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 | * A collection of option values directly corresponding |
||
69 | * to certain annotations - i.e group |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | protected $annotations = array(); |
||
74 | |||
75 | 42 | public function __construct($opts = array()) |
|
113 | |||
114 | /** |
||
115 | * Public read accessibility |
||
116 | * |
||
117 | * @param $var |
||
118 | * @return mixed |
||
119 | */ |
||
120 | 40 | public function __get($var) |
|
124 | |||
125 | /** |
||
126 | * Returns a collection of ParaTest's default |
||
127 | * option values |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | 42 | protected static function defaults() |
|
148 | |||
149 | /** |
||
150 | * Get the path to phpunit |
||
151 | * First checks if a Windows batch script is in the composer vendors directory. |
||
152 | * Composer automatically handles creating a .bat file, so if on windows this should be the case. |
||
153 | * Second look for the phpunit binary under nix |
||
154 | * Defaults to phpunit on the users PATH |
||
155 | * @return string $phpunit the path to phpunit |
||
156 | */ |
||
157 | 42 | protected static function phpunit() |
|
173 | |||
174 | /** |
||
175 | * Get the path to the vendor directory |
||
176 | * First assumes vendor directory is accessible from src (i.e development) |
||
177 | * Second assumes vendor directory is accessible within src |
||
178 | */ |
||
179 | 42 | protected static function vendorDir() |
|
188 | |||
189 | /** |
||
190 | * Filter options to distinguish between paratest |
||
191 | * internal options and any other options |
||
192 | * @param array $options |
||
193 | * @return array |
||
194 | */ |
||
195 | 42 | protected function filterOptions($options) |
|
217 | |||
218 | /** |
||
219 | * Take an array of filtered options and return a |
||
220 | * configuration path |
||
221 | * |
||
222 | * @param $filtered |
||
223 | * @return string|null |
||
224 | */ |
||
225 | 42 | protected function getConfigurationPath($filtered) |
|
232 | |||
233 | /** |
||
234 | * Retrieve the default configuration given a path (directory or file). |
||
235 | * This will search into the directory, if a directory is specified |
||
236 | * |
||
237 | * @param string $path The path to search into |
||
238 | * @param string $default The default value to give back |
||
239 | * @return string|null |
||
240 | */ |
||
241 | 42 | private function getDefaultConfigurationForPath($path = '.', $default = null) |
|
257 | |||
258 | /** |
||
259 | * Load options that are represented by annotations |
||
260 | * inside of tests i.e @group group1 = --group group1 |
||
261 | */ |
||
262 | 42 | protected function initAnnotations() |
|
271 | |||
272 | /** |
||
273 | * @param $file |
||
274 | * @return bool |
||
275 | */ |
||
276 | 42 | private function isFile($file) |
|
280 | } |
||
281 |
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: