Completed
Push — master ( b21958...b5070f )
by Dmitry
33s
created

IPAddressesCest::_before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 IPAddressesCest
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)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
22
    {
23
        $I->login();
24
        $I->needPage(Url::to('@ip'));
25
        $I->see('IP addresses', 'h1');
26
        $this->ensureICanSeeAdvancedSearchBox($I);
27
        $this->ensureICanSeeLegendBox($I);
28
        $this->ensureICanSeeBulkSearchBox();
29
    }
30
31
    private function ensureICanSeeAdvancedSearchBox(Client $I)
32
    {
33
        $I->see('Advanced search', 'h3');
34
35
        $formId = 'form-advancedsearch-ip-search';
36
        $this->index->containsFilters($formId, [
37
            ['input' => [
38
                'id' => 'ipsearch-ip_like',
39
                'placeholder' => 'IP',
40
            ]],
41
            ['input' => [
42
                'placeholder' => 'Tags',
43
            ]],
44
        ]);
45
46
        $I->see('Servers', "//form[@id='$formId']//span");
47
    }
48
49
    private function ensureICanSeeLegendBox(Client $I)
50
    {
51
        $I->see('Legend', 'h3');
52
53
        $legend = [
54
            'Shared',
55
            'Free',
56
            'Dedicated',
57
            'System',
58
            'Blocked',
59
        ];
60
        foreach ($legend as $text) {
61
            $I->see($text, '//ul/li');
62
        }
63
    }
64
65
    private function ensureICanSeeBulkSearchBox()
66
    {
67
        $this->index->containsColumns('bulk-ip-search', [
68
            'IP',
69
            'Counters',
70
            'Links',
71
        ]);
72
    }
73
}
74