Completed
Push — master ( 27c0a7...08c543 )
by Dmitry
11s
created

DomainsCest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 65
loc 65
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 4 4 1
A ensureIndexPageWorks() 10 10 1
A ensureICanSeeAdvancedSearchBox() 13 13 1
A ensureICanSeeLegendBox() 10 10 1
A ensureICanSeeBulkSearchBox() 16 16 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\admin;
4
5
use hipanel\helpers\Url;
6
use hipanel\tests\_support\Page\IndexPage;
7
use hipanel\tests\_support\Page\Widget\Input\Input;
8
use hipanel\tests\_support\Page\Widget\Input\Select2;
9
use hipanel\tests\_support\Step\Acceptance\Admin;
10
11 View Code Duplication
class DomainsCest
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    /**
14
     * @var IndexPage
15
     */
16
    private $index;
17
18
    public function _before(Admin $I)
19
    {
20
        $this->index = new IndexPage($I);
21
    }
22
23
    public function ensureIndexPageWorks(Admin $I)
24
    {
25
        $I->login();
26
        $I->needPage(Url::to('@hdomain'));
27
        $I->see('Domains', 'h1');
28
        $I->see('Create domain', 'a');
29
        $this->ensureICanSeeAdvancedSearchBox();
30
        $this->ensureICanSeeLegendBox();
31
        $this->ensureICanSeeBulkSearchBox();
32
    }
33
34
    private function ensureICanSeeAdvancedSearchBox()
35
    {
36
        $this->index->containsFilters([
37
            new Input('Domain name'),
38
            new Input('Domain list (comma-separated)'),
39
            new Input('IP'),
40
            new Select2('Status'),
41
            new Select2('Show aliases only'),
42
            new Select2('Client'),
43
            new Select2('Reseller'),
44
            new Select2('Server'),
45
        ]);
46
    }
47
48
    private function ensureICanSeeLegendBox()
49
    {
50
        $this->index->containsLegend([
51
            'Domain',
52
            'DNS records',
53
            'Alias',
54
            'Name server',
55
            'Complex domain',
56
        ]);
57
    }
58
59
    private function ensureICanSeeBulkSearchBox()
60
    {
61
        $this->index->containsBulkButtons([
62
            'Delete',
63
        ]);
64
        $this->index->containsColumns([
65
            'Domain name',
66
            'Client',
67
            'Reseller',
68
            'Account',
69
            'Server',
70
            'Status',
71
            'IP',
72
            'Service',
73
        ]);
74
    }
75
}
76