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

DomainsCest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 81
Duplicated Lines 46.91 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 38
loc 81
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 4 1
A ensureIndexPageWorks() 9 9 1
A ensureICanSeeAdvancedSearchBox() 0 27 1
A ensureICanSeeLegendBox() 15 15 2
A ensureICanSeeBulkSearchBox() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 DomainsCest
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('@hdomain'));
25
        $I->see('Domains', 'h1');
26
        $this->ensureICanSeeAdvancedSearchBox($I);
27
        $this->ensureICanSeeLegendBox($I);
28
        $this->ensureICanSeeBulkSearchBox();
29
    }
30
31
    private function ensureICanSeeAdvancedSearchBox(Client $I)
32
    {
33
        $I->see('Create domain', 'a');
34
        $I->see('Advanced search', 'h3');
35
36
        $formId = 'form-advancedsearch-hdomain-search';
37
        $this->index->containsFilters($formId, [
38
            ['input' => [
39
                'id' => 'hdomainsearch-domain_like',
40
                'placeholder' => 'Domain name',
41
            ]],
42
            ['input' => [
43
                'id' => 'hdomainsearch-domain_in',
44
            ]],
45
            ['input' => [
46
                'id' => 'hdomainsearch-ip',
47
                'placeholder' => 'IP',
48
            ]],
49
        ]);
50
51
        $I->see('Status', "//form[@id='$formId']//span");
52
        $I->see('Show aliases only', "//form[@id='$formId']//span");
53
        $I->see('Server', "//form[@id='$formId']//span");
54
        $I->see('Domain name', "//form[@id='$formId']//label");
55
        $I->see('Domain list (comma-separated)', "//form[@id='$formId']//label");
56
        $I->see('Type', "//form[@id='$formId']//label");
57
    }
58
59 View Code Duplication
    private function ensureICanSeeLegendBox(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...
60
    {
61
        $I->see('Legend', 'h3');
62
63
        $legend = [
64
            'Domain',
65
            'DNS records',
66
            'Alias',
67
            'Name server',
68
            'Complex domain',
69
        ];
70
        foreach ($legend as $text) {
71
            $I->see($text, '//ul/li');
72
        }
73
    }
74
75 View Code Duplication
    private function ensureICanSeeBulkSearchBox()
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...
76
    {
77
        $this->index->containsBulkButtons([
78
            ["//button[@type='submit']" => 'Delete'],
79
        ]);
80
        $this->index->containsColumns('bulk-hdomain-search', [
81
            'Domain name',
82
            'Account',
83
            'Server',
84
            'Status',
85
            'IP',
86
            'Service',
87
        ]);
88
    }
89
}
90