Create::createTicket()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace hipanel\modules\ticket\tests\_support\Page\ticket;
4
5
use hipanel\tests\_support\Page\Authenticated;
6
use hipanel\tests\_support\Page\Widget\Input\Input;
7
use hipanel\tests\_support\Page\Widget\Input\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
    public function createTicket($subject, $message, $topic)
18
    {
19
        $I = $this->tester;
20
21
        $I->amOnPage(Url::to(['@ticket/create']));
22
23
        (new Select2($I, '#thread-topics'))->setValue($topic);
24
25
        (new Input($I, '#thread-subject'))->setValue($subject);
26
        (new Input($I, '#thread-message'))->setValue($message);
27
28
        $this->seePreviewWorks($message);
29
30
        $I->click('Create ticket', '#create-thread-form');
31
        $this->seeTicketWasCreated($message, $topic);
32
33
        return $I->grabValueFrom(View::THREAD_ID_SELECTOR);
34
    }
35
36
    protected function seePreviewWorks($message)
37
    {
38
        $I = $this->tester;
39
40
        $I->click('a[href="#preview-create-thread-form"]');
41
        $I->waitForText($message, 30, '#preview-create-thread-form');
42
    }
43
44
    protected function seeTicketWasCreated($message, $topic)
45
    {
46
        $I = $this->tester;
47
48
        $I->waitForText('Ticket posted', 30);
49
        $I->seeInCurrentUrl('/ticket/view?id=');
50
        $I->see($topic);
51
        $I->see('Close ticket', 'a');
52
        $I->see($message);
53
    }
54
}
55