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