Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
58:58 queued 51:26
created

EA09PluginUninstallerCest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 52.63 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 20
loc 38
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

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
use Codeception\Util\Fixtures;
4
use Page\Admin\OwnersPluginPage;
5
6
/**
7
 * @group plugin
8
 * @group plugin_uninstaller
9
 */
10
class EA09PluginUninstallerCest
11
{
12
    const ページタイトル = '#main .page-header';
13
14
    protected $plugins = [];
15
16
    public function _before(\AcceptanceTester $I)
17
    {
18
        $fixtures = __DIR__.'/../_data/plugin_fixtures.php';
19
        if (file_exists($fixtures)) {
20
            $this->plugins = require $fixtures;
21
        }
22
        $I->loginAsAdmin();
23
    }
24
25
    public function _after(\AcceptanceTester $I)
26
    {
27
    }
28
29
    public function plugin_プラグインアンインストール(\AcceptanceTester $I)
30
    {
31
        $I->wantTo('プラグインアンインストール');
32
33
        foreach ($this->plugins as $num => $plugin) {
34
35
            // プラグイン無効化
36
            OwnersPluginPage::go($I)->無効にする($plugin['code']);
37
            $I->see('プラグインを無効にしました。', OwnersPluginPage::$完了メッセージ);
38
        }
39
40
        foreach ($this->plugins as $num => $plugin) {
41
42
            // プラグイン削除
43
            OwnersPluginPage::go($I)->削除($plugin['code']);
44
            $I->see(' プラグインを削除しました。', OwnersPluginPage::$完了メッセージ);
45
        }
46
    }
47
}
48