Completed
Push — 1.3 ( 9fd5a5...ccc470 )
by Kamil
32:09 queued 20:38
created

ResetPasswordPage::checkValidationMessageFor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Behat\Page\Shop\Account;
15
16
use Behat\Mink\Exception\ElementNotFoundException;
17
use Sylius\Behat\Page\SymfonyPage;
18
19
class ResetPasswordPage extends SymfonyPage implements ResetPasswordPageInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getRouteName()
25
    {
26
        return 'sylius_shop_password_reset';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function reset(): void
33
    {
34
        $this->getDocument()->pressButton('Reset');
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function specifyNewPassword(string $password): void
41
    {
42
        $this->getElement('password')->setValue($password);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function specifyConfirmPassword(string $password): void
49
    {
50
        $this->getElement('confirm_password')->setValue($password);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function checkValidationMessageFor(string $element, string $message): bool
57
    {
58
        $errorLabel = $this->getElement($element)->getParent()->find('css', '.sylius-validation-error');
59
60
        if (null === $errorLabel) {
61
            throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error');
62
        }
63
64
        return $message === $errorLabel->getText();
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    protected function getDefinedElements()
71
    {
72
        return array_merge(parent::getDefinedElements(), [
73
            'password' => '#sylius_user_reset_password_password_first',
74
            'confirm_password' => '#sylius_user_reset_password_password_second',
75
        ]);
76
    }
77
}
78