Completed
Push — experimental/sf ( b1938d...177a7b )
by chihiro
201:52 queued 194:30
created

EA04OrderCest::order_配送CSVダウンロード()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
use Codeception\Util\Fixtures;
4
use Eccube\Entity\Master\OrderStatus;
5
use Page\Admin\CsvSettingsPage;
6
use Page\Admin\OrderEditPage;
7
use Page\Admin\OrderManagePage;
8
9
/**
10
 * @group admin
11
 * @group admin01
12
 * @group order
13
 * @group ea4
14
 */
15
class EA04OrderCest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
16
{
17
    public function _before(\AcceptanceTester $I)
18
    {
19
        // すべてのテストケース実施前にログインしておく
20
        // ログイン後は管理アプリのトップページに遷移している
21
        $I->loginAsAdmin();
22
    }
23
24
    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...
25
    {
26
    }
27
28
    public function order_受注検索(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_受注検索" is not in camel caps format
Loading history...
29
    {
30
        $I->wantTo('EA0401-UC01-T01(& UC01-T02, UC01-T03) 受注検索');
31
32
        $findOrders = Fixtures::get('findOrders'); // Closure
33
        $TargetOrders = array_filter($findOrders(), function ($Order) {
34
            return $Order->getOrderStatus()->getId() != OrderStatus::PROCESSING;
35
        });
36
        OrderManagePage::go($I)->検索();
37
        $I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
38
39
        OrderManagePage::go($I)->検索('[email protected]');
40
        $I->see('検索結果:0件が該当しました', OrderManagePage::$検索結果_メッセージ);
41
42
        OrderManagePage::go($I)->詳細検索_電話番号('あああ');
43
        $I->see('検索条件に誤りがあります。', OrderManagePage::$検索結果_エラーメッセージ);
44
    }
45
46 View Code Duplication
    public function order_受注CSVダウンロード(\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...
Coding Style introduced by
Method name "EA04OrderCest::order_受注CSVダウンロード" is not in camel caps format
Loading history...
47
    {
48
        $I->wantTo('EA0401-UC02-T01 受注CSVダウンロード');
49
50
        $findOrders = Fixtures::get('findOrders'); // Closure
51
        $TargetOrders = array_filter($findOrders(), function ($Order) {
52
            return $Order->getOrderStatus()->getId() != OrderStatus::PROCESSING;
53
        });
54
        $OrderListPage = OrderManagePage::go($I)->検索();
55
        $I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
56
57
        $OrderListPage->受注CSVダウンロード実行();
58
        // make sure wait to download file completely
59
        $I->wait(10);
60
        $OrderCSV = $I->getLastDownloadFile('/^order_\d{14}\.csv$/');
61
        $I->assertGreaterOrEquals(count($TargetOrders), count(file($OrderCSV)), '検索結果以上の行数があるはず');
62
    }
63
64 View Code Duplication
    public function order_受注情報のCSV出力項目変更設定(\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...
Coding Style introduced by
Method name "EA04OrderCest::order_受注情報のCSV出力項目変更設定" is not in camel caps format
Loading history...
65
    {
66
        $I->wantTo('EA0401-UC02-T02 受注情報のCSV出力項目変更設定');
67
68
        $findOrders = Fixtures::get('findOrders'); // Closure
69
        $TargetOrders = array_filter($findOrders(), function ($Order) {
70
            return $Order->getOrderStatus()->getId() != OrderStatus::PROCESSING;
71
        });
72
        $OrderListPage = OrderManagePage::go($I)->検索();
73
        $I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
74
75
        /* 項目設定 */
76
        $OrderListPage->受注CSV出力項目設定();
77
78
        CsvSettingsPage::at($I);
79
        $value = $I->grabValueFrom(CsvSettingsPage::$CSVタイプ);
80
        $I->assertEquals(3, $value);
81
    }
82
83 View Code Duplication
    public function order_配送CSVダウンロード(\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...
Coding Style introduced by
Method name "EA04OrderCest::order_配送CSVダウンロード" is not in camel caps format
Loading history...
84
    {
85
        $I->wantTo('EA0401-UC02-T01 配送CSVダウンロード');
86
87
        $findOrders = Fixtures::get('findOrders'); // Closure
88
        $TargetOrders = array_filter($findOrders(), function ($Order) {
89
            return $Order->getOrderStatus()->getId() != OrderStatus::PROCESSING;
90
        });
91
        $OrderListPage = OrderManagePage::go($I)->検索();
92
        $I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
93
94
        $OrderListPage->配送CSVダウンロード実行();
95
        // make sure wait to download file completely
96
        $I->wait(10);
97
        $OrderCSV = $I->getLastDownloadFile('/^shipping_\d{14}\.csv$/');
98
        $I->assertGreaterOrEquals(count($TargetOrders), count(file($OrderCSV)), '検索結果以上の行数があるはず');
99
    }
100
101 View Code Duplication
    public function order_配送情報のCSV出力項目変更設定(\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...
Coding Style introduced by
Method name "EA04OrderCest::order_配送情報のCSV出力項目変更設定" is not in camel caps format
Loading history...
102
    {
103
        $I->wantTo('EA0401-UC02-T02 配送情報のCSV出力項目変更設定');
104
105
        $findOrders = Fixtures::get('findOrders'); // Closure
106
        $TargetOrders = array_filter($findOrders(), function ($Order) {
107
            return $Order->getOrderStatus()->getId() != OrderStatus::PROCESSING;
108
        });
109
        $OrderListPage = OrderManagePage::go($I)->検索();
110
        $I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
111
112
        /* 項目設定 */
113
        $OrderListPage->配送CSV出力項目設定();
114
115
        CsvSettingsPage::at($I);
116
        $value = $I->grabValueFrom(CsvSettingsPage::$CSVタイプ);
117
        $I->assertEquals(4, $value);
118
    }
119
120
    public function order_受注編集(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_受注編集" is not in camel caps format
Loading history...
121
    {
122
        $I->wantTo('EA0401-UC05-T01(& UC05-T02/UC05-T03/UC06-T01) 受注編集');
123
124
        // 新規受付ステータスの受注を作る
125
        $createCustomer = Fixtures::get('createCustomer');
126
        $createOrders = Fixtures::get('createOrders');
127
        $newOrders = $createOrders($createCustomer(), 1, array());
128
129
        $OrderListPage = OrderManagePage::go($I)->検索($newOrders[0]->getOrderNo());
130
131
        $I->see('検索結果:1件が該当しました', OrderManagePage::$検索結果_メッセージ);
132
133
        /* 編集 */
134
        $OrderListPage->一覧_編集(1);
135
136
        $OrderRegisterPage = OrderEditPage::at($I)
137
            ->注文者パネルを開く()
138
            ->入力_姓('')
139
            ->受注情報登録();
140
141
        $OrderRegisterPage->注文者パネルを開く();
142
        /* 異常系 */
143
        $I->see('入力されていません。', OrderEditPage::$姓_エラーメッセージ);
144
145
        /* 正常系 */
146
        $OrderRegisterPage
147
            ->入力_姓('aaa')
148
            ->入力_セイ('アアア')
149
            ->入力_メイ('アアア')
150
            ->入力_郵便番号('060-0000')
151
            ->入力_都道府県(['1' => '北海道'])
152
            ->入力_市区町村名('bbb')
153
            ->入力_番地_ビル名('bbb')
154
            ->入力_電話番号('111-111-111')
155
            ->入力_番地_ビル名('address 2')
156
            ->入力_支払方法(['4' => '郵便振替'])
157
            ->受注情報登録();
158
159
        $I->see('受注情報を保存しました。', OrderEditPage::$登録完了メッセージ);
160
161
        /* ステータス変更 */
162
        $OrderRegisterPage
163
            ->入力_受注ステータス(['2' => '入金待ち'])
164
            ->受注情報登録();
165
166
        $I->see('受注情報を保存しました。', OrderEditPage::$登録完了メッセージ);
167
168
        /* 明細の削除 */
169
        $itemName = $OrderRegisterPage->明細の項目名を取得(1);
170
        $OrderRegisterPage->明細を削除(1)
171
            ->acceptDeleteModal(1);
172
        $I->wait(2);
173
174
        // before submit
175
        $I->dontSee($itemName, "#table-form-field");
176
177
        // after submit
178
        $OrderRegisterPage->受注情報登録();
179
        $I->dontSee($itemName, "#table-form-field");
180
181
        $I->see('受注情報を保存しました。', OrderEditPage::$登録完了メッセージ);
182
    }
183
184
    public function order_受注削除(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_受注削除" is not in camel caps format
Loading history...
185
    {
186
        $I->wantTo('EA0401-UC08-T01(& UC08-T02) 受注削除');
187
188
        $findOrders = Fixtures::get('findOrders'); // Closure
189
        $TargetOrders = array_filter($findOrders(), function ($Order) {
190
            return $Order->getOrderStatus()->getId() != OrderStatus::PROCESSING;
191
        });
192
193
        $OrderListPage = OrderManagePage::go($I)->検索();
194
        $I->see('検索結果:'.count($TargetOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
195
196
        // 削除
197
        $OrderNumForDel = $OrderListPage->一覧_注文番号(1);
198
        $OrderListPage
199
          ->一覧_選択(1)
200
          ->一覧_削除()
201
          ->Accept_削除();
202
203
        $I->see('受注情報を削除しました', ['css' => '#page_admin_order > div > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span']);
204
        $I->assertNotEquals($OrderNumForDel, $OrderListPage->一覧_注文番号(1));
205
206
        // 削除キャンセル
207
        $OrderNumForDontDel = $OrderListPage->一覧_注文番号(1);
208
        $OrderListPage
209
          ->一覧_選択(1)
210
          ->一覧_削除()
211
          ->Cancel_削除();
212
213
        $I->assertEquals($OrderNumForDontDel, $OrderListPage->一覧_注文番号(1));
214
    }
215
216
    public function order_受注メール通知(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_受注メール通知" is not in camel caps format
Loading history...
217
    {
218
        $I->wantTo('EA0402-UC01-T01 受注メール通知');
219
220
        $I->resetEmails();
221
222
        OrderManagePage::go($I)
223
            ->一覧_メール通知(1);
224
225
        $I->seeEmailCount(2);
226
227
        $I->seeInLastEmailSubjectTo('[email protected]', '[EC-CUBE SHOP] 商品出荷のお知らせ');
228
    }
229
230
    public function order_一括メール通知(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_一括メール通知" is not in camel caps format
Loading history...
231
    {
232
        $I->wantTo('EA0402-UC02-T01(& UC02-T02) 一括メール通知');
233
234
        $I->resetEmails();
235
236
        OrderManagePage::go($I)
237
            ->一覧_全選択()
238
            ->一括メール送信();
239
240
        $I->seeEmailCount(20);
241
    }
242
243
    public function order_受注登録(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_受注登録" is not in camel caps format
Loading history...
244
    {
245
        $I->wantTo('EA0405-UC01-T01(& UC01-T02) 受注登録');
246
247
        $OrderRegisterPage = OrderEditPage::go($I)->受注情報登録();
248
249
        /* 異常系 */
250
        $I->dontSee('受注情報を保存しました。', OrderEditPage::$登録完了メッセージ);
251
252
        /* 正常系 */
253
        $OrderRegisterPage
254
            ->入力_受注ステータス(['1' => '新規受付'])
255
            ->入力_支払方法(['4' => '郵便振替'])
256
            ->入力_姓('order1')
257
            ->入力_名('order1')
258
            ->入力_セイ('アアア')
259
            ->入力_メイ('アアア')
260
            ->入力_郵便番号('060-0000')
261
            ->入力_都道府県(['1' => '北海道'])
262
            ->入力_市区町村名('bbb')
263
            ->入力_番地_ビル名('bbb')
264
            ->入力_Eメール('[email protected]')
265
            ->入力_電話番号('111-111-111')
266
            ->注文者情報をコピー()
267
            ->入力_配送業者([1 => 'サンプル業者'])
268
            ->商品検索('パーコレーター')
269
            ->商品検索結果_選択(1)
270
            ->受注情報登録();
271
272
        $I->see('受注情報を保存しました。', OrderEditPage::$登録完了メッセージ);
273
    }
274
275
    public function order_ー括受注のステータス変更(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA04OrderCest::order_ー括受注のステータス変更" is not in camel caps format
Loading history...
276
    {
277
        $I->getScenario()->incomplete('ステータス変更処理の再実装待ち');
278
279
        $I->wantTo('EA0405-UC06-T01_ー括受注のステータス変更');
280
281
        // 新規受付ステータスをキャンセルに変更する
282
        $entityManager = Fixtures::get('entityManager');
283
        $findOrders = Fixtures::get('findOrders');
284
        $NewOrders = array_filter($findOrders(), function ($Order) {
285
            return $Order->getOrderStatus()->getId() == OrderStatus::NEW;
286
        });
287
        $CancelStatus = $entityManager->getRepository('Eccube\Entity\Master\OrderStatus')->find(OrderStatus::CANCEL);
288
        foreach ($NewOrders as $newOrder) {
289
            $newOrder->setOrderStatus($CancelStatus);
290
        }
291
        $entityManager->flush();
292
293
        // 新規受付ステータスの受注を作る
294
        $createCustomer = Fixtures::get('createCustomer');
295
        $createOrders = Fixtures::get('createOrders');
296
        $newOrders = $createOrders($createCustomer(), 2, array());
297
        $Status = $entityManager->getRepository('Eccube\Entity\Master\OrderStatus')->find(OrderStatus::NEW);
298
        foreach ($newOrders as $newOrder) {
299
            $newOrder->setOrderStatus($Status);
300
        }
301
        $entityManager->flush();
302
303
        $NewOrders = array_filter($findOrders(), function ($Order) {
304
            return $Order->getOrderStatus()->getId() == OrderStatus::NEW;
305
        });
306
        OrderManagePage::go($I)->受注ステータス検索(OrderStatus::NEW);
307
        $I->see('検索結果:'.count($NewOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
308
309
        $DeliveredOrders = array_filter($findOrders(), function ($Order) {
310
            return $Order->getOrderStatus()->getId() == OrderStatus::DELIVERED;
311
        });
312
        OrderManagePage::go($I)->受注ステータス検索(OrderStatus::DELIVERED);
313
        $I->see('検索結果:'.count($DeliveredOrders).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
314
315
        OrderManagePage::go($I)->受注ステータス検索(OrderStatus::NEW)
316
            ->一覧_全選択()
317
            ->受注ステータス変更('発送済み');
0 ignored issues
show
Documentation introduced by
'発送済み' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
318
319
        OrderManagePage::go($I)->受注ステータス検索(OrderStatus::DELIVERED);
320
        $I->see('検索結果:'.(count($DeliveredOrders) + count($NewOrders)).'件が該当しました', OrderManagePage::$検索結果_メッセージ);
321
    }
322
}
323