|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Collision. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Nuno Maduro <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace NunoMaduro\Collision\Adapters\Phpunit\Commands; |
|
13
|
|
|
|
|
14
|
|
|
use NunoMaduro\Collision\Adapters\Phpunit\TestRunner; |
|
15
|
|
|
use Symfony\Component\Console\Command\Command; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
19
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
20
|
|
|
|
|
21
|
|
|
class TestCommand extends Command |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Test working path. |
|
25
|
|
|
* |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $workingPath; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Create a new command instance. |
|
32
|
|
|
* |
|
33
|
|
|
* @param string $workingPath |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(string $workingPath) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->workingPath = $workingPath; |
|
38
|
|
|
|
|
39
|
|
|
parent::__construct(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Configure the command options. |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function configure() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->ignoreValidationErrors(); |
|
50
|
|
|
|
|
51
|
|
|
$this->setName('run') |
|
52
|
|
|
->setDescription('Run the tests.') |
|
53
|
|
|
->addOption('without-tty', null, InputOption::VALUE_NONE, 'Disable output to TTY.'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Execute the command. |
|
58
|
|
|
* |
|
59
|
|
|
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
|
60
|
|
|
* |
|
61
|
|
|
* @return int 0 if everything went fine, or an exit code |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
64
|
|
|
{ |
|
65
|
|
|
$withoutTty = $input->getOption('without-tty'); |
|
66
|
|
|
|
|
67
|
|
|
$options = array_slice($_SERVER['argv'], $withoutTty ? 3 : 2); |
|
68
|
|
|
|
|
69
|
|
|
$runner = new TestRunner($this->workingPath, (bool) $withoutTty); |
|
70
|
|
|
|
|
71
|
|
|
return $runner(new SymfonyStyle($input, $output), $options); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|