Failed Conditions
Push — experimental/sf ( ef9148...a8c20b )
by Ryo
1419:13 queued 1408:28
created

EA09ShippingCest::_after()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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