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, selenium ...). |
||
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 | */ |
||
54 | 18 | 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 | */ |
||
73 | 8 | public function driver(): Driver |
|
87 | |||
88 | 1 | public function driver_simple(): Driver_Simple |
|
92 | |||
93 | public function driver_simple_xml(): Driver_SimpleXML |
||
97 | |||
98 | 1 | public function driver_kohana(): Driver_Kohana |
|
102 | |||
103 | 1 | public function driver_selenium(): Driver_Selenium |
|
107 | |||
108 | 1 | public function driver_phantomjs(): Driver_Phantomjs |
|
112 | |||
113 | /** |
||
114 | * Get the type of the driver for the current test. |
||
115 | * Use annotations to change the driver type e.g. @driver selenium. |
||
116 | */ |
||
117 | 8 | public function driver_type(): string |
|
127 | |||
128 | /** |
||
129 | * Return the environment object that handles setting / restoring env variables. |
||
130 | */ |
||
131 | public function environment(): Environment |
||
143 | |||
144 | /** |
||
145 | * Return true if the driver has been invoked in some way. |
||
146 | */ |
||
147 | 18 | public function is_driver_active(): bool |
|
151 | |||
152 | /** |
||
153 | * Return true if the environment has been modified / accessed. |
||
154 | */ |
||
155 | 17 | public function is_environment_active(): bool |
|
159 | |||
160 | /** |
||
161 | * Return the root node of the current page, opened by the driver |
||
162 | * Extend it with custom assertions from Assert. |
||
163 | */ |
||
164 | 7 | public function page(): Page |
|
171 | |||
172 | /** |
||
173 | * All other methods are handled by the root node of the page. |
||
174 | * |
||
175 | * @param string $method |
||
176 | * @param array $args |
||
177 | * |
||
178 | * @return mixed |
||
179 | */ |
||
180 | 6 | public function __call($method, $args) |
|
184 | |||
185 | 4 | private function getDriverFromType(string $type): Driver |
|
207 | } |
||
208 |