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