mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
* install spatie/phpunit-snapshot-assertions * switch GenerateBasicPhpdocFinal test to snapshot assertion * use v3 of spatie/phpunit-snapshot-assertions to be PHP7.2 compatible * add txt snapshot driver * fix EloquentCommandTest * replace all heredocs by snapshots * make test compatible with old/deprecated versions * Update composer.json * normalize composer.json * fix merge conflict * Allow older snapshot versions * normalize composer.json Co-authored-by: Barry vd. Heuvel <[email protected]> Co-authored-by: barryvdh <[email protected]>
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Orchestra\Testbench\TestCase as BaseTestCase;
|
|
use Spatie\Snapshots\MatchesSnapshots;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
use MatchesSnapshots;
|
|
|
|
/**
|
|
* The `CommandTester` is directly returned, use methods like
|
|
* `->getDisplay()` or `->getStatusCode()` on it.
|
|
*
|
|
* @param Command $command
|
|
* @param array $arguments The command line arguments, array of key=>value
|
|
* Examples:
|
|
* - named arguments: ['model' => 'Post']
|
|
* - boolean flags: ['--all' => true]
|
|
* - arguments with values: ['--arg' => 'value']
|
|
* @param array $interactiveInput Interactive responses to the command
|
|
* I.e. anything the command `->ask()` or `->confirm()`, etc.
|
|
* @return CommandTester
|
|
*/
|
|
protected function runCommand(Command $command, array $arguments = [], array $interactiveInput = []): CommandTester
|
|
{
|
|
$command->setLaravel($this->app);
|
|
|
|
$tester = new CommandTester($command);
|
|
$tester->setInputs($interactiveInput);
|
|
|
|
$tester->execute($arguments);
|
|
|
|
return $tester;
|
|
}
|
|
|
|
protected function assertMatchesPhpSnapshot(?string $actualContent)
|
|
{
|
|
$this->assertMatchesSnapshot($actualContent, new SnapshotPhpDriver());
|
|
}
|
|
|
|
protected function assertMatchesTxtSnapshot(?string $actualContent)
|
|
{
|
|
$this->assertMatchesSnapshot($actualContent, new SnapshotTxtDriver());
|
|
}
|
|
}
|