Failed Conditions
Pull Request — experimental/sf (#3241)
by k-yamamura
43:19 queued 23:09
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 Page\Admin\CsvSettingsPage;
5
use Page\Admin\ShippingManagePage;
6
use Page\Admin\ShippingEditPage;
7
use Page\Admin\OrderEditPage;
8
use Eccube\Entity\Master\ShippingStatus;
9
10
/**
11
 * @group admin
12
 * @group admin01
13
 * @group shipping
14
 * @group ea9
15
 */
16
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...
17
{
18
    public function _before(\AcceptanceTester $I)
19
    {
20
        // すべてのテストケース実施前にログインしておく
21
        // ログイン後は管理アプリのトップページに遷移している
22
        $I->loginAsAdmin();
23
    }
24
25
    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...
26
    {
27
    }
28
29
    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...
30
    {
31
        $I->wantTo('EA0901-UC01-T01(& UC01-T02, UC01-T3) 出荷検索');
32
33
        $TargetShippings = Fixtures::get('findShippings'); // Closure
34
        $Shippings = $TargetShippings();
35
        ShippingManagePage::go($I);
36
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
37
38
        ShippingManagePage::go($I)->検索('[email protected]');
39
        $I->see('検索結果 : 0 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
40
41
        ShippingManagePage::go($I)->詳細検索_電話番号('あああ');
42
        $I->see('検索条件に誤りがあります', ShippingManagePage::$検索結果_エラーメッセージ);
43
    }
44
45
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$I" missing
Loading history...
46
     * @env firefox
47
     * @env chrome
48
     */
49
    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...
50
    {
51
        $I->wantTo('EA0901-UC02-T01 出荷CSVダウンロード');
52
53
        $TargetShippings = Fixtures::get('findShippings'); // Closure
54
        $Shippings = $TargetShippings();
55
        $ShippingListPage = ShippingManagePage::go($I);
56
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
57
58
        $ShippingListPage->出荷CSVダウンロード実行();
59
        // make sure wait to download file completely
60
        $I->wait(10);
61
        $ShippingCSV = $I->getLastDownloadFile('/^shipping_\d{14}\.csv$/');
62
        $I->assertGreaterOrEquals(count($Shippings), count(file($ShippingCSV)), '検索結果以上の行数があるはず');
63
    }
64
65
    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...
66
    {
67
        $I->wantTo('EA0901-UC02-T02 出荷情報のCSV出力項目変更設定');
68
69
        $TargetShippings = Fixtures::get('findShippings'); // Closure
70
        $Shippings = $TargetShippings();
71
        $ShippingListPage = ShippingManagePage::go($I);
72
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
73
74
        /* 項目設定 */
75
        $ShippingListPage->出荷CSV出力項目設定();
76
77
        CsvSettingsPage::at($I);
78
        $value = $I->grabValueFrom(CsvSettingsPage::$CSVタイプ);
79
        $I->assertEquals(4, $value);
80
    }
81
82
    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...
83
    {
84
        $I->wantTo('EA0901-UC03-T01(& UC03-T02) 出荷編集');
85
86
        $I->resetEmails();
87
88
        $TargetShippings = Fixtures::get('findShippings'); // Closure
89
        $Shippings = $TargetShippings();
90
        $ShippingListPage = ShippingManagePage::go($I);
91
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
92
93
        /* 編集 */
94
        $ShippingListPage->一覧_編集(1);
95
96
        $ShippingRegisterPage = ShippingEditPage::at($I)
97
            ->お届け先編集()
98
            ->入力_姓('')
99
            ->出荷情報登録();
100
101
        /* 異常系 */
102
        // FIXME お届け先編集が閉じてしまうため、エラーメッセージが表示されない
103
        // $I->see('入力されていません。', ShippingEditPage::$姓_エラーメッセージ);
104
105
        /* 正常系 */
106
        $ShippingRegisterPage
107
            ->お届け先編集()
108
            ->入力_姓('aaa')
109
            ->入力_セイ('アアア')
110
            ->入力_メイ('アアア')
111
            ->入力_郵便番号('060-0000')
112
            ->入力_都道府県(['1' => '北海道'])
113
            ->入力_市区町村名('bbb')
114
            ->入力_番地_ビル名('bbb')
115
            ->入力_電話番号('111-111-111')
116
            ->入力_番地_ビル名('address 2')
117
            ->出荷情報登録();
118
119
        $I->see('出荷情報を登録しました。', ShippingEditPage::$登録完了メッセージ);
120
121
        /* ステータス変更 */
122
        $ShippingRegisterPage
123
            ->入力_出荷ステータス(['2' => '出荷済み'])
124
            ->出荷情報登録()
125
            ->変更を確定();
126
        $I->wait(1);
127
        $I->see('出荷情報を登録しました。', ShippingEditPage::$登録完了メッセージ);
128
129
        $I->wait(3);
130
        $I->seeEmailCount(2);
131
    }
132
133
    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...
134
    {
135
        $I->wantTo('EA0901-UC04-T01(& UC04-T02) 出荷削除');
136
137
        $TargetShippings = Fixtures::get('findShippings'); // Closure
138
        $Shippings = $TargetShippings();
139
        $ShippingListPage = ShippingManagePage::go($I);
140
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
141
142
        // 削除
143
        $ShippingListPage->一覧_チェックボックス(1);
144
        $ShippingListPage->一覧_削除();
145
146
        $I->waitForElementVisible(['xpath' => '//*[@id="page_admin_shipping"]/div[1]/div[3]/div[2]/span']);
147
        $I->see('出荷情報を削除しました。', ['xpath' => '//*[@id="page_admin_shipping"]/div[1]/div[3]/div[2]/span']);
148
149
        // 削除キャンセル
150
        $ShippingListPage->一覧_チェックボックス(1);
151
        $ShippingListPage->一覧_削除キャンセル();
152
    }
153
154 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...
155
    {
156
        $I->wantTo('EA0902-UC01-T01 一括発送済み更新');
157
158
        // 一括操作用の受注を生成しておく
159
        $createCustomer = Fixtures::get('createCustomer');
160
        $createOrders = Fixtures::get('createOrders');
161
        $createOrders($createCustomer(), 10, array());
162
163
        $I->resetEmails();
164
165
        $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...
166
        // ステータスを出荷準備中にリセット
167
        $resetShippingStatusPrepared = Fixtures::get('resetShippingStatusPrepared'); // Closure
168
        $resetShippingStatusPrepared();
169
170
        $TargetShippings = Fixtures::get('findShippings'); // Closure
171
        $Shippings = $TargetShippings();
172
        $ShippingListPage = ShippingManagePage::go($I);
173
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
174
175
        $ShippingListPage
176
            ->一覧_全選択()
177
            ->一括発送済み更新();
178
179
        $I->wait(5);
180
        $I->waitForElementVisible(['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
181
        $I->see('処理完了。10件のメールを送信しました', ['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
182
        $I->seeEmailCount(20);
183
184
        $I->click(['id' => 'bulkChangeComplete']);
185
    }
186
187 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...
188
    {
189
        $I->wantTo('EA0902-UC02-T01 一括発送済みメール送信');
190
191
        // 一括操作用の受注を生成しておく
192
        $createCustomer = Fixtures::get('createCustomer');
193
        $createOrders = Fixtures::get('createOrders');
194
        $createOrders($createCustomer(), 10, array());
195
196
        $I->resetEmails();
197
198
        $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...
199
        // ステータスを出荷済みにリセット
200
        $resetShippingStatusShipped = Fixtures::get('resetShippingStatusShipped'); // Closure
201
        $resetShippingStatusShipped();
202
203
        $TargetShippings = Fixtures::get('findShippings'); // Closure
204
        $Shippings = $TargetShippings();
205
        $ShippingListPage = ShippingManagePage::go($I);
206
        $I->see('検索結果 : '.count($Shippings).' 件が該当しました', ShippingManagePage::$検索結果_メッセージ);
207
208
        $ShippingListPage
209
            ->一覧_全選択()
210
            ->一括発送済みメール送信();
211
212
        $I->wait(5);
213
        $I->waitForElementVisible(['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
214
        $I->see('処理完了。10件のメールを送信しました', ['xpath' => '//*[@id="sentUpdateModal"]/div/div/div[2]/p']);
215
        $I->seeEmailCount(20);
216
217
        $I->click(['id' => 'bulkChangeComplete']);
218
    }
219
220
    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...
221
    {
222
        $I->wantTo('EA0903-UC01-T01(& UC01-T02) 出荷登録');
223
224
        $OrderRegisterPage = OrderEditPage::go($I)->受注情報登録();
225
226
        /* 正常系 */
227
        $OrderRegisterPage
228
            ->入力_受注ステータス(['1' => '新規受付'])
229
            ->入力_姓('order1')
230
            ->入力_名('order1')
231
            ->入力_セイ('アアア')
232
            ->入力_メイ('アアア')
233
            ->入力_郵便番号('060-0000')
234
            ->入力_都道府県(['1' => '北海道'])
235
            ->入力_市区町村名('bbb')
236
            ->入力_番地_ビル名('bbb')
237
            ->入力_Eメール('[email protected]')
238
            ->入力_電話番号('111-111-111')
239
            ->商品検索('パーコレーター')
240
            ->商品検索結果_選択(1)
241
            ->入力_支払方法(['4'=> '郵便振替'])
242
            ->受注情報登録();
243
244
        $ShippingRegisterPage = ShippingEditPage::go($I)->出荷情報登録();
245
246
        /* 異常系 */
247
        $I->dontSee('出荷情報を保存しました。', ShippingEditPage::$登録完了メッセージ);
248
249
250
        /* 正常系 */
251
        $ShippingRegisterPage
252
            ->入力_姓('shipping1')
253
            ->入力_名('shipping1')
254
            ->入力_セイ('アアア')
255
            ->入力_メイ('アアア')
256
            ->入力_郵便番号('060-0000')
257
            ->入力_都道府県(['1' => '北海道'])
258
            ->入力_市区町村名('bbb')
259
            ->入力_番地_ビル名('bbb')
260
            ->入力_電話番号('111-111-111')
261
            ->入力_出荷伝票番号('1111-1111-1111')
262
            ->入力_配送業者([1 => 'サンプル業者'])
263
            ->入力_配達用メモ('メモ')
264
            ->商品検索()
265
            ->商品検索結果_選択(1)
266
            ->出荷情報登録();
267
268
        $I->see('出荷情報を登録しました。', ShippingEditPage::$登録完了メッセージ);
269
    }
270
}
271