1 | <?php |
||
21 | abstract class TestCase extends BaseTestCase |
||
22 | { |
||
23 | /** |
||
24 | * Holds drivers fixtures. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected static $_drivers = []; |
||
29 | |||
30 | /** |
||
31 | * Current Driver for this testcase. |
||
32 | * |
||
33 | * @var Driver |
||
34 | */ |
||
35 | protected $_driver; |
||
36 | |||
37 | /** |
||
38 | * The type of the spiderling driver (kohana, phantomjs ...). |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $_driver_type; |
||
43 | |||
44 | /** |
||
45 | * The Environment object making sure you can set env variables and restore them after the test. |
||
46 | * |
||
47 | * @var \Openbuildings\EnvironmentBackup\Environment |
||
48 | */ |
||
49 | protected $_environment; |
||
50 | |||
51 | /** |
||
52 | * Restore environment and clear the specific driver if its active. |
||
53 | 17 | */ |
|
54 | protected function tearDown(): void |
||
66 | |||
67 | /** |
||
68 | * Return the current driver. This will use driver_simple, driver_kohana ... methods |
||
69 | * You can override them yourself in order to have custom configs. |
||
70 | * |
||
71 | * Drivers are cached as fixtured for the whole testrun and is shared between tests. |
||
72 | 7 | */ |
|
73 | public function driver(): Driver |
||
87 | 1 | ||
88 | public function driver_simple(): Driver_Simple |
||
92 | |||
93 | public function driver_simple_xml(): Driver_SimpleXML |
||
97 | 1 | ||
98 | public function driver_kohana(): Driver_Kohana |
||
102 | 1 | ||
103 | public function driver_phantomjs(): Driver_Phantomjs |
||
107 | |||
108 | /** |
||
109 | * Get the type of the driver for the current test. |
||
110 | * Use annotations to change the driver type e.g. @driver phantomjs. |
||
111 | 7 | */ |
|
112 | public function driver_type(): string |
||
125 | |||
126 | /** |
||
127 | * Return the environment object that handles setting / restoring env variables. |
||
128 | */ |
||
129 | public function environment(): Environment |
||
141 | 17 | ||
142 | /** |
||
143 | 17 | * Return true if the driver has been invoked in some way. |
|
144 | */ |
||
145 | public function is_driver_active(): bool |
||
149 | 17 | ||
150 | /** |
||
151 | 17 | * Return true if the environment has been modified / accessed. |
|
152 | */ |
||
153 | public function is_environment_active(): bool |
||
157 | |||
158 | 6 | /** |
|
159 | * Return the root node of the current page, opened by the driver |
||
160 | 6 | * Extend it with custom assertions from Assert. |
|
161 | 6 | */ |
|
162 | public function page(): Page |
||
169 | |||
170 | /** |
||
171 | * All other methods are handled by the root node of the page. |
||
172 | * |
||
173 | * @param string $method |
||
174 | 5 | * @param array $args |
|
175 | * |
||
176 | 5 | * @return mixed |
|
177 | */ |
||
178 | public function __call($method, $args) |
||
182 | 3 | ||
183 | 1 | private function getDriverFromType(string $type): Driver |
|
202 | } |
||
203 |