Completed
Push — master ( 74eeb7...8293fb )
by Dmitry
15:44
created

View::seePageContainsComment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace hipanel\modules\ticket\tests\_support\ticket;
4
5
use hipanel\tests\_support\Page\Authenticated;
6
use yii\helpers\Url;
7
8
/**
9
 * Class View
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
class View extends Authenticated
14
{
15
    const THREAD_ID_SELECTOR = '.leave-comment-form input[name="Thread[id]"]';
16
17
    /**
18
     * @var string|int
19
     */
20
    private $ticketId;
21
22
    /**
23
     * View constructor.
24
     * @param \AcceptanceTester $I
25
     * @param string|int $ticketId
26
     */
27
    public function __construct(\AcceptanceTester $I, $ticketId)
28
    {
29
        parent::__construct($I);
30
31
        $this->ticketId = $ticketId;
32
    }
33
34
    public function visitTicket()
35
    {
36
        $I = $this->tester;
37
38
        $I->amOnPage(Url::to(['@ticket/view', 'id' => $this->ticketId]));
39
        $I->seeInField(self::THREAD_ID_SELECTOR, $this->ticketId);
40
41
        return $this;
42
    }
43
44
    public function postComment($message)
45
    {
46
        $I = $this->tester;
47
48
        $I->fillField('#thread-message', $message);
49
        $this->seePreviewWorks($message);
50
51
        $I->click('Submit');
52
        $I->waitForText('Ticket changed');
53
        $this->seePageContainsComment($message);
54
    }
55
56 View Code Duplication
    protected function seePreviewWorks($message)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
    {
58
        $I = $this->tester;
59
60
        $I->click('a[href="#preview-leave-comment-form"]');
61
        $I->wait(1);
62
        $I->performOn('#preview-leave-comment-form', \Codeception\Util\ActionSequence::build()
63
            ->see($message)
64
        );
65
    }
66
67
    protected function seePageContainsComment($message)
68
    {
69
        $I = $this->tester;
70
71
        $I->see($message, '.comment .comment-text .body');
72
    }
73
74 View Code Duplication
    public function closeTicket()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        $I = $this->tester;
77
78
        $I->see('Close ticket');
79
        $I->click('Close ticket');
80
        $I->waitForText('Ticket closed');
81
        $I->waitForText('Open ticket', 3);
82
    }
83
84 View Code Duplication
    public function openTicket()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
    {
86
        $I = $this->tester;
87
88
        $I->see('Open ticket');
89
        $I->click('Open ticket');
90
        $I->waitForText('Ticket opened');
91
        $I->waitForText('Close ticket', 3);
92
    }
93
}
94