BackupsCest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 4 4 1
A ensureIndexPageWorks() 8 8 1
A ensureICanSeeAdvancedSearchBox() 9 9 1
A ensureICanSeeBulkSearchBox() 19 19 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
 * 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\Select2;
16
use hipanel\tests\_support\Step\Acceptance\Admin;
17
18 View Code Duplication
class BackupsCest
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...
19
{
20
    /**
21
     * @var IndexPage
22
     */
23
    private $index;
24
25
    public function _before(Admin $I)
26
    {
27
        $this->index = new IndexPage($I);
28
    }
29
30
    public function ensureIndexPageWorks(Admin $I)
31
    {
32
        $I->login();
33
        $I->needPage(Url::to('@backuping'));
34
        $I->see('Backups', 'h1');
35
        $this->ensureICanSeeAdvancedSearchBox($I);
36
        $this->ensureICanSeeBulkSearchBox();
37
    }
38
39
    private function ensureICanSeeAdvancedSearchBox(Admin $I)
40
    {
41
        $this->index->containsFilters([
42
            Select2::asAdvancedSearch($I, 'State'),
43
            Select2::asAdvancedSearch($I, 'Account'),
44
            Select2::asAdvancedSearch($I, 'Server'),
45
            Select2::asAdvancedSearch($I, 'Client'),
46
        ]);
47
    }
48
49
    private function ensureICanSeeBulkSearchBox()
50
    {
51
        $this->index->containsBulkButtons([
52
            'Enable',
53
            'Disable',
54
            'Delete',
55
        ]);
56
        $this->index->containsColumns([
57
            'Name',
58
            'Client',
59
            'Account',
60
            'Server',
61
            'Count',
62
            'Periodicity',
63
            'State',
64
            'Last backup',
65
            'Disk usage',
66
        ]);
67
    }
68
}
69