1 | <?php |
||
10 | class UserContext extends RawUserContext |
||
11 | { |
||
12 | /** |
||
13 | * @example |
||
14 | * Then I am logged in as a user with "CRM Client" role and filled fields |
||
15 | * | Full name | Sergii Bondarenko | |
||
16 | * | Position | Developer | |
||
17 | * | field_crm_user_company | FFW | |
||
18 | * |
||
19 | * @param string $roles |
||
20 | * User roles, separated by comma. |
||
21 | * @param TableNode $fields |
||
22 | * | Field machine name or label | Value | |
||
23 | * |
||
24 | * @throws \EntityMetadataWrapperException |
||
25 | * When user object cannot be saved. |
||
26 | * @throws \Exception |
||
27 | * When required fields are not filled. |
||
28 | * |
||
29 | * @Given /^(?:|I am )logged in as a user with "([^"]*)" role(?:|s)(?:| and filled fields:)$/ |
||
30 | */ |
||
31 | public function loginCreatedUser($roles, TableNode $fields = null) |
||
32 | { |
||
33 | $this->createDrupalUser($roles, $fields); |
||
34 | $this->loginUser(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @see loginCreatedUser() |
||
39 | * |
||
40 | * @Then /^(?:|I )create a user with "([^"]*)" role(?:|s)(?:| and filled fields:)$/ |
||
41 | */ |
||
42 | public function createDrupalUser($roles, TableNode $fields = null) |
||
46 | |||
47 | /** |
||
48 | * @param TableNode $credentials |
||
49 | * | username | BR0kEN | |
||
50 | * | password | p4sswd | |
||
51 | * |
||
52 | * @throws \Exception |
||
53 | * When user cannot be authorized. |
||
54 | * |
||
55 | * @Given /^(?:|I )am logged in with credentials:/ |
||
56 | */ |
||
57 | public function loginWithCredentials(TableNode $credentials) |
||
61 | |||
62 | /** |
||
63 | * This step must be used instead of "I am an anonymous user" because it |
||
64 | * has more strict checking for authenticated user. |
||
65 | * |
||
66 | * @Given /^I am unauthorized user$/ |
||
67 | * @Given /^I am log out$/ |
||
68 | */ |
||
69 | public function logoutDrupalUser() |
||
73 | |||
74 | /** |
||
75 | * @AfterScenario |
||
76 | */ |
||
77 | public function afterUserScenario() { |
||
83 | } |
||
84 |