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