Issues (213)

tests/acceptance/admin/ServerAssingHubsCest.php (1 issue)

Labels
Severity
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\seller;
12
13
use Codeception\Example;
0 ignored issues
show
The type Codeception\Example was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use hipanel\helpers\Url;
15
use hipanel\modules\server\tests\_support\Page\Hub\AssignHubs;
16
use hipanel\tests\_support\Page\IndexPage;
17
use hipanel\tests\_support\Page\Widget\Input\Select2;
18
use hipanel\tests\_support\Step\Acceptance\Admin;
19
20
class ServerAssingHubsCest
21
{
22
    /**
23
     * @var string|null
24
     */
25
    protected $serverId;
26
27
    /**
28
     * @var IndexPage
29
     */
30
    protected $indexPage;
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function _before(Admin $I)
36
    {
37
        $this->indexPage = new IndexPage($I);
38
    }
39
40
    /**
41
     * @dataProvider assignHubsProvider
42
     *
43
     * @param Admin $I
44
     * @param Example $data
45
     * @throws \Codeception\Exception\ModuleException
46
     */
47
    public function ensureICanAssignHubs(Admin $I, Example $data)
48
    {
49
        $assignPage = new AssignHubs($I);
50
        $this->serverId = $this->getTestServerId($I);
51
52
        $I->needPage(Url::to('@server/assign-hubs?id=' . $this->serverId));
53
54
        $assignPage->fillForm($data)
55
            ->hasNotErrors()
56
            ->submitForm();
57
58
        $I->see($data['net_id']);
59
    }
60
61
    /**
62
     * @dataProvider assignEmptyHubsProvider
63
     *
64
     * @param Admin $I
65
     * @param Example $data
66
     * @throws \Codeception\Exception\ModuleException
67
     */
68
    public function ensureICanRemoveAssignedHubs(Admin $I, Example $data)
69
    {
70
        $assignPage = new AssignHubs($I);
71
72
        $I->needPage(Url::to('@server/assign-hubs?id=' . $this->serverId));
73
74
        $assignPage->fillForm($data)
75
            ->hasNotErrors()
76
            ->submitForm();
77
78
        $I->cantSeeInField('h3[class*="box-title"]', 'Switches');
79
    }
80
81
    /**
82
     * @param Admin $I
83
     * @return string|null
84
     * @throws \Codeception\Exception\ModuleException
85
     */
86
    private function getTestServerId(Admin $I): ?string
87
    {
88
        $I->needPage(Url::to('@server'));
89
        $this->indexPage->filterBy((new Select2($I, "tr.filters select[name*=client]")), 'hipanel_test_reseller');
90
        $this->indexPage->openRowMenuByColumnValue('DC', 'TEST01');
91
        $this->indexPage->chooseRowMenuOption('View');
92
        return $I->grabFromCurrentUrl('~id=(\d+)~');
93
    }
94
95
    /**
96
     * @return array
97
     */
98
    protected function assignHubsProvider(): array
99
    {
100
        return [
101
            [
102
                'net_id'        => 'TEST-SW-05',
103
                'net_port'      => 'port' . uniqid(),
104
                'net2_id'       => 'TEST-SW-05',
105
                'net2_port'     => 'port' . uniqid(),
106
                'pdu2_id'       => 'TEST-SW-06',
107
                'pdu2_port'     => 'port' . uniqid(),
108
                'kvm_id'        => 'TEST-SW-04',
109
                'kvm_port'      => 'port' . uniqid(),
110
                'pdu_id'        => 'TEST-SW-06',
111
                'pdu_port'      => 'port' . uniqid(),
112
                'rack_id'       => 'TEST-SW-02',
113
                'rack_port'     => 'port' . uniqid(),
114
            ],
115
        ];
116
    }
117
118
    /**
119
     * @return array
120
     */
121
    protected function assignEmptyHubsProvider(): array
122
    {
123
        return [
124
            [
125
                'net_id'        => '',
126
                'net2_id'       => '',
127
                'pdu2_id'       => '',
128
                'kvm_id'        => '',
129
                'pdu_id'        => '',
130
                'rack_id'       => '',
131
            ],
132
        ];
133
    }
134
}
135