Failed Conditions
Pull Request — 4.0 (#4085)
by chihiro
06:18
created

ZZ99InstallerCest::installer_CheckPermission()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 31
rs 9.424
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.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\Install\InstallPage;
15
16
/**
17
 * @group installer
18
 */
19
class ZZ99InstallerCest
20
{
21
    protected $writableFiles = [
22
        'app/Plugin',
23
        'app/PluginData',
24
        'app/proxy',
25
        'app/template',
26
        'html',
27
        'var',
28
        'vendor',
29
        'composer.json',
30
        'composer.lock',
31
    ];
32
33
    /**
34
     * 権限チェックのテスト.
35
     *
36
     * @param AcceptanceTester $I
37
     */
38
    public function installer_CheckPermission(\AcceptanceTester $I)
39
    {
40
        $I->wantTo('ZZ99 インストーラ 権限チェックのテスト');
41
42
        // step1
43
        $page = InstallPage::go($I);
44
        $I->see('ようこそ', InstallPage::$STEP1_タイトル);
45
46
        // 次へ
47
        $page->step1_次へボタンをクリック();
48
49
        // step2
50
        $I->see('権限チェック', InstallPage::$STEP2_タイトル);
51
        $I->see('アクセス権限は正常です', InstallPage::$STEP2_テキストエリア);
52
53
        foreach ($this->writableFiles as $file) {
54
            $path = __DIR__.'/../../'.$file;
55
            $origin = octdec(substr(sprintf('%o', fileperms($path)), -4));
56
57
            // 書き込み権限を外す
58
            chmod($path, 0555);
59
60
            // リロードしてエラーが表示されることを確認.
61
            $page->step2_リロード();
62
            $I->see('以下のファイルまたはディレクトリに書き込み権限を付与してください', InstallPage::$STEP2_テキストエリア);
63
            $I->see($file, InstallPage::$STEP2_テキストエリア);
64
65
            // 権限を戻す.
66
            chmod($path, $origin);
67
        }
68
    }
69
}
70