Completed
Push — 4.0 ( 268f2c...88f012 )
by Hideki
05:48 queued 10s
created

AA00PluginInstallerCest::_before()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 8
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use Page\Admin\OwnersPluginPage;
15
16
/**
17
 * @group plugin
18
 * @group plugin_installer
19
 */
20
class AA00PluginInstallerCest
21
{
22
    const ページタイトル = '#main .page-header';
23
24
    protected $plugins = [];
25
26 View Code Duplication
    public function _before(\AcceptanceTester $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...
27
    {
28
        $fixtures = __DIR__.'/../_data/plugin_fixtures.php';
29
        if (file_exists($fixtures)) {
30
            $this->plugins = require $fixtures;
31
        }
32
        $I->loginAsAdmin();
33
    }
34
35
    public function _after(\AcceptanceTester $I)
0 ignored issues
show
Unused Code introduced by
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
    }
38
39
    public function plugin_プラグインインストール(\AcceptanceTester $I)
40
    {
41
        $I->wantTo('プラグインインストール');
42
43
        foreach ($this->plugins as $num => $plugin) {
44
            $OwnersPluginPage = OwnersPluginPage::go($I)
45
                ->goInstall($I);
46
            $datadir = __DIR__.'/../_data';
47
48
            if (file_exists($datadir.'/'.$plugin['file'])) {
49
                unlink($datadir.'/'.$plugin['file']);
50
            }
51
            $I->amGoingTo($plugin['file'].' を '.$plugin['url'].' からダウンロードします.');
52
            $archive = file_get_contents($plugin['url']);
53
            $save_path = $datadir.'/'.$plugin['file'];
54
            file_put_contents($save_path, $archive);
55
            $I->amGoingTo($plugin['file'].' を '.$save_path.' に保存しました.');
56
57
            $OwnersPluginPage->インストール($plugin['file']);
58
            $I->see('プラグインをインストールしました。', OwnersPluginPage::$完了メッセージ);
59
60
            // プラグイン有効化
61
            $OwnersPluginPage->有効にする($plugin['code']);
62
            $I->see('プラグインを有効にしました。', OwnersPluginPage::$完了メッセージ);
63
        }
64
    }
65
}
66