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

EF05MypageCest   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 288
Duplicated Lines 14.24 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
dl 41
loc 288
rs 10
c 0
b 0
f 0
wmc 13
lcom 1
cbo 7

12 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 3 1
A _after() 0 3 1
A mypage_初期表示() 10 10 1
A mypage_ご注文履歴_() 0 18 1
A mypage_ご注文履歴詳細() 0 26 1
A mypage_お気に入り一覧() 0 24 1
A mypage_会員情報編集() 0 50 2
A mypage_お届け先編集表示() 12 12 1
B mypage_お届け先編集作成変更() 0 56 1
A mypage_お届け先編集削除() 0 30 1
A mypage_退会手続き() 0 23 1
A mypage_退会手続き未実施() 19 19 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
use Codeception\Util\Fixtures;
15
use Page\Front\CustomerAddressEditPage;
16
use Page\Front\CustomerAddressListPage;
17
use Page\Front\HistoryPage;
18
use Page\Front\MyPage;
19
use Page\Front\ProductDetailPage;
20
21
/**
22
 * @group front
23
 * @group mypage
24
 * @group ef5
25
 */
26
class EF05MypageCest
27
{
28
    public function _before(\AcceptanceTester $I)
0 ignored issues
show
Unused Code introduced by
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
    }
31
32
    public function _after(\AcceptanceTester $I)
0 ignored issues
show
Unused Code introduced by
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
    }
35
36 View Code Duplication
    public function mypage_初期表示(\AcceptanceTester $I)
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...
37
    {
38
        $I->wantTo('EF0501-UC01-T01 Mypage 初期表示');
39
        $createCustomer = Fixtures::get('createCustomer');
40
        $customer = $createCustomer();
41
        $I->loginAsMember($customer->getEmail(), 'password');
42
43
        MyPage::go($I);
44
        MyPage::at($I);
45
    }
46
47
    public function mypage_ご注文履歴_(\AcceptanceTester $I)
48
    {
49
        $I->wantTo('EF0502-UC01-T01 Mypage ご注文履歴');
50
        $createCustomer = Fixtures::get('createCustomer');
51
        $customer = $createCustomer();
52
        $createOrders = Fixtures::get('createOrders');
53
        $Orders = $createOrders($customer, 5, [], \Eccube\Entity\Master\OrderStatus::NEW);
0 ignored issues
show
Unused Code introduced by
$Orders is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
54
55
        $I->loginAsMember($customer->getEmail(), 'password');
56
57
        // TOPページ>マイページ>ご注文履歴
58
        MyPage::go($I)->注文履歴();
59
60
        // 注文内容の状況/簡易情報が表示される、各注文履歴に「詳細を見る」ボタンが表示される
61
        $I->see('ご注文履歴', 'div.ec-pageHeader h1');
62
        $I->see('ご注文番号', 'div.ec-historyRole dl.ec-definitions');
63
        $I->see('詳細を見る', 'div.ec-historyRole p.ec-historyListHeader__action a');
64
    }
65
66
    public function mypage_ご注文履歴詳細(\AcceptanceTester $I)
67
    {
68
        $I->wantTo('EF0503-UC01-T01 Mypage ご注文履歴詳細');
69
        $createCustomer = Fixtures::get('createCustomer');
70
        $customer = $createCustomer();
71
        $createOrders = Fixtures::get('createOrders');
72
        $createOrders($customer, 5, [], \Eccube\Entity\Master\OrderStatus::NEW);
73
74
        $I->loginAsMember($customer->getEmail(), 'password');
75
76
        MyPage::go($I)->注文履歴詳細(1);
77
78
        HistoryPage::at($I);
79
80
        $I->see('ご注文状況', 'div.ec-orderOrder div.ec-definitions:nth-child(3) dt');
81
        // $I->see('注文受付', '#main_middle .order_detail'); TODO 受注ステータスが可変するためテストが通らない場合がある
82
        $I->see('配送情報', 'div.ec-orderRole div.ec-orderDelivery div.ec-rectHeading h2');
83
        $I->see('お届け先', 'div.ec-orderRole div.ec-orderDelivery div.ec-orderDelivery__title');
84
        $I->see('お支払い情報', 'div.ec-orderRole div.ec-orderPayment div.ec-rectHeading h2');
85
        $I->see('お問い合わせ', 'div.ec-orderRole div.ec-orderConfirm div.ec-rectHeading h2');
86
        $I->see('メール配信履歴一覧', 'div.ec-orderRole div.ec-orderMails div.ec-rectHeading h2');
87
        $I->see('小計', 'div.ec-orderRole__summary div.ec-totalBox dl:nth-child(1)');
88
        $I->see('手数料', 'div.ec-orderRole__summary div.ec-totalBox dl:nth-child(2)');
89
        $I->see('送料', 'div.ec-orderRole__summary div.ec-totalBox dl:nth-child(3)');
90
        $I->see('合計', 'div.ec-orderRole__summary div.ec-totalBox .ec-totalBox__total');
91
    }
92
93
    public function mypage_お気に入り一覧(\AcceptanceTester $I)
94
    {
95
        $I->wantTo('EF0508-UC01-T01 Mypage お気に入り一覧');
96
        $createCustomer = Fixtures::get('createCustomer');
97
        $customer = $createCustomer();
98
        $I->loginAsMember($customer->getEmail(), 'password');
99
100
        // TOPページ>マイページ>ご注文履歴
101
        MyPage::go($I)->お気に入り一覧();
102
103
        // 最初はなにも登録されていない
104
        $I->see('お気に入り一覧', 'div.ec-pageHeader h1');
105
        $I->see('お気に入りは登録されていません。', 'div.ec-favoriteRole');
106
107
        // お気に入り登録
108
        ProductDetailPage::go($I, 2)->お気に入りに追加();
109
110
        MyPage::go($I)->お気に入り一覧();
111
        $I->see('チェリーアイスサンド', 'ul.ec-favoriteRole__itemList li:nth-child(1) p.ec-favoriteRole__itemTitle');
112
113
        // お気に入りを削除
114
        $I->click('ul.ec-favoriteRole__itemList li:nth-child(1) a.ec-closeBtn--circle');
115
        $I->acceptPopup();
116
    }
117
118
    public function mypage_会員情報編集(\AcceptanceTester $I)
119
    {
120
        $I->wantTo('EF0504-UC01-T01 Mypage 会員情報編集');
121
        $createCustomer = Fixtures::get('createCustomer');
122
        $customer = $createCustomer();
123
        $I->loginAsMember($customer->getEmail(), 'password');
124
        $faker = Fixtures::get('faker');
125
        $new_email = microtime(true).'.'.$faker->safeEmail;
126
127
        // TOPページ>マイページ>会員情報編集
128
        MyPage::go($I)->会員情報編集();
129
130
        // 会員情報フォームに既存の登録情報が表示される
131
        $I->seeInField(['id' => 'entry_name_name01'], $customer->getName01());
132
133
        $form = [
134
            'entry[name][name01]' => '姓05',
135
            'entry[name][name02]' => '名05',
136
            'entry[kana][kana01]' => 'セイ',
137
            'entry[kana][kana02]' => 'メイ',
138
            'entry[postal_code]' => '530-0001',
139
            'entry[address][pref]' => ['value' => '27'],
140
            'entry[address][addr01]' => '大阪市北区',
141
            'entry[address][addr02]' => '梅田2-4-9 ブリーゼタワー13F',
142
            'entry[phone_number]' => '111-111-111',
143
            'entry[email][first]' => $new_email,
144
            'entry[email][second]' => $new_email,
145
            'entry[password][first]' => 'password',
146
            'entry[password][second]' => 'password',
147
        ];
148
149
        $findPluginByCode = Fixtures::get('findPluginByCode');
150
        $Plugin = $findPluginByCode('MailMagazine');
151
        if ($Plugin) {
152
            $I->amGoingTo('メルマガプラグインを発見したため、メルマガを購読します');
153
            // 必須入力が効いてない https://github.com/EC-CUBE/mail-magazine-plugin/issues/29
154
            $form['entry[mailmaga_flg]'] = '1';
155
        }
156
        // 会員情報フォームに会員情報を入力する
157
        $I->submitForm('div.ec-editRole form', $form);
158
159
        // 会員情報編集(完了)画面が表示される
160
        $I->see('会員情報編集(完了)', 'div.ec-pageHeader h1');
161
162
        // 「トップページへ」ボタンを押下する
163
        $I->click('div.ec-registerCompleteRole a.ec-blockBtn--cancel');
164
165
        // TOPページヘ遷移する
166
        $I->see('新着情報', '.ec-secHeading__ja');
167
    }
168
169 View Code Duplication
    public function mypage_お届け先編集表示(\AcceptanceTester $I)
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...
170
    {
171
        $I->wantTo('EF0506-UC01-T01 Mypage お届け先編集表示');
172
        $createCustomer = Fixtures::get('createCustomer');
173
        $customer = $createCustomer();
174
        $I->loginAsMember($customer->getEmail(), 'password');
175
176
        // TOPページ>マイページ>お届け先一覧
177
        MyPage::go($I)->お届け先編集();
178
179
        $I->see('お届け先一覧', 'div.ec-pageHeader h1');
180
    }
181
182
    public function mypage_お届け先編集作成変更(\AcceptanceTester $I)
183
    {
184
        $I->wantTo('EF0506-UC01-T02 Mypage お届け先編集作成変更');
185
        $createCustomer = Fixtures::get('createCustomer');
186
        $customer = $createCustomer();
187
        $I->loginAsMember($customer->getEmail(), 'password');
188
189
        // お届先作成
190
        // TOPページ>マイページ>お届け先編集
191
        MyPage::go($I)
192
            ->お届け先編集()
193
            ->追加();
194
195
        // 入力 & submit
196
        CustomerAddressEditPage::at($I)
197
            ->入力_姓('姓05')
198
            ->入力_名('名05')
199
            ->入力_セイ('セイ')
200
            ->入力_メイ('メイ')
201
            ->入力_郵便番号('530-0001')
202
            ->入力_都道府県(['value' => '27'])
203
            ->入力_市区町村名('大阪市北区')
204
            ->入力_番地_ビル名('梅田2-4-9 ブリーゼタワー13F')
205
            ->入力_電話番号('111-111-111')
206
            ->登録する();
207
208
        // お届け先編集ページ
209
        CustomerAddressListPage::at($I);
210
211
        // 一覧に追加されている
212
        $I->see('大阪市北区', 'div.ec-addressList div:nth-child(1) div.ec-addressList__address');
213
214
        // お届先編集
215
        // TOPページ>マイページ>お届け先編集
216
        MyPage::go($I)
217
            ->お届け先編集()
218
            ->変更(1);
219
220
        CustomerAddressEditPage::at($I)
221
            ->入力_姓('姓05')
222
            ->入力_名('名05')
223
            ->入力_セイ('セイ')
224
            ->入力_メイ('メイ')
225
            ->入力_郵便番号('530-0001')
226
            ->入力_都道府県(['value' => '27'])
227
            ->入力_市区町村名('大阪市南区')
228
            ->入力_番地_ビル名('梅田2-4-9 ブリーゼタワー13F')
229
            ->入力_電話番号('111-111-111')
230
            ->登録する();
231
232
        // お届け先編集ページ
233
        CustomerAddressListPage::at($I);
234
235
        // 一覧に反映されている
236
        $I->see('大阪市南区', 'div.ec-addressList div:nth-child(1) div.ec-addressList__address');
237
    }
238
239
    public function mypage_お届け先編集削除(\AcceptanceTester $I)
240
    {
241
        $I->wantTo('EF0503-UC01-T01 Mypage お届け先編集削除');
242
        $createCustomer = Fixtures::get('createCustomer');
243
        $customer = $createCustomer();
244
        $I->loginAsMember($customer->getEmail(), 'password');
245
246
        // TOPページ>マイページ>お届け先編集
247
        MyPage::go($I)->お届け先編集()->追加();
248
249
        CustomerAddressEditPage::at($I)
250
            ->入力_姓('姓0501')
251
            ->入力_名('名0501')
252
            ->入力_セイ('セイ')
253
            ->入力_メイ('メイ')
254
            ->入力_郵便番号('530-0001')
255
            ->入力_都道府県(['value' => '27'])
256
            ->入力_市区町村名('大阪市西区')
257
            ->入力_番地_ビル名('梅田2-4-9 ブリーゼタワー13F')
258
            ->入力_電話番号('111-111-111')
259
            ->登録する();
260
261
        $I->see('大阪市西区', 'div.ec-addressList div:nth-child(1) div.ec-addressList__address');
262
263
        CustomerAddressListPage::at($I)
264
            ->削除(1);
265
266
        // 確認
267
        $I->see('お届け先は登録されていません。', '#page_mypage_delivery > div.ec-layoutRole > div.ec-layoutRole__contents > div > div > div:nth-child(2) > p');
268
    }
269
270 View Code Duplication
    public function mypage_退会手続き未実施(\AcceptanceTester $I)
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...
271
    {
272
        $I->wantTo('EF0507-UC03-T01 Mypage 退会手続き 未実施');
273
        $createCustomer = Fixtures::get('createCustomer');
274
        $customer = $createCustomer();
275
        $I->loginAsMember($customer->getEmail(), 'password');
276
277
        // TOPページ>マイページ>退会手続き
278
        MyPage::go($I)
279
            ->退会手続き();
280
281
        // 会員退会手続きへ
282
        $I->click('div.ec-withdrawRole form button');
283
284
        // 未実施
285
        $I->click('div.ec-withdrawConfirmRole form a.ec-withdrawConfirmRole__cancel');
286
287
        MyPage::at($I);
288
    }
289
290
    public function mypage_退会手続き(\AcceptanceTester $I)
291
    {
292
        $I->wantTo('EF0507-UC03-T02 Mypage 退会手続き');
293
        $createCustomer = Fixtures::get('createCustomer');
294
        $customer = $createCustomer();
295
        $I->loginAsMember($customer->getEmail(), 'password');
296
297
        // TOPページ>マイページ>お届け先編集
298
        MyPage::go($I)
299
            ->退会手続き();
300
301
        // 会員退会手続きへ
302
        $I->click('div.ec-withdrawRole form button');
303
304
        // 実施
305
        $I->click('div.ec-withdrawConfirmRole form button');
306
        $I->see('退会手続き', 'div.ec-pageHeader h1');
307
        $I->see('退会が完了いたしました', 'div.ec-withdrawCompleteRole div.ec-reportHeading');
308
        $I->click('div.ec-withdrawCompleteRole a.ec-blockBtn--cancel');
309
310
        // TOPページヘ遷移する
311
        $I->see('新着情報', '.ec-secHeading__ja');
312
    }
313
}
314