1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hipanel\modules\ticket\tests\acceptance\client; |
4
|
|
|
|
5
|
|
|
use Codeception\Scenario; |
6
|
|
|
use hipanel\helpers\Url; |
7
|
|
|
use hipanel\modules\ticket\tests\_support\Page\ticket\Create; |
8
|
|
|
use hipanel\modules\ticket\tests\_support\Page\ticket\Index; |
9
|
|
|
use hipanel\modules\ticket\tests\_support\Page\ticket\View; |
10
|
|
|
use hipanel\tests\_support\Page\IndexPage; |
11
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Input; |
12
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Select2; |
13
|
|
|
use hipanel\tests\_support\Step\Acceptance\Client; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class TicketCest |
17
|
|
|
* |
18
|
|
|
* @author Dmytro Naumenko <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class TicketCest |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string|int |
24
|
|
|
*/ |
25
|
|
|
protected $ticket_id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var IndexPage |
29
|
|
|
*/ |
30
|
|
|
private $index; |
31
|
|
|
|
32
|
|
|
public function _before(Client $I) |
33
|
|
|
{ |
34
|
|
|
$this->index = new IndexPage($I); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function ensureIndexPageWorks(Client $I) |
38
|
|
|
{ |
39
|
|
|
$I->login(); |
40
|
|
|
$I->needPage(Url::to('@ticket')); |
41
|
|
|
$I->see('Tickets', 'h1'); |
42
|
|
|
$I->seeLink('Create ticket', Url::to('@ticket/create')); |
43
|
|
|
$this->ensureICanSeeAdvancedSearchBox(); |
44
|
|
|
$this->ensureICanSeeBulkSearchBox(); |
45
|
|
|
(new Index($I))->ensurePageWorks(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
private function ensureICanSeeAdvancedSearchBox() |
49
|
|
|
{ |
50
|
|
|
$this->index->containsFilters([ |
51
|
|
|
new Input('Subject or message'), |
52
|
|
|
new Select2('Status'), |
53
|
|
|
new Input('Topics'), |
54
|
|
|
]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
private function ensureICanSeeBulkSearchBox() |
58
|
|
|
{ |
59
|
|
|
$this->index->containsBulkButtons([ |
60
|
|
|
'Subscribe', |
61
|
|
|
'Unsubscribe', |
62
|
|
|
'Close', |
63
|
|
|
]); |
64
|
|
|
$this->index->containsColumns([ |
65
|
|
|
'Subject', |
66
|
|
|
'Answers', |
67
|
|
|
]); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function ensureICanNavigateToCreateTicketPage(Client $I) |
71
|
|
|
{ |
72
|
|
|
(new Index($I))->ensureThatICanNavigateToCreateTicketPage(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function ensureICanCreateTicket(Client $I) |
76
|
|
|
{ |
77
|
|
|
$this->ticket_id = (new Create($I))->createTicket( |
78
|
|
|
'Test ticket (' . date('Y-m-d H:i') . ')', |
79
|
|
|
'This is a test ticket created by automated testing system. Ignore it, please.', |
80
|
|
|
'General question' |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function ensureISeeCreatedTicketOnIndexPage(Client $I, Scenario $scenario) |
85
|
|
|
{ |
86
|
|
|
if (!isset($this->ticket_id)) { |
87
|
|
|
$scenario->incomplete('Ticket ID must be filled to run this test'); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
$index = new Index($I); |
91
|
|
|
$index->hasLinkToTicket($this->ticket_id); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function ensureICanCommentTicket(Client $I, Scenario $scenario) |
95
|
|
|
{ |
96
|
|
|
if (!isset($this->ticket_id)) { |
97
|
|
|
$scenario->incomplete('Ticket ID must be filled to run this test'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
$view = new View($I, $this->ticket_id); |
101
|
|
|
$view->visitTicket(); |
102
|
|
|
$view->postComment('This is a test comment. Ignore it, please.'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function ensureICanChangeTicketState(Client $I, Scenario $scenario) |
106
|
|
|
{ |
107
|
|
|
if (!isset($this->ticket_id)) { |
108
|
|
|
$scenario->incomplete('Ticket ID must be filled to run this test'); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$view = new View($I, $this->ticket_id); |
112
|
|
|
$view->visitTicket(); |
113
|
|
|
$view->closeTicket(); |
114
|
|
|
|
115
|
|
|
$I->openNewTab(); |
116
|
|
|
$index = new Index($I); |
117
|
|
|
$index->hasntLinkToTicket($this->ticket_id); |
118
|
|
|
$I->closeTab(); |
119
|
|
|
|
120
|
|
|
$view->openTicket(); |
121
|
|
|
$view->closeTicket(); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|