DatabasesCest::ensureIndexPageWorks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 DatabasesCest
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(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('@db'));
27
        $I->see('Databases', 'h1');
28
        $I->seeLink('Create DB', Url::to('create'));
29
        $this->ensureICanSeeAdvancedSearchBox($I);
30
        $this->ensureICanSeeBulkSearchBox();
31
    }
32
33
    private function ensureICanSeeAdvancedSearchBox(Admin $I)
34
    {
35
        $this->index->containsFilters([
36
            Input::asAdvancedSearch($I, 'DB name'),
37
            Select2::asAdvancedSearch($I, 'Server'),
38
            Input::asAdvancedSearch($I, 'Description'),
39
            Select2::asAdvancedSearch($I, 'Client'),
40
            Select2::asAdvancedSearch($I, 'Reseller'),
41
            Select2::asAdvancedSearch($I, 'Status'),
42
        ]);
43
    }
44
45
    private function ensureICanSeeBulkSearchBox()
46
    {
47
        $this->index->containsBulkButtons([
48
            'Delete',
49
        ]);
50
        $this->index->containsColumns([
51
            'DB name',
52
            'Account',
53
            'Server',
54
            'Client',
55
            'Reseller',
56
            'Description',
57
            'Status',
58
        ]);
59
    }
60
}
61