1 | <?php |
||
20 | class PHPUnit extends Tester |
||
21 | { |
||
22 | /** |
||
23 | * @var \ParaTest\Console\Commands\ParaTestCommand |
||
24 | */ |
||
25 | protected $command; |
||
26 | |||
27 | /** |
||
28 | * Configures the ParaTestCommand with PHPUnit specific |
||
29 | * definitions |
||
30 | * |
||
31 | * @param Command $command |
||
32 | * @return mixed |
||
33 | */ |
||
34 | 8 | public function configure(Command $command) |
|
51 | |||
52 | /** |
||
53 | * Executes the PHPUnit Runner. Will Display help if no config and no path |
||
54 | * supplied |
||
55 | * |
||
56 | * @param InputInterface $input |
||
57 | * @param OutputInterface $output |
||
58 | * @return int|mixed |
||
59 | */ |
||
60 | public function execute(InputInterface $input, OutputInterface $output) |
||
61 | { |
||
62 | if (!$this->hasConfig($input) && !$this->hasPath($input)) { |
||
63 | $this->displayHelp($input, $output); |
||
64 | } |
||
65 | |||
66 | if ($input->getOption('runner') === 'WrapperRunner') { |
||
67 | $runner = new WrapperRunner($this->getRunnerOptions($input)); |
||
68 | } else { |
||
69 | if ($input->getOption('runner') !== '') { |
||
70 | // because we want to have to bootstrap script inherited before check/initialization |
||
71 | $runnerOption = $this->getRunnerOptions($input); |
||
72 | $runnerClass = $input->getOption('runner'); |
||
73 | if (class_exists($runnerClass)) { |
||
74 | $runner = new $runnerClass($runnerOption); |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | |||
79 | if (!isset($runner)) { |
||
80 | $runner = new Runner($this->getRunnerOptions($input)); |
||
81 | } |
||
82 | |||
83 | // Allow the tests to be repeated. |
||
84 | $statusCode = 0; |
||
85 | $repeat = $input->getOption('repeat') ?: 1; |
||
86 | for ($i = 0; $i < $repeat; $i++) { |
||
87 | $runner->run(); |
||
88 | $status = $runner->getExitCode(); |
||
89 | $statusCode = $status ? $status : $statusCode; |
||
90 | } |
||
91 | |||
92 | // Print all messages at the end. |
||
93 | $runner->complete(); |
||
94 | |||
95 | return $statusCode; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Returns whether or not a test path has been supplied |
||
100 | * via option or regular input |
||
101 | * |
||
102 | * @param InputInterface $input |
||
103 | * @return bool |
||
104 | */ |
||
105 | protected function hasPath(InputInterface $input) |
||
111 | |||
112 | /** |
||
113 | * Is there a PHPUnit xml configuration present |
||
114 | * |
||
115 | * @param InputInterface $input |
||
116 | * @return bool |
||
117 | */ |
||
118 | 4 | protected function hasConfig(InputInterface $input) |
|
122 | |||
123 | /** |
||
124 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
125 | * @return \ParaTest\Runners\PHPUnit\Configuration|boolean |
||
126 | */ |
||
127 | 4 | protected function getConfig(InputInterface $input) |
|
143 | |||
144 | /** |
||
145 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
146 | * @return array |
||
147 | * @throws \RuntimeException |
||
148 | */ |
||
149 | 4 | public function getRunnerOptions(InputInterface $input) |
|
166 | |||
167 | /** |
||
168 | * Require the bootstrap. If the file is specified, but does not exist |
||
169 | * then an exception will be raised. |
||
170 | * |
||
171 | * @param $file |
||
172 | * @throws \RuntimeException |
||
173 | */ |
||
174 | 5 | public function requireBootstrap($file) |
|
187 | |||
188 | /** |
||
189 | * This function limits the scope of a required file |
||
190 | * so that variables defined in it do not break |
||
191 | * this object's configuration. |
||
192 | */ |
||
193 | 5 | protected function scopedRequire($file) |
|
199 | |||
200 | /** |
||
201 | * Return whether or not code coverage information should be collected. |
||
202 | * |
||
203 | * @param $options |
||
204 | * @return bool |
||
205 | */ |
||
206 | 4 | protected function hasCoverage($options) |
|
212 | |||
213 | /** |
||
214 | * Fetch the path to the bootstrap file. |
||
215 | * |
||
216 | * @param InputInterface $input |
||
217 | * @param array $options |
||
218 | * @return string |
||
219 | */ |
||
220 | 4 | protected function getBootstrapFile(InputInterface $input, array $options) |
|
235 | } |
||
236 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.