1 | <?php |
||
13 | class Options |
||
14 | { |
||
15 | /** |
||
16 | * The number of processes to run at a time. |
||
17 | * |
||
18 | * @var int |
||
19 | */ |
||
20 | protected $processes; |
||
21 | |||
22 | /** |
||
23 | * The test path pointing to tests that will |
||
24 | * be run. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $path; |
||
29 | |||
30 | /** |
||
31 | * The path to the PHPUnit binary that will be run. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $phpunit; |
||
36 | |||
37 | /** |
||
38 | * Determines whether or not ParaTest runs in |
||
39 | * functional mode. If enabled, ParaTest will run |
||
40 | * every test method in a separate process. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $functional; |
||
45 | |||
46 | /** |
||
47 | * Prevents starting new tests after a test has failed. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $stopOnFailure; |
||
52 | |||
53 | /** |
||
54 | * A collection of post-processed option values. This is the collection |
||
55 | * containing ParaTest specific options. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $filtered; |
||
60 | |||
61 | /** |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $runner; |
||
65 | |||
66 | /** |
||
67 | * @var bool |
||
68 | */ |
||
69 | protected $noTestTokens; |
||
70 | |||
71 | /** |
||
72 | * @var bool |
||
73 | */ |
||
74 | protected $colors; |
||
75 | |||
76 | /** |
||
77 | * Filters which tests to run. |
||
78 | * |
||
79 | * @var string|null |
||
80 | */ |
||
81 | protected $testsuite; |
||
82 | |||
83 | /** |
||
84 | * @var int|null |
||
85 | */ |
||
86 | protected $maxBatchSize; |
||
87 | |||
88 | /** |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $filter; |
||
92 | |||
93 | /** |
||
94 | * @var string[] |
||
95 | */ |
||
96 | protected $groups; |
||
97 | |||
98 | /** |
||
99 | * @var string[] |
||
100 | */ |
||
101 | protected $excludeGroups; |
||
102 | |||
103 | /** |
||
104 | * A collection of option values directly corresponding |
||
105 | * to certain annotations - i.e group. |
||
106 | * |
||
107 | * @var array |
||
108 | */ |
||
109 | protected $annotations = []; |
||
110 | |||
111 | 42 | public function __construct(array $opts = []) |
|
148 | |||
149 | /** |
||
150 | * Public read accessibility. |
||
151 | * |
||
152 | * @param string $var |
||
153 | * |
||
154 | * @return mixed |
||
155 | */ |
||
156 | 40 | public function __get(string $var) |
|
160 | |||
161 | /** |
||
162 | * Public read accessibility |
||
163 | * (e.g. to make empty($options->property) work as expected). |
||
164 | * |
||
165 | * @param string $var |
||
166 | * |
||
167 | * @return mixed |
||
168 | */ |
||
169 | 23 | public function __isset(string $var): bool |
|
173 | |||
174 | /** |
||
175 | * Returns a collection of ParaTest's default |
||
176 | * option values. |
||
177 | * |
||
178 | * @return array |
||
179 | */ |
||
180 | 42 | protected static function defaults(): array |
|
196 | |||
197 | /** |
||
198 | * Get the path to phpunit |
||
199 | * First checks if a Windows batch script is in the composer vendors directory. |
||
200 | * Composer automatically handles creating a .bat file, so if on windows this should be the case. |
||
201 | * Second look for the phpunit binary under nix |
||
202 | * Defaults to phpunit on the users PATH. |
||
203 | * |
||
204 | * @return string $phpunit the path to phpunit |
||
205 | */ |
||
206 | 42 | protected static function phpunit(): string |
|
221 | |||
222 | /** |
||
223 | * Get the path to the vendor directory |
||
224 | * First assumes vendor directory is accessible from src (i.e development) |
||
225 | * Second assumes vendor directory is accessible within src. |
||
226 | */ |
||
227 | 42 | protected static function vendorDir(): string |
|
236 | |||
237 | /** |
||
238 | * Filter options to distinguish between paratest |
||
239 | * internal options and any other options. |
||
240 | */ |
||
241 | 42 | protected function filterOptions(array $options): array |
|
262 | |||
263 | /** |
||
264 | * Take an array of filtered options and return a |
||
265 | * configuration path. |
||
266 | * |
||
267 | * @param $filtered |
||
268 | * |
||
269 | * @return string|null |
||
270 | */ |
||
271 | 42 | protected function getConfigurationPath(array $filtered) |
|
279 | |||
280 | /** |
||
281 | * Retrieve the default configuration given a path (directory or file). |
||
282 | * This will search into the directory, if a directory is specified. |
||
283 | * |
||
284 | * @param string $path The path to search into |
||
285 | * @param string $default The default value to give back |
||
286 | * |
||
287 | * @return string|null |
||
288 | */ |
||
289 | 42 | private function getDefaultConfigurationForPath(string $path = '.', string $default = null) |
|
306 | |||
307 | /** |
||
308 | * Load options that are represented by annotations |
||
309 | * inside of tests i.e @group group1 = --group group1. |
||
310 | */ |
||
311 | 42 | protected function initAnnotations() |
|
320 | |||
321 | /** |
||
322 | * @param $file |
||
323 | * |
||
324 | * @return bool |
||
325 | */ |
||
326 | 42 | private function isFile(string $file): bool |
|
330 | } |
||
331 |