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

codeception/acceptance/EF02ProductCest.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\ProductDetailPage;
16
use Page\Front\ProductListPage;
17
use Page\Front\TopPage;
18
19
/**
20
 * @group front
21
 * @group product
22
 * @group ef2
23
 */
24
class EF02ProductCest
25
{
26 View Code Duplication
    public function product_商品一覧初期表示(\AcceptanceTester $I)
27
    {
28
        $I->wantTo('EF0201-UC01-T01 商品一覧ページ 初期表示');
29
        $topPage = TopPage::go($I);
30
31
        // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移
32
        $topPage->カテゴリ選択(['アイスサンド', 'フルーツ']);
33
34
        // 登録商品がカテゴリごとに一覧表示される
35
        $I->see('フルーツ', '.ec-topicpath');
36
37
        // 一覧ページで商品がサムネイル表示される
38
        $I->see('チェリーアイスサンド', '.ec-shelfGrid');
39
    }
40
41
    public function product_商品一覧ヘッダ以外のカテゴリリンク(\AcceptanceTester $I)
42
    {
43
        $I->wantTo('EF0201-UC01-T02 商品一覧ページ ヘッダ以外のカテゴリリンク');
44
        $I->amOnPage('/');
45
46
        // MEMO: EF0201-UC01-T02... テスト項目の記述が意味不明なのでskip
47
    }
48
49
    public function product_商品一覧ソート(\AcceptanceTester $I)
50
    {
51
        $I->wantTo('EF0201-UC03-T01 商品一覧ページ ソート');
52
        $topPage = TopPage::go($I);
53
54
        // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移
55
        $topPage->カテゴリ選択(['新入荷']);
56
57
        // 各商品のサムネイルが表示される デフォルトは価格順
58
        $products = $I->grabMultiple(['xpath' => "//*[@class='ec-shelfGrid__item']/a/p[2]"]);
59
        $pPos = 0;
60
        $fPos = 0;
61 View Code Duplication
        foreach ($products as $key => $product) {
62
            if ($product == 'チェリーアイスサンド') {
63
                $pPos = $key;
64
            }
65
            if ($product == '彩のジェラートCUBE') {
66
                $fPos = $key;
67
            }
68
        }
69
        $I->assertTrue(($pPos < $fPos));
70
71
        $listPage = new ProductListPage($I);
72
        // ソート条件の選択リストを変更する 価格順->新着順
73
        $listPage
74
            ->表示件数設定(40)
75
            ->表示順設定('新着順');
76
77
        // 変更されたソート条件に従い、商品がソートされる
78
        $products = $I->grabMultiple(['xpath' => "//*[@class='ec-shelfGrid__item']/a/p[1]"]);
79
        $pPos = 0;
0 ignored issues
show
$pPos 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...
80
        $fPos = 0;
0 ignored issues
show
$fPos 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...
81 View Code Duplication
        foreach ($products as $key => $product) {
82
            if ($product == 'チェリーアイスサンド') {
83
                $pPos = $key;
0 ignored issues
show
$pPos 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...
84
            }
85
            if ($product == '彩のジェラートCUBE') {
86
                $fPos = $key;
0 ignored issues
show
$fPos 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...
87
            }
88
        }
89
        // ToDo [issue]
90
        // まだバグ修正前 https://github.com/EC-CAUBE/ec-cube/issues/1118
91
        // 修正されたら以下を追加
92
        //$I->assertTrue(($pPos > $fPos));
93
    }
94
95
    public function product_商品一覧表示件数(\AcceptanceTester $I)
96
    {
97
        $I->wantTo('EF0201-UC04-T01 商品一覧ページ 表示件数');
98
        $topPage = TopPage::go($I);
99
100
        // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移
101
        $topPage->カテゴリ選択(['新入荷']);
102
        $listPage = new ProductListPage($I);
103
104
        // 各商品のサムネイルが表示される
105
        $config = Fixtures::get('test_config');
106
        $productNum = $config['fixture_product_num'] + 2;
107
        $itemNum = ($productNum >= 20) ? 20 : $productNum;
108
        $I->assertEquals($itemNum, $listPage->一覧件数取得());
109
110
        // 表示件数の選択リストを変更する
111
        $listPage->表示件数設定(40);
112
113
        // 変更された表示件数分が1画面に表示される
114
        $expected = ($productNum >= 40) ? 40 : $productNum;
115
        $I->assertEquals($expected, $listPage->一覧件数取得());
116
    }
117
118
    public function product_商品一覧ページング(\AcceptanceTester $I)
119
    {
120
        $I->wantTo('EF0201-UC04-T02 商品一覧ページ ページング');
121
        $topPage = TopPage::go($I);
122
123
        // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移
124
        $topPage->カテゴリ選択(['新入荷']);
125
126
        // 絞込検索条件では、検索数が多い場合、「次へ」「前へ」「ページ番号」が表示される
127
        $I->see('1', ['css' => 'li.ec-pager__item--active']);
128
        $I->see('2', ['xpath' => "//li[@class='ec-pager__item'][position()=1]"]);
129
        $I->see('次へ', ['xpath' => "//li[@class='ec-pager__item'][position()=2]"]);
130
131
        // 選択されたリンクに応じてページングされる
132
133
        // '2'をクリック
134
        $I->click(['xpath' => "//li[@class='ec-pager__item'][position()=1]/a"]);
135
        $I->see('2', ['css' => 'li.ec-pager__item--active']);
136
137
        // '前へ'をクリック
138
        $I->click(['xpath' => "//li[@class='ec-pager__item'][position()=1]/a"]);
139
        $I->see('1', ['css' => 'li.ec-pager__item--active']);
140
141
        // '次へ'をクリック
142
        $I->click(['xpath' => "//li[@class='ec-pager__item'][position()=2]/a"]);
143
        $I->see('2', ['css' => 'li.ec-pager__item--active']);
144
    }
145
146
    public function product_商品詳細初期表示(\AcceptanceTester $I)
147
    {
148
        $I->wantTo('EF0202-UC01-T01 商品詳細 初期表示');
149
        $I->setStock(2, 0);
150
        ProductDetailPage::go($I, 2);
151
152
        // 「カートに入れる」ボタンが、非活性となり「ただいま品切れ中です」と表示される。
153
        $I->see('ただいま品切れ中です', '#form1 button');
154
    }
155
156 View Code Duplication
    public function product_商品詳細カテゴリリンク(\AcceptanceTester $I)
157
    {
158
        $I->wantTo('EF0202-UC01-T02 商品詳細 カテゴリリンク');
159
        $productPage = ProductDetailPage::go($I, 2);
160
161
        // 商品詳細の関連カテゴリに表示されている、カテゴリリンクを押下する
162
        $productPage->カテゴリ選択(['アイスサンド', 'フルーツ']);
163
164
        // 登録商品がカテゴリごとに一覧表示される
165
        $I->see('フルーツ', '.ec-topicpath');
166
167
        // 一覧ページで商品がサムネイル表示される
168
        $I->see('チェリーアイスサンド', '.ec-shelfGrid');
169
    }
170
171
    public function product_商品詳細サムネイル(\AcceptanceTester $I)
172
    {
173
        $I->wantTo('EF0202-UC01-T03 商品詳細 サムネイル');
174
        $productPage = ProductDetailPage::go($I, 2);
175
176
        // デフォルトサムネイル表示確認
177
        $img = $productPage->サムネイル画像URL(1);
178
        $I->assertRegExp('/\/upload\/save_image\/sand-1\.png$/', $img, $img.' が見つかりません');
179
180
        // 2個目のサムネイルクリック
181
        $productPage->サムネイル切替(2);
182
        $img = $productPage->サムネイル画像URL(2);
183
        $I->assertRegExp('/\/upload\/save_image\/sand-2\.png$/', $img, $img.' が見つかりません');
184
    }
185
186 View Code Duplication
    public function product_商品詳細カート1(\AcceptanceTester $I)
187
    {
188
        $I->wantTo('EF0202-UC02-T01 商品詳細 カート 注文数<販売制限数<在庫数の注文');
189
        $I->setStock(2, 10);
190
        $productPage = ProductDetailPage::go($I, 2);
191
192
        // 「カートに入れる」ボタンを押下する
193
        $productPage->カートに入れる(4);
194
        $I->wait(5);
195
196
        $I->assertContains('カートに追加しました。', $productPage->カートに追加());
197
198
        $cartPage = $productPage->カートへ進む();
199
200
        // 入力された個数分が、カート画面の対象商品に追加されている。
201
        $I->assertContains('チェリーアイスサンド', $cartPage->商品名(1));
202
        $I->assertContains('4', $cartPage->商品数量(1));
203
204
        // カートを空に
205
        $cartPage->商品削除(1);
206
    }
207
208 View Code Duplication
    public function product_商品詳細カート2(\AcceptanceTester $I)
209
    {
210
        $I->wantTo('EF0202-UC02-T02 商品詳細 カート 販売制限数<注文数<在庫数の注文');
211
        $I->setStock(2, 10);
212
213
        $productPage = ProductDetailPage::go($I, 2);
214
215
        // 「カートに入れる」ボタンを押下する
216
        $productPage->カートに入れる(6);
217
        $I->wait(5);
218
219
        $I->assertContains('「チェリーアイスサンド」は販売制限しております。一度に販売制限数を超える購入はできません。', $productPage->カートに追加());
220
221
        $cartPage = $productPage->カートへ進む();
222
223
        // 入力された個数分が、カート画面の対象商品に追加されている。
224
        $I->assertContains('チェリーアイスサンド', $cartPage->商品名(1));
225
        $I->assertContains('5', $cartPage->商品数量(1));
226
227
        // カートを空に
228
        $cartPage->商品削除(1);
229
    }
230
231 View Code Duplication
    public function product_商品詳細カート3(\AcceptanceTester $I)
232
    {
233
        $I->wantTo('EF0202-UC02-T03 商品詳細 カート 販売制限数<在庫数<注文数の注文');
234
        $I->setStock(2, 10);
235
236
        $productPage = ProductDetailPage::go($I, 2);
237
238
        // 「カートに入れる」ボタンを押下する
239
        $productPage->カートに入れる(12);
240
        $I->wait(5);
241
242
        $I->assertContains('「チェリーアイスサンド」は販売制限しております。一度に販売制限数を超える購入はできません。', $productPage->カートに追加());
243
244
        $cartPage = $productPage->カートへ進む();
245
246
        // 入力された個数分が、カート画面の対象商品に追加されている。
247
        $I->assertContains('チェリーアイスサンド', $cartPage->商品名(1));
248
        $I->assertContains('5', $cartPage->商品数量(1));
249
250
        // カートを空に
251
        $cartPage->商品削除(1);
252
    }
253
254 View Code Duplication
    public function product_商品詳細カート4(\AcceptanceTester $I)
255
    {
256
        $I->wantTo('EF0202-UC02-T04 商品詳細(規格あり) カート 注文数<販売制限数<在庫数の注文');
257
        $I->setStock(1, [10, 10, 10, 10, 10, 10, 10, 10, 10]);
258
259
        $productPage = ProductDetailPage::go($I, 1)
260
            ->規格選択(['チョコ', '16mm × 16mm'])
261
            ->カートに入れる(1);
262
263
        $I->wait(5);
264
265
        $I->assertContains('カートに追加しました。', $productPage->カートに追加());
266
267
        $cartPage = $productPage->カートへ進む();
268
269
        // 入力された個数分が、カート画面の対象商品に追加されている。
270
        $I->assertContains('彩のジェラートCUBE', $cartPage->商品名(1));
271
        $I->assertContains('1', $cartPage->商品数量(1));
272
273
        // カートを空に
274
        $cartPage->商品削除(1);
275
    }
276
277 View Code Duplication
    public function product_商品詳細カート5(\AcceptanceTester $I)
278
    {
279
        $I->wantTo('EF0202-UC02-T05 商品詳細(規格あり) カート 販売制限数<注文数<在庫数の注文');
280
        $I->setStock(1, [10, 10, 10, 10, 10, 10, 10, 10, 10]);
281
282
        $productPage = ProductDetailPage::go($I, 1)
283
            ->規格選択(['チョコ', '16mm × 16mm'])
284
            ->カートに入れる(3);
285
286
        $I->wait(5);
287
288
        $I->assertContains('「彩のジェラートCUBE - チョコ - 16mm × 16mm」は販売制限しております。一度に販売制限数を超える購入はできません。', $productPage->カートに追加());
289
290
        $cartPage = $productPage->カートへ進む();
291
292
        // 入力された個数分が、カート画面の対象商品に追加されている。
293
        $I->assertContains('彩のジェラートCUBE', $cartPage->商品名(1));
294
        $I->assertContains('2', $cartPage->商品数量(1));
295
296
        // カートを空に
297
        $cartPage->商品削除(1);
298
    }
299
300 View Code Duplication
    public function product_商品詳細カート6(\AcceptanceTester $I)
301
    {
302
        $I->wantTo('EF0202-UC02-T06 商品詳細(規格あり) カート 販売制限数<在庫数<注文数の注文');
303
        $I->setStock(1, [10, 10, 10, 10, 10, 10, 10, 10, 10]);
304
305
        $productPage = ProductDetailPage::go($I, 1)
306
            ->規格選択(['チョコ', '16mm × 16mm'])
307
            ->カートに入れる(12);
308
309
        $I->wait(5);
310
311
        $I->assertContains('「彩のジェラートCUBE - チョコ - 16mm × 16mm」は販売制限しております。一度に販売制限数を超える購入はできません。', $productPage->カートに追加());
312
313
        $cartPage = $productPage->カートへ進む();
314
315
        // 入力された個数分が、カート画面の対象商品に追加されている。
316
        $I->assertContains('彩のジェラートCUBE', $cartPage->商品名(1));
317
        $I->assertContains('2', $cartPage->商品数量(1));
318
319
        // カートを空に
320
        $cartPage->商品削除(1);
321
    }
322
}
323