Completed
Push — master ( 011918...3a8b9a )
by Paweł
31:19 queued 19:29
created

CreatePage   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 3
dl 0
loc 93
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getRouteName() 0 4 1
A titleReview() 0 4 1
A setComment() 0 4 1
A setAuthor() 0 4 1
A rateReview() 0 4 1
A submitReview() 0 4 1
A getRateValidationMessage() 0 4 1
A getTitleValidationMessage() 0 4 1
A getCommentValidationMessage() 0 4 1
A getAuthorValidationMessage() 0 4 1
A getDefinedElements() 0 10 1
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