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

Create::seePreviewWorks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
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 hipanel\tests\_support\Page\Widget\Select2;
8
use yii\helpers\Url;
9
10
/**
11
 * Class Create
12
 *
13
 * @author Dmytro Naumenko <[email protected]>
14
 */
15
class Create extends Authenticated
16
{
17
    /**
18
     * @var Select2
19
     */
20
    protected $select2;
21
22
    public function __construct(AcceptanceTester $I)
23
    {
24
        parent::__construct($I);
25
26
        $this->select2 = new Select2($I);
27
    }
28
29
    public function createTicket($subject, $message, $topic)
30
    {
31
        $I = $this->tester;
32
33
        $I->amOnPage(Url::to(['@ticket/create']));
34
35
        $this->select2->open('#thread-topics');
36
        $I->see('General question');
37
        $I->see('Financial question');
38
        $I->see('VDS');
39
40
        $this->select2->chooseOption($topic);
41
42
        $I->fillField('#thread-subject', $subject);
43
        $I->fillField('#thread-message', $message);
44
        $this->seePreviewWorks($message);
45
46
        $I->click('Create ticket', '#create-thread-form');
47
        $this->seeTicketWasCreated($message, $topic);
48
49
        return $I->grabValueFrom(View::THREAD_ID_SELECTOR);
50
    }
51
52
    protected function seePreviewWorks($message)
53
    {
54
        $I = $this->tester;
55
56
        $I->click('a[href="#preview-create-thread-form"]');
57
        $I->waitForText($message, 10, '#preview-create-thread-form');
58
    }
59
60
    protected function seeTicketWasCreated($message, $topic)
61
    {
62
        $I = $this->tester;
63
64
        $I->waitForText('Ticket posted');
65
        $I->seeInCurrentUrl('/ticket/view?id=');
66
        $I->see($topic);
67
        $I->see('Close ticket', 'a');
68
        $I->see($message);
69
    }
70
}
71