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

_support/Page/Admin/PluginManagePage.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
namespace Page\Admin;
15
16
class PluginManagePage extends AbstractAdminPageStyleGuide
17
{
18
    const 完了メーッセージ = '#page_admin_store_plugin > div.c-container > div.c-contentsArea > div.alert.alert-dismissible.fade.show.m-3 > span';
19
20
    public function __construct(\AcceptanceTester $I)
21
    {
22
        parent::__construct($I);
23
    }
24
25
    public static function at($I)
26
    {
27
        $page = new self($I);
28
29
        return $page->atPage('インストールプラグイン一覧オーナーズストア');
30
    }
31
32
    /**
33
     * @param $pluginCode
34
     * @param string $message
35
     *
36
     * @return PluginManagePage
37
     */
38
    public function ストアプラグイン_有効化($pluginCode, $message = '有効にしました。')
39
    {
40
        $this->ストアプラグイン_ボタンクリック($pluginCode, '有効化');
41
        $this->tester->see($message, self::完了メーッセージ);
42
43
        return $this;
44
    }
45
46
    /**
47
     * @param $pluginCode
48
     * @param string $message
49
     *
50
     * @return PluginManagePage
51
     */
52
    public function ストアプラグイン_無効化($pluginCode, $message = '無効にしました。')
53
    {
54
        $this->ストアプラグイン_ボタンクリック($pluginCode, '無効化');
55
        $this->tester->see($message, self::完了メーッセージ);
56
57
        return $this;
58
    }
59
60
    /**
61
     * @param $pluginCode
62
     * @param string $message
63
     *
64
     * @return PluginManagePage
65
     *
66
     * @throws \Exception
67
     */
68
    public function ストアプラグイン_削除($pluginCode, $message = '削除が完了しました。')
69
    {
70
        $this->ストアプラグイン_ボタンクリック($pluginCode, '削除');
71
        $this->tester->waitForElementVisible(['id' => 'officialPluginDeleteButton']);
72
        $this->tester->click(['id' => 'officialPluginDeleteButton']);
73
        $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 30);
74
        $this->tester->see($message, ['css' => '#officialPluginDeleteModal > div > div > div.modal-body.text-left > p']);
75
        $this->tester->click(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)']);
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param $pluginCode
82
     *
83
     * @return PluginStoreUpgradePage
84
     */
85
    public function ストアプラグイン_アップデート($pluginCode)
86
    {
87
        echo $this->tester->grabTextFrom(['xpath' => '//*[@id="page_admin_store_plugin"]']);
88
        $this->tester->click(['xpath' => $this->ストアプラグイン_セレクタ($pluginCode).'/../../td[5]/a']);
89
90
        return PluginStoreUpgradePage::at($this->tester);
91
    }
92
93 View Code Duplication
    private function ストアプラグイン_ボタンクリック($pluginCode, $label)
0 ignored issues
show
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...
94
    {
95
        $xpath = ['xpath' => $this->ストアプラグイン_セレクタ($pluginCode).'/../../td[6]//i[@data-original-title="'.$label.'"]/parent::node()'];
96
        $this->tester->click($xpath);
97
98
        return $this;
99
    }
100
101
    public function ストアプラグイン_セレクタ($pluginCode)
102
    {
103
        return '//*[@id="page_admin_store_plugin"]//div/h5[contains(text(), "オーナーズストアのプラグイン")]/../..//table/tbody//td[3]/p[contains(text(), "'.$pluginCode.'")]';
104
    }
105
106
    public function 独自プラグイン_有効化($pluginCode)
107
    {
108
        $this->独自プラグイン_ボタンクリック($pluginCode, '有効化');
109
        $this->tester->see('有効にしました。', self::完了メーッセージ);
110
111
        return $this;
112
    }
113
114
    public function 独自プラグイン_無効化($pluginCode)
115
    {
116
        $this->独自プラグイン_ボタンクリック($pluginCode, '無効化');
117
        $this->tester->see('無効にしました。', self::完了メーッセージ);
118
119
        return $this;
120
    }
121
122
    public function 独自プラグイン_削除($pluginCode)
123
    {
124
        $this->独自プラグイン_ボタンクリック($pluginCode, '削除');
125
        $this->tester->waitForElementVisible(['css' => '#localPluginDeleteModal .modal-footer a']);
126
        $this->tester->click(['css' => '#localPluginDeleteModal .modal-footer a']);
127
128
        return $this;
129
    }
130
131
    public function 独自プラグイン_アップデート($pluginCode, $fileName)
132
    {
133
        $this->tester->attachFile(['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[5]//input[@type="file"]'], $fileName);
134
        $this->tester->click(['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[5]//button']);
135
        $this->tester->see('アップデートしました。', self::完了メーッセージ);
136
137
        return $this;
138
    }
139
140 View Code Duplication
    private function 独自プラグイン_ボタンクリック($pluginCode, $label)
0 ignored issues
show
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...
141
    {
142
        $xpath = ['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[6]//i[@data-original-title="'.$label.'"]/parent::node()'];
143
        $this->tester->click($xpath);
144
145
        return $this;
146
    }
147
148
    private function 独自プラグイン_セレクタ($pluginCode)
149
    {
150
        return '//*[@id="page_admin_store_plugin"]//div/h5[contains(text(), "ユーザー独自プラグイン")]/../..//table/tbody//td[3][contains(text(), "'.$pluginCode.'")]/';
151
    }
152
}
153