1 | <?php |
||
12 | class Options |
||
13 | { |
||
14 | /** |
||
15 | * The number of processes to run at a time |
||
16 | * |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $processes; |
||
20 | |||
21 | /** |
||
22 | * The test path pointing to tests that will |
||
23 | * be run |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $path; |
||
28 | |||
29 | /** |
||
30 | * The path to the PHPUnit binary that will be run |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $phpunit; |
||
35 | |||
36 | /** |
||
37 | * Determines whether or not ParaTest runs in |
||
38 | * functional mode. If enabled, ParaTest will run |
||
39 | * every test method in a separate process |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $functional; |
||
44 | |||
45 | /** |
||
46 | * Prevents starting new tests after a test has failed. |
||
47 | * |
||
48 | * @var boolean |
||
49 | */ |
||
50 | protected $stopOnFailure; |
||
51 | |||
52 | /** |
||
53 | * A collection of post-processed option values. This is the collection |
||
54 | * containing ParaTest specific options |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $filtered; |
||
59 | |||
60 | /** |
||
61 | * The number of times that a test needs to be repeated. |
||
62 | * |
||
63 | * @var int |
||
64 | */ |
||
65 | protected $repeat; |
||
66 | |||
67 | /** |
||
68 | * Whether or not should repeat only the failing tests. |
||
69 | * |
||
70 | * @var int |
||
71 | */ |
||
72 | protected $only_repeat_failed; |
||
73 | |||
74 | /** |
||
75 | * A collection of option values directly corresponding |
||
76 | * to certain annotations - i.e group |
||
77 | * |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $annotations = array(); |
||
81 | |||
82 | 42 | public function __construct($opts = array()) |
|
121 | |||
122 | /** |
||
123 | * Public read accessibility |
||
124 | * |
||
125 | * @param $var |
||
126 | * @return mixed |
||
127 | */ |
||
128 | 40 | public function __get($var) |
|
132 | |||
133 | /** |
||
134 | * Returns a collection of ParaTest's default |
||
135 | * option values |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | 42 | protected static function defaults() |
|
157 | |||
158 | /** |
||
159 | * Get the path to phpunit |
||
160 | * First checks if a Windows batch script is in the composer vendors directory. |
||
161 | * Composer automatically handles creating a .bat file, so if on windows this should be the case. |
||
162 | * Second look for the phpunit binary under nix |
||
163 | * Defaults to phpunit on the users PATH |
||
164 | * @return string $phpunit the path to phpunit |
||
165 | */ |
||
166 | 42 | protected static function phpunit() |
|
182 | |||
183 | /** |
||
184 | * Get the path to the vendor directory |
||
185 | * First assumes vendor directory is accessible from src (i.e development) |
||
186 | * Second assumes vendor directory is accessible within src |
||
187 | */ |
||
188 | 42 | protected static function vendorDir() |
|
197 | |||
198 | /** |
||
199 | * Filter options to distinguish between paratest |
||
200 | * internal options and any other options |
||
201 | * @param array $options |
||
202 | * @return array |
||
203 | */ |
||
204 | 42 | protected function filterOptions($options) |
|
227 | |||
228 | /** |
||
229 | * Take an array of filtered options and return a |
||
230 | * configuration path |
||
231 | * |
||
232 | * @param $filtered |
||
233 | * @return string|null |
||
234 | */ |
||
235 | 42 | protected function getConfigurationPath($filtered) |
|
242 | |||
243 | /** |
||
244 | * Retrieve the default configuration given a path (directory or file). |
||
245 | * This will search into the directory, if a directory is specified |
||
246 | * |
||
247 | * @param string $path The path to search into |
||
248 | * @param string $default The default value to give back |
||
249 | * @return string|null |
||
250 | */ |
||
251 | 42 | private function getDefaultConfigurationForPath($path = '.', $default = null) |
|
267 | |||
268 | /** |
||
269 | * Load options that are represented by annotations |
||
270 | * inside of tests i.e @group group1 = --group group1 |
||
271 | */ |
||
272 | 42 | protected function initAnnotations() |
|
281 | |||
282 | /** |
||
283 | * @param $file |
||
284 | * @return bool |
||
285 | */ |
||
286 | 42 | private function isFile($file) |
|
290 | } |
||
291 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: