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
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\tests\acceptance\admin;
12
13
use hipanel\helpers\Url;
14
use hipanel\tests\_support\Page\IndexPage;
15
use hipanel\tests\_support\Page\Widget\Input\Input;
16
use hipanel\tests\_support\Page\Widget\Input\Select2;
17
use hipanel\tests\_support\Step\Acceptance\Admin;
18
19 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...
20
{
21
    /**
22
     * @var IndexPage
23
     */
24
    private $index;
25
26
    public function _before(Admin $I)
27
    {
28
        $this->index = new IndexPage($I);
29
    }
30
31
    public function ensureIndexPageWorks(Admin $I)
32
    {
33
        $I->login();
34
        $I->needPage(Url::to('@db'));
35
        $I->see('Databases', 'h1');
36
        $I->seeLink('Create DB', Url::to('create'));
37
        $this->ensureICanSeeAdvancedSearchBox($I);
38
        $this->ensureICanSeeBulkSearchBox();
39
    }
40
41
    private function ensureICanSeeAdvancedSearchBox(Admin $I)
42
    {
43
        $this->index->containsFilters([
44
            Input::asAdvancedSearch($I, 'DB name'),
45
            Select2::asAdvancedSearch($I, 'Server'),
46
            Input::asAdvancedSearch($I, 'Description'),
47
            Select2::asAdvancedSearch($I, 'Client'),
48
            Select2::asAdvancedSearch($I, 'Reseller'),
49
            Select2::asAdvancedSearch($I, 'Status'),
50
        ]);
51
    }
52
53
    private function ensureICanSeeBulkSearchBox()
54
    {
55
        $this->index->containsBulkButtons([
56
            'Delete',
57
        ]);
58
        $this->index->containsColumns([
59
            'DB name',
60
            'Account',
61
            'Server',
62
            'Client',
63
            'Reseller',
64
            'Description',
65
            'Status',
66
        ]);
67
    }
68
}
69