Failed Conditions
Pull Request — experimental/sf (#3264)
by Kiyotaka
93:10 queued 80:54
created

EA09ShippingCest::shipping_出荷CSV雛形ファイルダウンロード()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 8
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Codeception\Util\Fixtures;
4
use Eccube\Entity\Customer;
5
use Eccube\Entity\Order;
6
use Page\Admin\CsvSettingsPage;
7
use Page\Admin\OrderEditPage;
8
use Page\Admin\ShippingCsvUploadPage;
9
use Page\Admin\ShippingEditPage;
10
use Page\Admin\ShippingManagePage;
11
12
/**
13
 * @group admin
14
 * @group admin01
15
 * @group shipping
16
 * @group ea9
17
 */
18
class EA09ShippingCest
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...
19
{
20
    public function _before(\AcceptanceTester $I)
21
    {
22
        // すべてのテストケース実施前にログインしておく
23
        // ログイン後は管理アプリのトップページに遷移している
24
        $I->loginAsAdmin();
25
    }
26
27
    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...
28
    {
29
    }
30
31
    public function shipping出荷検索(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping出荷検索" is not in camel caps format
Loading history...
32
    {
33
        $I->wantTo('EA0901-UC01-T01(& UC01-T02, UC01-T3) 出荷検索');
34
35
        $TargetShippings = Fixtures::get('findShippings'); // Closure
36
        $Shippings = $TargetShippings();
37
        ShippingManagePage::go($I);
38
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
39
40
        ShippingManagePage::go($I)->検索('[email protected]');
41
        $I->see('検索結果 : 0 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
42
43
        ShippingManagePage::go($I)->詳細検索_電話番号('あああ');
44
        $I->see('検索条件に誤りがあります', ShippingManagePage::$検索結果_エラーメッセージ);
45
    }
46
47
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$I" missing
Loading history...
48
     * @env firefox
49
     * @env chrome
50
     */
51
    public function shipping出荷CSVダウンロード(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping出荷CSVダウンロード" is not in camel caps format
Loading history...
52
    {
53
        $I->wantTo('EA0901-UC02-T01 出荷CSVダウンロード');
54
55
        $TargetShippings = Fixtures::get('findShippings'); // Closure
56
        $Shippings = $TargetShippings();
57
        $ShippingListPage = ShippingManagePage::go($I);
58
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
59
60
        $ShippingListPage->出荷CSVダウンロード実行();
61
        // make sure wait to download file completely
62
        $I->wait(10);
63
        $ShippingCSV = $I->getLastDownloadFile('/^shipping_\d{14}\.csv$/');
64
        $I->assertGreaterOrEquals(count($Shippings), count(file($ShippingCSV)), '検索結果以上の行数があるはず');
65
    }
66
67
    public function shipping出荷情報のCSV出力項目変更設定(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping出荷情報のCSV出力項目変更設定" is not in camel caps format
Loading history...
68
    {
69
        $I->wantTo('EA0901-UC02-T02 出荷情報のCSV出力項目変更設定');
70
71
        $TargetShippings = Fixtures::get('findShippings'); // Closure
72
        $Shippings = $TargetShippings();
73
        $ShippingListPage = ShippingManagePage::go($I);
74
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
75
76
        /* 項目設定 */
77
        $ShippingListPage->出荷CSV出力項目設定();
78
79
        CsvSettingsPage::at($I);
80
        $value = $I->grabValueFrom(CsvSettingsPage::$CSVタイプ);
81
        $I->assertEquals(4, $value);
82
    }
83
84
    public function shipping出荷編集(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping出荷編集" is not in camel caps format
Loading history...
85
    {
86
        $I->wantTo('EA0901-UC03-T01(& UC03-T02) 出荷編集');
87
88
        $I->resetEmails();
89
90
        $TargetShippings = Fixtures::get('findShippings'); // Closure
91
        $Shippings = $TargetShippings();
92
        $ShippingListPage = ShippingManagePage::go($I);
93
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
94
95
        /* 編集 */
96
        $ShippingListPage->一覧_編集(1);
97
98
        $ShippingRegisterPage = ShippingEditPage::at($I)
99
            ->お届け先編集()
100
            ->入力_姓('')
101
            ->出荷情報登録();
102
103
        /* 異常系 */
104
        // FIXME お届け先編集が閉じてしまうため、エラーメッセージが表示されない
105
        // $I->see('入力されていません。', ShippingEditPage::$姓_エラーメッセージ);
106
107
        /* 正常系 */
108
        $ShippingRegisterPage
109
            ->お届け先編集()
110
            ->入力_姓('aaa')
111
            ->入力_セイ('アアア')
112
            ->入力_メイ('アアア')
113
            ->入力_郵便番号('060-0000')
114
            ->入力_都道府県(['1' => '北海道'])
115
            ->入力_市区町村名('bbb')
116
            ->入力_番地_ビル名('bbb')
117
            ->入力_電話番号('111-111-111')
118
            ->入力_番地_ビル名('address 2')
119
            ->出荷情報登録();
120
121
        $I->see('出荷情報を登録しました。', ShippingEditPage::$登録完了メッセージ);
122
123
        /* ステータス変更 */
124
        $ShippingRegisterPage
125
            ->入力_出荷ステータス(['2' => '出荷済み'])
126
            ->出荷情報登録()
127
            ->変更を確定();
128
        $I->wait(1);
129
        $I->see('出荷情報を登録しました。', ShippingEditPage::$登録完了メッセージ);
130
131
        $I->wait(3);
132
        $I->seeEmailCount(2);
133
    }
134
135
    public function shipping出荷削除(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping出荷削除" is not in camel caps format
Loading history...
136
    {
137
        $I->wantTo('EA0901-UC04-T01(& UC04-T02) 出荷削除');
138
139
        $TargetShippings = Fixtures::get('findShippings'); // Closure
140
        $Shippings = $TargetShippings();
141
        $ShippingListPage = ShippingManagePage::go($I);
142
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
143
144
        // 削除
145
        $ShippingListPage->一覧_チェックボックス(1);
146
        $ShippingListPage->一覧_削除();
147
148
        $I->waitForElementVisible(['xpath' => '//*[@id="page_admin_shipping"]/div[1]/div[3]/div[2]/span']);
149
        $I->see('出荷情報を削除しました。', ['xpath' => '//*[@id="page_admin_shipping"]/div[1]/div[3]/div[2]/span']);
150
151
        // 削除キャンセル
152
        $ShippingListPage->一覧_チェックボックス(1);
153
        $ShippingListPage->一覧_削除キャンセル();
154
    }
155
156 View Code Duplication
    public function shipping一括発送済み更新(\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 "EA09ShippingCest::shipping一括発送済み更新" is not in camel caps format
Loading history...
157
    {
158
        $I->wantTo('EA0902-UC01-T01 一括発送済み更新');
159
160
        // 一括操作用の受注を生成しておく
161
        $createCustomer = Fixtures::get('createCustomer');
162
        $createOrders = Fixtures::get('createOrders');
163
        $createOrders($createCustomer(), 10, array());
164
165
        $I->resetEmails();
166
167
        $config = Fixtures::get('config');
0 ignored issues
show
Unused Code introduced by
$config 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...
168
        // ステータスを出荷準備中にリセット
169
        $resetShippingStatusPrepared = Fixtures::get('resetShippingStatusPrepared'); // Closure
170
        $resetShippingStatusPrepared();
171
172
        $TargetShippings = Fixtures::get('findShippings'); // Closure
173
        $Shippings = $TargetShippings();
174
        $ShippingListPage = ShippingManagePage::go($I);
175
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
176
177
        $ShippingListPage
178
            ->一覧_全選択()
179
            ->一括発送済み更新();
180
181
        $I->wait(5);
182
        $I->waitForElementVisible(['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
183
        $I->see('処理完了。10件のメールを送信しました', ['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
184
        $I->seeEmailCount(20);
185
186
        $I->click(['id' => 'bulkChangeComplete']);
187
    }
188
189 View Code Duplication
    public function shipping一括発送済みメール送信(\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 "EA09ShippingCest::shipping一括発送済みメール送信" is not in camel caps format
Loading history...
190
    {
191
        $I->wantTo('EA0902-UC02-T01 一括発送済みメール送信');
192
193
        // 一括操作用の受注を生成しておく
194
        $createCustomer = Fixtures::get('createCustomer');
195
        $createOrders = Fixtures::get('createOrders');
196
        $createOrders($createCustomer(), 10, array());
197
198
        $I->resetEmails();
199
200
        $config = Fixtures::get('config');
0 ignored issues
show
Unused Code introduced by
$config 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...
201
        // ステータスを出荷済みにリセット
202
        $resetShippingStatusShipped = Fixtures::get('resetShippingStatusShipped'); // Closure
203
        $resetShippingStatusShipped();
204
205
        $TargetShippings = Fixtures::get('findShippings'); // Closure
206
        $Shippings = $TargetShippings();
207
        $ShippingListPage = ShippingManagePage::go($I);
208
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
209
210
        $ShippingListPage
211
            ->一覧_全選択()
212
            ->一括発送済みメール送信();
213
214
        $I->wait(5);
215
        $I->waitForElementVisible(['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
216
        $I->see('処理完了。10件のメールを送信しました', ['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
217
        $I->seeEmailCount(20);
218
219
        $I->click(['id' => 'bulkChangeComplete']);
220
    }
221
222
    public function shipping出荷登録(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping出荷登録" is not in camel caps format
Loading history...
223
    {
224
        $I->wantTo('EA0903-UC01-T01(& UC01-T02) 出荷登録');
225
226
        $OrderRegisterPage = OrderEditPage::go($I)->受注情報登録();
227
228
        /* 正常系 */
229
        $OrderRegisterPage
230
            ->入力_受注ステータス(['1' => '新規受付'])
231
            ->入力_姓('order1')
232
            ->入力_名('order1')
233
            ->入力_セイ('アアア')
234
            ->入力_メイ('アアア')
235
            ->入力_郵便番号('060-0000')
236
            ->入力_都道府県(['1' => '北海道'])
237
            ->入力_市区町村名('bbb')
238
            ->入力_番地_ビル名('bbb')
239
            ->入力_Eメール('[email protected]')
240
            ->入力_電話番号('111-111-111')
241
            ->商品検索('パーコレーター')
242
            ->商品検索結果_選択(1)
243
            ->入力_支払方法(['4'=> '郵便振替'])
244
            ->受注情報登録();
245
246
        $ShippingRegisterPage = ShippingEditPage::go($I)->出荷情報登録();
247
248
        /* 異常系 */
249
        $I->dontSee('出荷情報を保存しました。', ShippingEditPage::$登録完了メッセージ);
250
251
252
        /* 正常系 */
253
        $ShippingRegisterPage
254
            ->入力_姓('shipping1')
255
            ->入力_名('shipping1')
256
            ->入力_セイ('アアア')
257
            ->入力_メイ('アアア')
258
            ->入力_郵便番号('060-0000')
259
            ->入力_都道府県(['1' => '北海道'])
260
            ->入力_市区町村名('bbb')
261
            ->入力_番地_ビル名('bbb')
262
            ->入力_電話番号('111-111-111')
263
            ->入力_出荷伝票番号('1111-1111-1111')
264
            ->入力_配送業者([1 => 'サンプル業者'])
265
            ->入力_配達用メモ('メモ')
266
            ->商品検索()
267
            ->商品検索結果_選択(1)
268
            ->出荷情報登録();
269
270
        $I->see('出荷情報を登録しました。', ShippingEditPage::$登録完了メッセージ);
271
    }
272
273
    public function shipping_出荷CSV登録(\AcceptanceTester $I)
0 ignored issues
show
Coding Style introduced by
Method name "EA09ShippingCest::shipping_出荷CSV登録" is not in camel caps format
Loading history...
274
    {
275
        $I->wantTo('EA0903-UC04-T01 出荷CSV登録');
276
277
        /* @var Customer $Customer */
278
        $Customer = (Fixtures::get('createCustomer'))();
279
        /* @var Order[] $Orders */
280
        $Orders = (Fixtures::get('createOrders'))($Customer, 3);
281
282
        /*
283
         * 出荷再検索 出荷日/伝票番号が登録されていないことを確認
284
         */
285
286
        $ShippingManagePage = ShippingManagePage::go($I)
287
            ->詳細検索設定()
288
            ->入力_ご注文者お名前($Customer->getName01().$Customer->getName02())
289
            ->入力_ご注文者お名前フリガナ($Customer->getKana01().$Customer->getKana02())
290
            ->検索();
291
292
        $I->see('検索結果 : 3 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
293
294
        $I->assertEquals('未登録', $ShippingManagePage->取得_出荷伝票番号(1));
295
        $I->assertEquals('未登録', $ShippingManagePage->取得_出荷伝票番号(2));
296
        $I->assertEquals('未登録', $ShippingManagePage->取得_出荷伝票番号(3));
297
        $I->assertEquals('-', $ShippingManagePage->取得_出荷日(1));
298
        $I->assertEquals('-', $ShippingManagePage->取得_出荷日(2));
299
        $I->assertEquals('-', $ShippingManagePage->取得_出荷日(3));
300
301
        /*
302
         * 出荷CSV登録
303
         */
304
305
        $csv = implode(PHP_EOL, [
306
            '出荷ID,出荷伝票番号,出荷日',
307
            $Orders[0]->getShippings()[0]->getId().',00001,2018-01-01',
308
            $Orders[1]->getShippings()[0]->getId().',00002,2018-02-02',
309
            $Orders[2]->getShippings()[0]->getId().',00003,2018-03-03',
310
        ]);
311
312
        $csvFileName = codecept_data_dir().'/shipping.csv';
313
        file_put_contents($csvFileName, $csv);
314
315
        try {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
316
317
            ShippingCsvUploadPage::go($I)
318
                ->入力_CSVファイル('shipping.csv')
319
                ->CSVアップロード();
320
321
            $I->see('出荷登録CSVファイルをアップロードしました。', ShippingCsvUploadPage::$完了メッセージ);
322
323
            /*
324
             * 出荷再検索 出荷日/伝票番号が登録されたことを確認
325
             */
326
327
            $ShippingManagePage = ShippingManagePage::go($I)
328
                ->詳細検索設定()
329
                ->入力_ご注文者お名前($Customer->getName01().$Customer->getName02())
330
                ->入力_ご注文者お名前フリガナ($Customer->getKana01().$Customer->getKana02())
331
                ->検索();
332
333
            $I->see('検索結果 : 3 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
334
335
            $I->assertEquals('00003', $ShippingManagePage->取得_出荷伝票番号(1));
336
            $I->assertEquals('00002', $ShippingManagePage->取得_出荷伝票番号(2));
337
            $I->assertEquals('00001', $ShippingManagePage->取得_出荷伝票番号(3));
338
            $I->assertEquals('2018/03/03', $ShippingManagePage->取得_出荷日(1));
339
            $I->assertEquals('2018/02/02', $ShippingManagePage->取得_出荷日(2));
340
            $I->assertEquals('2018/01/01', $ShippingManagePage->取得_出荷日(3));
341
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
342
        } finally {
343
            if (file_exists($csvFileName)) {
344
                unlink($csvFileName);
345
            }
346
        }
347
    }
348
349 View Code Duplication
    public function shipping_出荷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 "EA09ShippingCest::shipping_出荷CSV雛形ファイルダウンロード" is not in camel caps format
Loading history...
350
    {
351
        $I->wantTo('EA0093-UC04-T02 出荷CSV雛形ファイルのダウンロード');
352
353
        ShippingCsvUploadPage::go($I)->雛形ダウンロード();
354
        $csv = $I->getLastDownloadFile('/^shipping\.csv$/');
355
        $I->assertEquals(mb_convert_encoding(file_get_contents($csv), 'UTF-8', 'Shift_JIS'), '出荷ID,出荷伝票番号,出荷日'.PHP_EOL);
356
    }
357
}
358