Completed
Push — master ( f8a75f...a37a81 )
by Dmitry
9s
created

TariffPlansCest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 16.36 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 9
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 4 1
A ensureIndexPageWorks() 9 9 1
A ensureICanSeeAdvancedSearchBox() 0 18 1
A ensureICanSeeBulkBillSearchBox() 0 13 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 advancedhosters\hipanel\tests\acceptance\module\finance\manager;
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\Dropdown;
9
use hipanel\tests\_support\Page\Widget\Input\Select2;
10
use hipanel\tests\_support\Step\Acceptance\Manager;
11
12
class TariffPlansCest
13
{
14
    /**
15
     * @var IndexPage
16
     */
17
    private $index;
18
19
    public function _before(Manager $I)
20
    {
21
        $this->index = new IndexPage($I);
22
    }
23
24 View Code Duplication
    public function ensureIndexPageWorks(Manager $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...
25
    {
26
        $I->login();
27
        $I->needPage(Url::to('@plan'));
28
        $I->see('Tariff plans', 'h1');
29
        $I->seeLink('Create', Url::to('@plan/create'));
30
        $this->ensureICanSeeAdvancedSearchBox();
31
        $this->ensureICanSeeBulkBillSearchBox();
32
    }
33
34
    private function ensureICanSeeAdvancedSearchBox()
35
    {
36
        $this->index->containsFilters([
37
            new Input('Name Ilike'),
38
            new Select2('Client'),
39
            (new Dropdown('plansearch-type'))->withItems([
40
                'Server',
41
                'vCDN',
42
                'pCDN',
43
                'IP',
44
                'Account',
45
                'Domain',
46
                'Client',
47
                'Template',
48
            ]),
49
            new Input('Statuses'),
50
        ]);
51
    }
52
53
    private function ensureICanSeeBulkBillSearchBox()
54
    {
55
        $this->index->containsBulkButtons([
56
            'Restore',
57
            'Delete',
58
        ]);
59
        $this->index->containsColumns([
60
            'Name',
61
            'Client',
62
            'Type',
63
            'Status',
64
        ]);
65
    }
66
}
67