Completed
Push — dev/plugin-assets ( 1918e3 )
by Kiyotaka
06:51
created

PluginManagePage::ストアプラグイン_セレクタ()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
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
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-success.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
     *
35
     * @return PluginManagePage
36
     */
37
    public function ストアプラグイン_有効化($pluginCode)
38
    {
39
        return $this->ストアプラグイン_ボタンクリック($pluginCode, '有効化');
40
    }
41
42
    /**
43
     * @param $pluginCode
44
     *
45
     * @return PluginManagePage
46
     */
47
    public function ストアプラグイン_無効化($pluginCode)
48
    {
49
        return $this->ストアプラグイン_ボタンクリック($pluginCode, '無効化');
50
    }
51
52
    /**
53
     * @param $pluginCode
54
     *
55
     * @return PluginManagePage
56
     *
57
     * @throws \Exception
58
     */
59
    public function ストアプラグイン_削除($pluginCode)
60
    {
61
        $this->ストアプラグイン_ボタンクリック($pluginCode, '削除');
62
        $this->tester->waitForElementVisible(['id' => 'officialPluginDeleteButton']);
63
        $this->tester->click(['id' => 'officialPluginDeleteButton']);
64
        $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 30);
65
        $this->tester->click(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)']);
66
67
        return $this;
68
    }
69
70
    /**
71
     * @param $pluginCode
72
     * @return PluginStoreUpgradePage
73
     */
74
    public function ストアプラグイン_アップデート($pluginCode)
75
    {
76
        $this->tester->click(['xpath' => $this->ストアプラグイン_セレクタ($pluginCode).'/../../td[5]/a']);
77
        return PluginStoreUpgradePage::at($this->tester);
78
    }
79
80 View Code Duplication
    private function ストアプラグイン_ボタンクリック($pluginCode, $label)
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...
81
    {
82
        $xpath = ['xpath' => $this->ストアプラグイン_セレクタ($pluginCode).'/../../td[6]//i[@data-original-title="'.$label.'"]/parent::node()'];
83
        $this->tester->click($xpath);
84
85
        return $this;
86
    }
87
88
    private function ストアプラグイン_セレクタ($pluginCode)
89
    {
90
        return '//*[@id="page_admin_store_plugin"]//div/h5[contains(text(), "オーナーズストアのプラグイン")]/../..//table/tbody//td[3]/p[contains(text(), "'.$pluginCode.'")]';
91
    }
92
93
    public function 独自プラグイン_有効化($pluginCode)
94
    {
95
        return $this->独自プラグイン_ボタンクリック($pluginCode, '有効化');
96
    }
97
98
    public function 独自プラグイン_無効化($pluginCode)
99
    {
100
        return $this->独自プラグイン_ボタンクリック($pluginCode, '無効化');
101
    }
102
103
    public function 独自プラグイン_削除($pluginCode)
104
    {
105
        $this->独自プラグイン_ボタンクリック($pluginCode, '削除');
106
        $this->tester->waitForElementVisible(['css' => '#localPluginDeleteModal .modal-footer a']);
107
        $this->tester->click(['css' => '#localPluginDeleteModal .modal-footer a']);
108
109
        return $this;
110
    }
111
112
    public function 独自プラグイン_アップデート($pluginCode, $fileName)
113
    {
114
        $this->tester->attachFile(['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[5]//input[@type="file"]'], $fileName);
115
        $this->tester->click(['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[5]//button']);
116
        $this->tester->see('アップデートしました。', self::完了メーッセージ);
117
        return $this;
118
    }
119
120 View Code Duplication
    private function 独自プラグイン_ボタンクリック($pluginCode, $label)
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...
121
    {
122
        $xpath = ['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[6]//i[@data-original-title="'.$label.'"]/parent::node()'];
123
        $this->tester->click($xpath);
124
125
        return $this;
126
    }
127
128
    private function 独自プラグイン_セレクタ($pluginCode)
129
    {
130
        return '//*[@id="page_admin_store_plugin"]//div/h5[contains(text(), "ユーザー独自プラグイン")]/../..//table/tbody//td[3][contains(text(), "'.$pluginCode.'")]/';
131
    }
132
}
133