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

IPAddressesCest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 4 4 1
A ensureIndexPageWorks() 9 9 1
A ensureICanSeeAdvancedSearchBox() 8 8 1
A ensureICanSeeLegendBox() 10 10 1
A ensureICanSeeBulkSearchBox() 8 8 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\seller;
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\Seller;
10
11 View Code Duplication
class IPAddressesCest
0 ignored issues
show
Duplication introduced by pkolomiy
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(Seller $I)
19
    {
20
        $this->index = new IndexPage($I);
21
    }
22
23
    public function ensureIndexPageWorks(Seller $I)
24
    {
25
        $I->login();
26
        $I->needPage(Url::to('@ip'));
27
        $I->see('IP addresses', 'h1');
28
        $this->ensureICanSeeAdvancedSearchBox();
29
        $this->ensureICanSeeLegendBox();
30
        $this->ensureICanSeeBulkSearchBox();
31
    }
32
33
    private function ensureICanSeeAdvancedSearchBox()
34
    {
35
        $this->index->containsFilters([
36
            new Input('IP'),
37
            new Select2('Servers'),
38
            new Input('Tags'),
39
        ]);
40
    }
41
42
    private function ensureICanSeeLegendBox()
43
    {
44
        $this->index->containsLegend([
45
            'Shared',
46
            'Free',
47
            'Dedicated',
48
            'System',
49
            'Blocked',
50
        ]);
51
    }
52
53
    private function ensureICanSeeBulkSearchBox()
54
    {
55
        $this->index->containsColumns([
56
            'IP',
57
            'Counters',
58
            'Links',
59
        ]);
60
    }
61
}
62