mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
* phpunit: use dedicate `Tests` namespace for tests * tests: replace phpunit with orchestra/testbench * phpunit: ignore result cache file * phpunit: adapt test for newer version * tests: add base testcase class with a helper to run/assert commands * tests: add test for ide-helper:eloquent * travis: add global default variables * travis: disable xdebug, speeds up running tests * travis: convert php versions to build matrix for environment vars * travis: only run phpcs/phpunit when the env vars signal it However phpcs only runs with one test combination from the matrix, not necessary to execute it every time.
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Orchestra\Testbench\TestCase as BaseTestCase;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|