Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class TestCase extends PHPUnitTestCase |
||
11 | { |
||
12 | /** |
||
13 | * @var Application |
||
14 | */ |
||
15 | protected $application; |
||
16 | |||
17 | protected function setUp() |
||
18 | { |
||
19 | $this->application = new Application(); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Returns an instance of the command tester using the options provided. |
||
24 | * |
||
25 | * @param string $commandName The name of the command being tested. |
||
26 | * @param array $options An array of options to pass to the command. |
||
27 | * @return CommandTester |
||
28 | * @throws RuntimeException |
||
29 | */ |
||
30 | protected function getCommandTester(string $commandName, array $options = []): CommandTester |
||
31 | { |
||
32 | if (!$command = $this->getApplication()->find($commandName)) { |
||
33 | throw new RuntimeException( |
||
34 | sprintf('Please register the % command before attempting to test it.', $commandName) |
||
35 | ); |
||
36 | } |
||
37 | $commandTester = new CommandTester($command); |
||
38 | $commandTester->execute(['command' => $commandName], $options); |
||
39 | return $commandTester; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Returns the application registered with this test. |
||
44 | * |
||
45 | * @return Application |
||
46 | */ |
||
47 | protected function getApplication(): Application |
||
50 | } |
||
51 | } |
||
52 |