Completed
Push — master ( 3ff7e6...cf5edc )
by Kamil
96:30 queued 63:14
created

CreatePage::getRateValidationMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
namespace Sylius\Behat\Page\Shop\ProductReview;
13
14
use Sylius\Behat\Page\SymfonyPage;
15
16
/**
17
 * @author Mateusz Zalewski <[email protected]>
18
 */
19
class CreatePage extends SymfonyPage implements CreatePageInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getRouteName()
25
    {
26
        return 'sylius_shop_product_reviews_create';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function titleReview($title)
33
    {
34
        $this->getDocument()->fillField('Title', $title);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function setComment($comment)
41
    {
42
        $this->getDocument()->fillField('sylius_product_review_comment', $comment);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function setAuthor($author)
49
    {
50
        $this->getDocument()->fillField('Author', $author);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function rateReview($rate)
57
    {
58
        $this->getElement('rate', ['%rate%' => $rate])->click();
59
    }
60
61
    public function submitReview()
62
    {
63
        $this->getDocument()->pressButton('Add');
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function getRateValidationMessage()
70
    {
71
        return $this->getElement('rating')->getParent()->find('css', '.sylius-validation-error')->getText();
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function getTitleValidationMessage()
78
    {
79
        return $this->getElement('title')->getParent()->find('css', '.sylius-validation-error')->getText();
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function getCommentValidationMessage()
86
    {
87
        return $this->getElement('comment')->getParent()->find('css', '.sylius-validation-error')->getText();
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function getAuthorValidationMessage()
94
    {
95
        return $this->getElement('author')->getParent()->find('css', '.sylius-validation-error')->getText();
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    protected function getDefinedElements()
102
    {
103
        return array_merge(parent::getDefinedElements(), [
104
            'author' => '#sylius_product_review_author_email',
105
            'comment' => '#sylius_product_review_comment',
106
            'rate' => '.star.rating .icon:nth-child(%rate%)',
107
            'rating' => '#sylius_product_review_rating',
108
            'title' => '#sylius_product_review_title',
109
        ]);
110
    }
111
}
112