Completed
Push — master ( 910aee...a67276 )
by Dmitry
03:24
created

View::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace hipanel\modules\ticket\tests\_support\Page\ticket;
4
5
use hipanel\tests\_support\AcceptanceTester;
6
use hipanel\tests\_support\Page\Authenticated;
7
use yii\helpers\Url;
8
9
/**
10
 * Class View
11
 *
12
 * @author Dmytro Naumenko <[email protected]>
13
 */
14
class View extends Authenticated
15
{
16
    const THREAD_ID_SELECTOR = '.leave-comment-form input[name="Thread[id]"]';
17
18
    /**
19
     * @var string|int
20
     */
21
    private $ticketId;
22
23
    /**
24
     * View constructor.
25
     * @param \AcceptanceTester $I
26
     * @param string|int $ticketId
27
     */
28
    public function __construct(AcceptanceTester $I, $ticketId)
29
    {
30
        parent::__construct($I);
31
32
        $this->ticketId = $ticketId;
33
    }
34
35
    public function visitTicket()
36
    {
37
        $I = $this->tester;
38
39
        $I->amOnPage(Url::to(['@ticket/view', 'id' => $this->ticketId]));
40
        $I->seeInField(self::THREAD_ID_SELECTOR, $this->ticketId);
41
42
        return $this;
43
    }
44
45
    public function postComment($message)
46
    {
47
        $I = $this->tester;
48
49
        $I->fillField('#thread-message', $message);
50
        $this->seePreviewWorks($message);
51
52
        $I->click('Answer', '#leave-comment-form');
53
        $I->waitForText('Ticket changed');
54
        $this->seePageContainsComment($message);
55
    }
56
57
    protected function seePreviewWorks($message)
58
    {
59
        $I = $this->tester;
60
61
        $I->click('a[href="#preview-leave-comment-form"]');
62
        $I->waitForText($message, 10, '#preview-leave-comment-form');
63
    }
64
65
    protected function seePageContainsComment($message)
66
    {
67
        $I = $this->tester;
68
69
        $I->see($message, '.comment .comment-text .body');
70
    }
71
72 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...
73
    {
74
        $I = $this->tester;
75
76
        $I->see('Close ticket');
77
        $I->click('Close ticket');
78
        $I->waitForText('Ticket closed');
79
        $I->waitForText('Open ticket', 3);
80
    }
81
82 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...
83
    {
84
        $I = $this->tester;
85
86
        $I->see('Open ticket');
87
        $I->click('Open ticket');
88
        $I->waitForText('Ticket opened');
89
        $I->waitForText('Close ticket', 3);
90
    }
91
}
92