1 | <?php |
||
27 | abstract class Page implements PageObject |
||
28 | { |
||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $elements = []; |
||
33 | |||
34 | /** |
||
35 | * @var Session |
||
36 | */ |
||
37 | private $session; |
||
38 | |||
39 | /** |
||
40 | * @var Factory |
||
41 | */ |
||
42 | private $factory; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | private $parameters; |
||
48 | |||
49 | /** |
||
50 | * @var DocumentElement |
||
51 | */ |
||
52 | private $document; |
||
53 | |||
54 | /** |
||
55 | * @param Session $session |
||
56 | * @param Factory $factory |
||
57 | * @param array $parameters |
||
58 | */ |
||
59 | public function __construct(Session $session, Factory $factory, array $parameters = []) |
||
67 | |||
68 | /** |
||
69 | * @param array $urlParameters |
||
70 | * |
||
71 | * @throws UnexpectedPageException If page is not opened successfully |
||
72 | */ |
||
73 | public function open(array $urlParameters = []) |
||
78 | |||
79 | /** |
||
80 | * @param array $urlParameters |
||
81 | */ |
||
82 | public function tryToOpen(array $urlParameters = []) |
||
86 | |||
87 | /** |
||
88 | * @param array $urlParameters |
||
89 | * |
||
90 | * @throws UnexpectedPageException |
||
91 | */ |
||
92 | public function verify(array $urlParameters) |
||
98 | |||
99 | /** |
||
100 | * @param array $urlParameters |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public function isOpen(array $urlParameters = []) |
||
114 | |||
115 | /** |
||
116 | * @return string |
||
117 | */ |
||
118 | abstract protected function getPath(); |
||
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | protected function getName() |
||
127 | |||
128 | /** |
||
129 | * @param array $urlParameters |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | protected function getUrl(array $urlParameters = []) |
||
137 | |||
138 | /** |
||
139 | * @throws UnexpectedPageException |
||
140 | */ |
||
141 | protected function verifyResponse() |
||
156 | |||
157 | /** |
||
158 | * Overload to verify if the current url matches the expected one. Throw an exception otherwise. |
||
159 | * |
||
160 | * @param array $urlParameters |
||
161 | */ |
||
162 | protected function verifyUrl(array $urlParameters = []) |
||
168 | |||
169 | /** |
||
170 | * Overload to verify if we're on an expected page. Throw an exception otherwise. |
||
171 | * |
||
172 | * @throws UnexpectedPageException |
||
173 | */ |
||
174 | protected function verifyPage() |
||
177 | |||
178 | /** |
||
179 | * @param int $statusCode |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | protected function isErrorResponse($statusCode) |
||
187 | |||
188 | /** |
||
189 | * @param string $name |
||
190 | * |
||
191 | * @return string|null |
||
192 | */ |
||
193 | protected function getParameter($name) |
||
197 | |||
198 | /** |
||
199 | * @param string $name |
||
200 | * |
||
201 | * @return Element |
||
202 | */ |
||
203 | public function getElement($name) |
||
213 | |||
214 | /** |
||
215 | * @param string $name |
||
216 | * |
||
217 | * @return bool |
||
218 | */ |
||
219 | protected function hasElement($name) |
||
223 | |||
224 | /** |
||
225 | * @param string $name |
||
226 | * |
||
227 | * @return Element |
||
228 | */ |
||
229 | protected function createElement($name) |
||
237 | |||
238 | /** |
||
239 | * @return Session |
||
240 | */ |
||
241 | protected function getSession() |
||
245 | |||
246 | /** |
||
247 | * @return DriverInterface |
||
248 | */ |
||
249 | protected function getDriver() |
||
253 | |||
254 | /** |
||
255 | * @return DocumentElement |
||
256 | */ |
||
257 | protected function getDocument() |
||
261 | |||
262 | /** |
||
263 | * @param string $path |
||
264 | * |
||
265 | * @return string |
||
266 | */ |
||
267 | private function makeSurePathIsAbsolute($path) |
||
273 | |||
274 | /** |
||
275 | * @param array $urlParameters |
||
276 | * |
||
277 | * @return string |
||
278 | */ |
||
279 | private function unmaskUrl(array $urlParameters) |
||
289 | } |
||
290 |