1 | <?php |
||
24 | abstract class Page |
||
25 | { |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $elements = []; |
||
30 | |||
31 | /** |
||
32 | * @var Session |
||
33 | */ |
||
34 | private $session; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $parameters; |
||
40 | |||
41 | /** |
||
42 | * @var DocumentElement|null |
||
43 | */ |
||
44 | private $document; |
||
45 | |||
46 | /** |
||
47 | * @param Session $session |
||
48 | * @param array $parameters |
||
49 | */ |
||
50 | public function __construct(Session $session, array $parameters = []) |
||
55 | |||
56 | /** |
||
57 | * @param array $urlParameters |
||
58 | * |
||
59 | * @throws UnexpectedPageException If page is not opened successfully |
||
60 | */ |
||
61 | public function open(array $urlParameters = []) |
||
66 | |||
67 | /** |
||
68 | * @param array $urlParameters |
||
69 | */ |
||
70 | public function tryToOpen(array $urlParameters = []) |
||
74 | |||
75 | /** |
||
76 | * @param array $urlParameters |
||
77 | * |
||
78 | * @throws UnexpectedPageException |
||
79 | */ |
||
80 | public function verify(array $urlParameters) |
||
86 | |||
87 | /** |
||
88 | * @param array $urlParameters |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function isOpen(array $urlParameters = []) |
||
102 | |||
103 | /** |
||
104 | * @return string |
||
105 | */ |
||
106 | abstract protected function getPath(); |
||
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | protected function getName() |
||
115 | |||
116 | /** |
||
117 | * @param array $urlParameters |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | protected function getUrl(array $urlParameters = []) |
||
125 | |||
126 | /** |
||
127 | * @throws UnexpectedPageException |
||
128 | */ |
||
129 | protected function verifyResponse() |
||
144 | |||
145 | /** |
||
146 | * Overload to verify if the current url matches the expected one. Throw an exception otherwise. |
||
147 | * |
||
148 | * @param array $urlParameters |
||
149 | */ |
||
150 | protected function verifyUrl(array $urlParameters = []) |
||
156 | |||
157 | /** |
||
158 | * Overload to verify if we're on an expected page. Throw an exception otherwise. |
||
159 | * |
||
160 | * @throws UnexpectedPageException |
||
161 | */ |
||
162 | protected function verifyPage() |
||
165 | |||
166 | /** |
||
167 | * @param int $statusCode |
||
168 | * |
||
169 | * @return bool |
||
170 | */ |
||
171 | protected function isErrorResponse($statusCode) |
||
175 | |||
176 | /** |
||
177 | * @param string $name |
||
178 | * |
||
179 | * @return NodeElement |
||
180 | */ |
||
181 | protected function getParameter($name) |
||
185 | |||
186 | /** |
||
187 | * @param string $name |
||
188 | * |
||
189 | * @return NodeElement |
||
190 | */ |
||
191 | public function getElement($name) |
||
201 | |||
202 | /** |
||
203 | * @param string $name |
||
204 | * |
||
205 | * @return bool |
||
206 | */ |
||
207 | protected function hasElement($name) |
||
211 | |||
212 | /** |
||
213 | * @param string $name |
||
214 | * |
||
215 | * @return NodeElement |
||
216 | */ |
||
217 | protected function createElement($name) |
||
228 | |||
229 | /** |
||
230 | * @return Session |
||
231 | */ |
||
232 | protected function getSession() |
||
236 | |||
237 | /** |
||
238 | * @return DriverInterface |
||
239 | */ |
||
240 | protected function getDriver() |
||
244 | |||
245 | /** |
||
246 | * @return DocumentElement |
||
247 | */ |
||
248 | protected function getDocument() |
||
256 | |||
257 | /** |
||
258 | * @param array $urlParameters |
||
259 | * |
||
260 | * @return string |
||
261 | */ |
||
262 | private function unmaskUrl(array $urlParameters) |
||
272 | |||
273 | /** |
||
274 | * @param string|array $selector |
||
275 | * @param SelectorsHandler $selectorsHandler |
||
276 | * |
||
277 | * @return string |
||
278 | */ |
||
279 | private function getSelectorAsXpath($selector, SelectorsHandler $selectorsHandler) |
||
286 | } |
||
287 |