|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Server module for HiPanel |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-server |
|
6
|
|
|
* @package hipanel-module-server |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\server\tests\acceptance\admin; |
|
12
|
|
|
|
|
13
|
|
|
use Codeception\Example; |
|
|
|
|
|
|
14
|
|
|
use hipanel\helpers\Url; |
|
15
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\AssignHubs; |
|
16
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\Create; |
|
17
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\Delete; |
|
18
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\Update; |
|
19
|
|
|
use hipanel\tests\_support\Page\IndexPage; |
|
20
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Dropdown; |
|
21
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Input; |
|
22
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Select2; |
|
23
|
|
|
use hipanel\tests\_support\Step\Acceptance\Admin; |
|
24
|
|
|
|
|
25
|
|
|
class HubCest |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var IndexPage |
|
29
|
|
|
*/ |
|
30
|
|
|
private $index; |
|
31
|
|
|
|
|
32
|
|
|
public function _before(Admin $I) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->index = new IndexPage($I); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param Admin $I |
|
39
|
|
|
*/ |
|
40
|
|
|
public function ensureIndexPageWorks(Admin $I): void |
|
41
|
|
|
{ |
|
42
|
|
|
$I->login(); |
|
43
|
|
|
$I->needPage(Url::to('@hub')); |
|
44
|
|
|
$I->see('Switches', 'h1'); |
|
45
|
|
|
$I->seeLink('Create switch', Url::to('@hub/create')); |
|
46
|
|
|
$this->ensureICanSeeAdvancedSearchBox($I); |
|
47
|
|
|
$this->ensureICanSeeLegendBox(); |
|
48
|
|
|
$this->ensureICanSeeBulkServerSearchBox(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @dataProvider createProvider |
|
53
|
|
|
* @param Admin $I |
|
54
|
|
|
* @param Example $data |
|
55
|
|
|
*/ |
|
56
|
|
|
public function ensureICanCreateHub(Admin $I, Example $data): void |
|
57
|
|
|
{ |
|
58
|
|
|
$I->needPage(Url::to(['@hub/create'])); |
|
59
|
|
|
$page = new Create($I); |
|
60
|
|
|
$page->fillForm($data); |
|
61
|
|
|
$page->submitForm(); |
|
62
|
|
|
$I->seeInCurrentUrl('hub/view?id'); |
|
63
|
|
|
$page->check($data); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @dataProvider assignHubsProvider |
|
68
|
|
|
* @param Admin $I |
|
69
|
|
|
* @param Example $data |
|
70
|
|
|
*/ |
|
71
|
|
|
public function ensureICanAssignHubs(Admin $I, Example $data): void |
|
72
|
|
|
{ |
|
73
|
|
|
$I->login(); |
|
74
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
75
|
|
|
$page = new AssignHubs($I); |
|
76
|
|
|
$page->needPageByName($data['hub_name']); |
|
77
|
|
|
$page->needGoToAssignForm(); |
|
78
|
|
|
unset($data['hub_name']); |
|
79
|
|
|
$page->fillAssignForm($data); |
|
80
|
|
|
$page->submitForm(); |
|
81
|
|
|
$page->checkAssigned($data); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @dataProvider updateProvider |
|
87
|
|
|
* @param Admin $I |
|
88
|
|
|
* @param Example $data |
|
89
|
|
|
*/ |
|
90
|
|
|
public function ensureICanUpdateHub(Admin $I, Example $data): void |
|
91
|
|
|
{ |
|
92
|
|
|
$I->login(); |
|
93
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
94
|
|
|
$page = new Update($I); |
|
95
|
|
|
$name = str_replace('_updated', '', $data['name']); |
|
96
|
|
|
$page->needPageByName($name); |
|
97
|
|
|
$page->needUpdatePage(); |
|
98
|
|
|
$page->fillForm($data); |
|
99
|
|
|
$page->submitForm(); |
|
100
|
|
|
$I->seeInCurrentUrl('hub/view?id'); |
|
101
|
|
|
$page->check($data); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @dataProvider updateProvider |
|
106
|
|
|
* @param Admin $I |
|
107
|
|
|
* @param Example $data |
|
108
|
|
|
*/ |
|
109
|
|
|
public function ensureICanDeleteHub(Admin $I, Example $data): void |
|
110
|
|
|
{ |
|
111
|
|
|
$I->login(); |
|
112
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
113
|
|
|
$page = new Delete($I); |
|
114
|
|
|
$page->needPageByName($data['name']); |
|
115
|
|
|
$page->deleteHub($data['name']); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return array |
|
120
|
|
|
*/ |
|
121
|
|
|
protected function createProvider(): array |
|
122
|
|
|
{ |
|
123
|
|
|
return [ |
|
124
|
|
|
[ |
|
125
|
|
|
'name' => 'test_switch', |
|
126
|
|
|
'type_id' => 'Switch', |
|
127
|
|
|
'mac' => '00:27:0e:2a:b9:aa', |
|
128
|
|
|
'inn' => 'test_inn', |
|
129
|
|
|
'ip' => '127.0.0.1', |
|
130
|
|
|
'model' => 'test_model', |
|
131
|
|
|
'note' => 'test_note', |
|
132
|
|
|
], |
|
133
|
|
|
]; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @return array |
|
138
|
|
|
*/ |
|
139
|
|
|
protected function updateProvider(): array |
|
140
|
|
|
{ |
|
141
|
|
|
$result = []; |
|
142
|
|
|
foreach ($this->createProvider() as $rows) { |
|
143
|
|
|
$data = []; |
|
144
|
|
|
foreach ($rows as $field => $value) { |
|
145
|
|
|
if (!in_array($field, ['type_id', 'ip', 'mac'])) { |
|
146
|
|
|
$data[$field] = $value . '_updated'; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
$result[] = $data; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
return $result; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return array |
|
157
|
|
|
*/ |
|
158
|
|
|
protected function optionsProvider(): array |
|
159
|
|
|
{ |
|
160
|
|
|
return [ |
|
161
|
|
|
[ |
|
162
|
|
|
], |
|
163
|
|
|
]; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @return array |
|
168
|
|
|
*/ |
|
169
|
|
|
protected function assignHubsProvider(): array |
|
170
|
|
|
{ |
|
171
|
|
|
return [ |
|
172
|
|
|
[ |
|
173
|
|
|
'hub_name' => 'test_switch', |
|
174
|
|
|
'net_id' => 'TEST-SW-05', |
|
175
|
|
|
'net_port' => 'port5', |
|
176
|
|
|
'kvm_id' => 'TEST-SW-04', |
|
177
|
|
|
'kvm_port' => 'port4', |
|
178
|
|
|
'pdu_id' => 'TEST-SW-06', |
|
179
|
|
|
'pdu_port' => 'port6', |
|
180
|
|
|
'rack_id' => 'TEST-SW-02', |
|
181
|
|
|
'rack_port' => 'port2', |
|
182
|
|
|
'console_id' => null, |
|
183
|
|
|
'console_port' => null, |
|
184
|
|
|
'location_id' => 'TEST-SW-03', |
|
185
|
|
|
'location_port' => '', |
|
186
|
|
|
], |
|
187
|
|
|
]; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
private function ensureICanSeeAdvancedSearchBox(Admin $I) |
|
191
|
|
|
{ |
|
192
|
|
|
$this->index->containsFilters([ |
|
193
|
|
|
Input::asAdvancedSearch($I, 'Switch'), |
|
194
|
|
|
Input::asAdvancedSearch($I, 'INN'), |
|
195
|
|
|
Input::asAdvancedSearch($I, 'IP'), |
|
196
|
|
|
Input::asAdvancedSearch($I, 'MAC address'), |
|
197
|
|
|
Input::asAdvancedSearch($I, 'Model'), |
|
198
|
|
|
Input::asAdvancedSearch($I, 'Order No.'), |
|
199
|
|
|
(Dropdown::asAdvancedSearch($I, 'Type'))->withItems([ |
|
200
|
|
|
'Switch', |
|
201
|
|
|
'KVM', |
|
202
|
|
|
'APC', |
|
203
|
|
|
'Rack', |
|
204
|
|
|
'IPMI', |
|
205
|
|
|
'Module', |
|
206
|
|
|
]), |
|
207
|
|
|
Select2::asAdvancedSearch($I, 'Buyer'), |
|
208
|
|
|
Input::asAdvancedSearch($I, 'Tariff'), |
|
209
|
|
|
Input::asAdvancedSearch($I, 'Rack'), |
|
210
|
|
|
]); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
private function ensureICanSeeLegendBox() |
|
214
|
|
|
{ |
|
215
|
|
|
$this->index->containsLegend([ |
|
216
|
|
|
'Switch', |
|
217
|
|
|
'KVM', |
|
218
|
|
|
'APC', |
|
219
|
|
|
'IPMI', |
|
220
|
|
|
'Module', |
|
221
|
|
|
'Rack', |
|
222
|
|
|
'Camera', |
|
223
|
|
|
'Cable organizer', |
|
224
|
|
|
]); |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
private function ensureICanSeeBulkServerSearchBox() |
|
228
|
|
|
{ |
|
229
|
|
|
$this->index->containsBulkButtons([ |
|
230
|
|
|
'Update', |
|
231
|
|
|
]); |
|
232
|
|
|
$this->index->containsColumns([ |
|
233
|
|
|
'Name', |
|
234
|
|
|
'INN', |
|
235
|
|
|
'Model', |
|
236
|
|
|
'Type', |
|
237
|
|
|
'IP', |
|
238
|
|
|
'MAC address', |
|
239
|
|
|
]); |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths