Completed
Push — 4.0 ( d47428...a1c143 )
by Kiyotaka
06:47 queued 10s
created

ZZ99InstallerCest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A installer_CheckPermission() 0 49 2
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
        $rootDir = __DIR__.'/../../';
54
55
        foreach ($this->writableFiles as $file) {
56
            $path = $rootDir.$file;
57
            $origin = octdec(substr(sprintf('%o', fileperms($path)), -4));
58
59
            // 書き込み権限を外す
60
            chmod($path, 0555);
61
62
            // リロードしてエラーが表示されることを確認.
63
            $page->step2_リロード();
64
            $I->see('以下のファイルまたはディレクトリに書き込み権限を付与してください', InstallPage::$STEP2_テキストエリア);
65
            $I->see($file, InstallPage::$STEP2_テキストエリア);
66
67
            // 権限を戻す.
68
            chmod($path, $origin);
69
        }
70
71
        // 対象外のディレクトリ・ファイルの確認
72
        $externalDir = $rootDir.'externalDir';
73
        mkdir($externalDir, 0555, true);
74
75
        $externalFile = $rootDir.'externalFile.txt';
76
        touch($externalFile);
77
        chmod($externalFile, 0555);
78
79
        $page->step2_リロード();
80
        $I->see('アクセス権限は正常です', InstallPage::$STEP2_テキストエリア);
81
82
        chmod($externalDir, 0777);
83
        chmod($externalFile, 0777);
84
        rmdir($externalDir);
85
        unlink($externalFile);
86
    }
87
}
88