1 | <?php |
||
15 | class RawUserContext extends RawTqContext |
||
16 | { |
||
17 | use BaseEntity; |
||
18 | |||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | protected function entityType() |
||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | protected function getCurrentId() |
||
34 | |||
35 | /** |
||
36 | * @param string $column |
||
37 | * Column of a "users" table. |
||
38 | * @param string $value |
||
39 | * Expected value in column. |
||
40 | * |
||
41 | * @return int |
||
42 | */ |
||
43 | protected function getIdByArguments($column, $value) |
||
49 | |||
50 | /** |
||
51 | * @param string $roles |
||
52 | * Necessary user roles separated by comma. |
||
53 | * @param array $fields |
||
54 | * |
||
55 | * @return \stdClass |
||
56 | */ |
||
57 | public function createUserWithRoles($roles, array $fields = []) |
||
68 | |||
69 | /** |
||
70 | * @throws \Exception |
||
71 | */ |
||
72 | public function loginUser() |
||
85 | |||
86 | /** |
||
87 | * @param array $props |
||
88 | * An array with two keys: "username" and "password". Both of them are required. |
||
89 | * @param string $message |
||
90 | * An error message, that will be thrown when user cannot be authenticated. |
||
91 | * |
||
92 | * @throws \Behat\Mink\Exception\ElementNotFoundException |
||
93 | * When one of a fields cannot be not found. |
||
94 | * @throws \Exception |
||
95 | * When login process failed. |
||
96 | * @throws \WebDriver\Exception\NoSuchElement |
||
97 | * When log in button cannot be found. |
||
98 | */ |
||
99 | public function fillLoginForm(array $props, $message = '') |
||
124 | |||
125 | /** |
||
126 | * Cookies are set when at least one page of the site has been visited. This |
||
127 | * action done in "beforeScenario" hook of TqContext. |
||
128 | * |
||
129 | * @see TqContext::beforeScenario() |
||
130 | * |
||
131 | * @return bool |
||
132 | */ |
||
133 | public function isLoggedIn() |
||
146 | |||
147 | public function logoutUser() |
||
154 | |||
155 | /** |
||
156 | * @param array $fields |
||
157 | * Additional data for user account. |
||
158 | * |
||
159 | * @throws \Exception |
||
160 | * |
||
161 | * @return \stdClass |
||
162 | */ |
||
163 | public function createTestUser(array $fields = []) |
||
229 | } |
||
230 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: