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