1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hipanel\modules\hosting\tests\acceptance\client; |
4
|
|
|
|
5
|
|
|
use hipanel\helpers\Url; |
6
|
|
|
use hipanel\tests\_support\Page\IndexPage; |
7
|
|
|
use hipanel\tests\_support\Step\Acceptance\Client; |
8
|
|
|
|
9
|
|
|
class RequestsCest |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var IndexPage |
13
|
|
|
*/ |
14
|
|
|
private $index; |
15
|
|
|
|
16
|
|
|
public function _before(Client $I) |
17
|
|
|
{ |
18
|
|
|
$this->index = new IndexPage($I); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
View Code Duplication |
public function ensureIndexPageWorks(Client $I) |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
$I->login(); |
24
|
|
|
$I->needPage(Url::to('@request')); |
25
|
|
|
$I->see('Requests', 'h1'); |
26
|
|
|
$this->ensureICanSeeAdvancedSearchBox($I); |
27
|
|
|
$this->ensureICanSeeLegendBox($I); |
28
|
|
|
$this->ensureICanSeeBulkSearchBox(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
View Code Duplication |
private function ensureICanSeeAdvancedSearchBox(Client $I) |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
$I->see('Advanced search', 'h3'); |
34
|
|
|
|
35
|
|
|
$formId = 'form-advancedsearch-request-search'; |
36
|
|
|
$this->index->containsFilters($formId, []); |
37
|
|
|
|
38
|
|
|
$I->see('Server', "//form[@id='$formId']//span"); |
39
|
|
|
$I->see('Account', "//form[@id='$formId']//span"); |
40
|
|
|
$I->see('Status', "//form[@id='$formId']//span"); |
41
|
|
|
$I->see('Object', "//form[@id='$formId']//span"); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
private function ensureICanSeeLegendBox(Client $I) |
45
|
|
|
{ |
46
|
|
|
$I->see('Legend', 'h3'); |
47
|
|
|
$I->see('Scheduled time:', 'h4'); |
48
|
|
|
$I->see('State:', 'h4'); |
49
|
|
|
|
50
|
|
|
$legend = [ |
51
|
|
|
'Already', |
52
|
|
|
'Deferred', |
53
|
|
|
'New', |
54
|
|
|
'In progress', |
55
|
|
|
'Done', |
56
|
|
|
'Error', |
57
|
|
|
'Buzzed', |
58
|
|
|
]; |
59
|
|
|
foreach ($legend as $text) { |
60
|
|
|
$I->see($text, '//ul/li'); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
View Code Duplication |
private function ensureICanSeeBulkSearchBox() |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$this->index->containsBulkButtons([ |
67
|
|
|
["//button[@type='submit']" => 'Delete'], |
68
|
|
|
]); |
69
|
|
|
$this->index->containsColumns('bulk-request-search', [ |
70
|
|
|
'Action', |
71
|
|
|
'Server', |
72
|
|
|
'Account', |
73
|
|
|
'Object', |
74
|
|
|
'Time', |
75
|
|
|
'Status', |
76
|
|
|
]); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
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.