|
19 | 19 |
|
20 | 20 | class RegisterPage extends SymfonyPage implements RegisterPageInterface |
21 | 21 | { |
22 | | - /** |
23 | | - * {@inheritdoc} |
24 | | - */ |
25 | 22 | public function getRouteName(): string |
26 | 23 | { |
27 | 24 | return 'sylius_shop_register'; |
28 | 25 | } |
29 | 26 |
|
30 | 27 | /** |
31 | | - * {@inheritdoc} |
32 | | - * |
33 | 28 | * @throws ElementNotFoundException |
34 | 29 | */ |
35 | | - public function checkValidationMessageFor($element, $message) |
| 30 | + public function checkValidationMessageFor(string $element, string $message): bool |
36 | 31 | { |
37 | 32 | $errorLabel = $this |
38 | 33 | ->getElement(StringInflector::nameToCode($element)) |
39 | 34 | ->getParent() |
40 | | - ->find('css', '.sylius-validation-error') |
| 35 | + ->find('css', '[data-test-validation-error]') |
41 | 36 | ; |
42 | 37 |
|
43 | 38 | if (null === $errorLabel) { |
44 | | - throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error'); |
| 39 | + throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]'); |
45 | 40 | } |
46 | 41 |
|
47 | 42 | return $message === $errorLabel->getText(); |
48 | 43 | } |
49 | 44 |
|
50 | | - public function register() |
| 45 | + public function register(): void |
51 | 46 | { |
52 | | - $this->getDocument()->pressButton('Create an account'); |
| 47 | + $this->getElement('create_account_button')->press(); |
53 | 48 | } |
54 | 49 |
|
55 | | - /** |
56 | | - * {@inheritdoc} |
57 | | - */ |
58 | | - public function specifyEmail($email) |
| 50 | + public function specifyEmail(string $email): void |
59 | 51 | { |
60 | | - $this->getDocument()->fillField('Email', $email); |
| 52 | + $this->getElement('email')->setValue($email); |
61 | 53 | } |
62 | 54 |
|
63 | | - /** |
64 | | - * {@inheritdoc} |
65 | | - */ |
66 | | - public function specifyFirstName($firstName) |
| 55 | + public function specifyFirstName(string $firstName): void |
67 | 56 | { |
68 | | - $this->getDocument()->fillField('First name', $firstName); |
| 57 | + $this->getElement('first_name')->setValue($firstName); |
69 | 58 | } |
70 | 59 |
|
71 | | - /** |
72 | | - * {@inheritdoc} |
73 | | - */ |
74 | | - public function specifyLastName($lastName) |
| 60 | + public function specifyLastName(string $lastName): void |
75 | 61 | { |
76 | | - $this->getDocument()->fillField('Last name', $lastName); |
| 62 | + $this->getElement('last_name')->setValue($lastName); |
77 | 63 | } |
78 | 64 |
|
79 | | - /** |
80 | | - * {@inheritdoc} |
81 | | - */ |
82 | | - public function specifyPassword($password) |
| 65 | + public function specifyPassword(string $password): void |
83 | 66 | { |
84 | | - $this->getDocument()->fillField('Password', $password); |
| 67 | + $this->getElement('password')->setValue($password); |
85 | 68 | } |
86 | 69 |
|
87 | | - /** |
88 | | - * {@inheritdoc} |
89 | | - */ |
90 | | - public function specifyPhoneNumber($phoneNumber) |
| 70 | + public function specifyPhoneNumber(string $phoneNumber): void |
91 | 71 | { |
92 | | - $this->getDocument()->fillField('Phone number', $phoneNumber); |
| 72 | + $this->getElement('phone_number')->setValue($phoneNumber); |
93 | 73 | } |
94 | 74 |
|
95 | | - /** |
96 | | - * {@inheritdoc} |
97 | | - */ |
98 | | - public function verifyPassword($password) |
| 75 | + public function verifyPassword(string $password): void |
99 | 76 | { |
100 | | - $this->getDocument()->fillField('Verification', $password); |
| 77 | + $this->getElement('password_verification')->setValue($password); |
101 | 78 | } |
102 | 79 |
|
103 | | - public function subscribeToTheNewsletter() |
| 80 | + public function subscribeToTheNewsletter(): void |
104 | 81 | { |
105 | | - $this->getDocument()->checkField('Subscribe to the newsletter'); |
| 82 | + $this->getElement('subscribe_newsletter')->check(); |
106 | 83 | } |
107 | 84 |
|
108 | | - /** |
109 | | - * {@inheritdoc} |
110 | | - */ |
111 | 85 | protected function getDefinedElements(): array |
112 | 86 | { |
113 | 87 | return array_merge(parent::getDefinedElements(), [ |
114 | | - 'email' => '#sylius_customer_registration_email', |
115 | | - 'first_name' => '#sylius_customer_registration_firstName', |
116 | | - 'last_name' => '#sylius_customer_registration_lastName', |
117 | | - 'password_verification' => '#sylius_customer_registration_user_plainPassword_second', |
118 | | - 'password' => '#sylius_customer_registration_user_plainPassword_first', |
119 | | - 'phone_number' => '#sylius_customer_registration_phoneNumber', |
| 88 | + 'create_account_button' => '[data-test-register-button]', |
| 89 | + 'email' => '[data-test-email]', |
| 90 | + 'first_name' => '[data-test-first-name]', |
| 91 | + 'last_name' => '[data-test-last-name]', |
| 92 | + 'password' => '[data-test-password-first]', |
| 93 | + 'password_verification' => '[data-test-password-second]', |
| 94 | + 'phone_number' => '[data-test-phone-number]', |
| 95 | + 'subscribe_newsletter' => '[data-test-subscribed-to-newsletter]', |
120 | 96 | ]); |
121 | 97 | } |
122 | 98 | } |
0 commit comments