mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
[PROPOSAL] Add more tests to the library (#865)
* 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.
This commit is contained in:
committed by
Barry vd. Heuvel
parent
0d1dd2182b
commit
fb0c576806
@@ -0,0 +1,36 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user