nanasess /
ec-cube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | use Codeception\Util\Fixtures; |
||
| 4 | use Page\Front\CartPage; |
||
| 5 | use Page\Front\ProductDetailPage; |
||
| 6 | use Page\Front\ProductListPage; |
||
| 7 | use Page\Front\TopPage; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @group front |
||
| 11 | * @group product |
||
| 12 | * @group ef2 |
||
| 13 | */ |
||
| 14 | class EF02ProductCest |
||
|
0 ignored issues
–
show
|
|||
| 15 | { |
||
| 16 | View Code Duplication | public function product_商品一覧初期表示(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 17 | { |
||
| 18 | $I->wantTo('EF0201-UC01-T01 商品一覧ページ 初期表示'); |
||
| 19 | $topPage = TopPage::go($I); |
||
| 20 | |||
| 21 | // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移 |
||
| 22 | $topPage->カテゴリ選択(['キッチンツール', '調理器具']); |
||
| 23 | |||
| 24 | // 登録商品がカテゴリごとに一覧表示される |
||
| 25 | $I->see('調理器具', '.ec-topicpath'); |
||
| 26 | |||
| 27 | // 一覧ページで商品がサムネイル表示される |
||
| 28 | $I->see('パーコレーター', '.ec-shelfGrid'); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function product_商品一覧ヘッダ以外のカテゴリリンク(\AcceptanceTester $I) |
||
| 32 | { |
||
| 33 | $I->wantTo('EF0201-UC01-T02 商品一覧ページ ヘッダ以外のカテゴリリンク'); |
||
| 34 | $I->amOnPage('/'); |
||
| 35 | |||
| 36 | // MEMO: EF0201-UC01-T02... テスト項目の記述が意味不明なのでskip |
||
| 37 | } |
||
| 38 | |||
| 39 | public function product_商品一覧ソート(\AcceptanceTester $I) |
||
| 40 | { |
||
| 41 | $I->wantTo('EF0201-UC03-T01 商品一覧ページ ソート'); |
||
| 42 | $topPage = TopPage::go($I); |
||
| 43 | |||
| 44 | // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移 |
||
| 45 | $topPage->カテゴリ選択(['キッチンツール']); |
||
| 46 | |||
| 47 | // 各商品のサムネイルが表示される デフォルトは価格順 |
||
| 48 | $products = $I->grabMultiple(['xpath' => "//*[@class='ec-shelfGrid__item']/a/p[1]"]); |
||
| 49 | $pPos = 0; |
||
| 50 | $fPos = 0; |
||
| 51 | View Code Duplication | foreach ($products as $key => $product) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across 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...
|
|||
| 52 | if ($product == 'パーコレーター') { |
||
| 53 | $pPos = $key; |
||
| 54 | } |
||
| 55 | if ($product == 'ディナーフォーク') { |
||
| 56 | $fPos = $key; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | $I->assertTrue(($pPos < $fPos)); |
||
| 60 | |||
| 61 | $listPage = new ProductListPage($I); |
||
| 62 | // ソート条件の選択リストを変更する 価格順->新着順 |
||
| 63 | $listPage |
||
| 64 | ->表示件数設定(30) |
||
| 65 | ->表示順設定('新着順'); |
||
| 66 | |||
| 67 | // 変更されたソート条件に従い、商品がソートされる |
||
| 68 | $products = $I->grabMultiple(['xpath' => "//*[@class='ec-shelfGrid__item']/a/p[1]"]); |
||
| 69 | $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 Loading history...
|
|||
| 70 | $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 Loading history...
|
|||
| 71 | View Code Duplication | foreach ($products as $key => $product) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across 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...
|
|||
| 72 | if ($product == 'パーコレーター') { |
||
| 73 | $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 Loading history...
|
|||
| 74 | } |
||
| 75 | if ($product == 'ディナーフォーク') { |
||
| 76 | $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 Loading history...
|
|||
| 77 | } |
||
| 78 | } |
||
| 79 | // ToDo [issue] |
||
| 80 | // まだバグ修正前 https://github.com/EC-CAUBE/ec-cube/issues/1118 |
||
| 81 | // 修正されたら以下を追加 |
||
| 82 | //$I->assertTrue(($pPos > $fPos)); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 83 | } |
||
| 84 | |||
| 85 | public function product_商品一覧表示件数(\AcceptanceTester $I) |
||
| 86 | { |
||
| 87 | $I->wantTo('EF0201-UC04-T01 商品一覧ページ 表示件数'); |
||
| 88 | $topPage = TopPage::go($I); |
||
| 89 | |||
| 90 | // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移 |
||
| 91 | $topPage->カテゴリ選択(['キッチンツール']); |
||
| 92 | $listPage = new ProductListPage($I); |
||
| 93 | |||
| 94 | // 各商品のサムネイルが表示される |
||
| 95 | $config = Fixtures::get('test_config'); |
||
| 96 | $productNum = $config['fixture_product_num'] + 2; |
||
| 97 | $itemNum = ($productNum >= 15) ? 15 : $productNum; |
||
| 98 | $I->assertEquals($itemNum, $listPage->一覧件数取得()); |
||
| 99 | |||
| 100 | // 表示件数の選択リストを変更する |
||
| 101 | $listPage->表示件数設定(30); |
||
| 102 | |||
| 103 | // 変更された表示件数分が1画面に表示される |
||
| 104 | $expected = ($productNum >= 30) ? 30 : $productNum; |
||
| 105 | $I->assertEquals($expected, $listPage->一覧件数取得()); |
||
| 106 | } |
||
| 107 | |||
| 108 | public function product_商品一覧ページング(\AcceptanceTester $I) |
||
| 109 | { |
||
| 110 | $I->wantTo('EF0201-UC04-T02 商品一覧ページ ページング'); |
||
| 111 | $topPage = TopPage::go($I); |
||
| 112 | |||
| 113 | // TOPページ>商品一覧(ヘッダーのいずれかのカテゴリを選択)へ遷移 |
||
| 114 | $topPage->カテゴリ選択(['キッチンツール']); |
||
| 115 | |||
| 116 | // 絞込検索条件では、検索数が多い場合、「次へ」「前へ」「ページ番号」が表示される |
||
| 117 | $I->see('1', ['css' => 'li.ec-pager__item--active']); |
||
| 118 | $I->see('2', ['xpath' => "//li[@class='ec-pager__item'][position()=1]"]); |
||
| 119 | $I->see('次へ', ['xpath' => "//li[@class='ec-pager__item'][position()=2]"]); |
||
| 120 | |||
| 121 | // 選択されたリンクに応じてページングされる |
||
| 122 | |||
| 123 | // '2'をクリック |
||
| 124 | $I->click(['xpath' => "//li[@class='ec-pager__item'][position()=1]/a"]); |
||
| 125 | $I->see('2', ['css' => 'li.ec-pager__item--active']); |
||
| 126 | |||
| 127 | // '前へ'をクリック |
||
| 128 | $I->click(['xpath' => "//li[@class='ec-pager__item'][position()=1]/a"]); |
||
| 129 | $I->see('1', ['css' => 'li.ec-pager__item--active']); |
||
| 130 | |||
| 131 | // '次へ'をクリック |
||
| 132 | $I->click(['xpath' => "//li[@class='ec-pager__item'][position()=2]/a"]); |
||
| 133 | $I->see('2', ['css' => 'li.ec-pager__item--active']); |
||
| 134 | } |
||
| 135 | |||
| 136 | public function product_商品詳細初期表示(\AcceptanceTester $I) |
||
| 137 | { |
||
| 138 | $I->wantTo('EF0202-UC01-T01 商品詳細 初期表示'); |
||
| 139 | $I->setStock(2, 0); |
||
| 140 | ProductDetailPage::go($I, 2); |
||
| 141 | |||
| 142 | // 「カートに入れる」ボタンが、非活性となり「ただいま品切れ中です」と表示される。 |
||
| 143 | $I->see('ただいま品切れ中です', '#form1 button'); |
||
| 144 | } |
||
| 145 | |||
| 146 | View Code Duplication | public function product_商品詳細カテゴリリンク(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 147 | { |
||
| 148 | $I->wantTo('EF0202-UC01-T02 商品詳細 カテゴリリンク'); |
||
| 149 | $productPage = ProductDetailPage::go($I, 2); |
||
| 150 | |||
| 151 | // 商品詳細の関連カテゴリに表示されている、カテゴリリンクを押下する |
||
| 152 | $productPage->カテゴリ選択(['キッチンツール', '調理器具']); |
||
| 153 | |||
| 154 | // 登録商品がカテゴリごとに一覧表示される |
||
| 155 | $I->see('調理器具', '.ec-topicpath'); |
||
| 156 | |||
| 157 | // 一覧ページで商品がサムネイル表示される |
||
| 158 | $I->see('パーコレーター', '.ec-shelfGrid'); |
||
| 159 | } |
||
| 160 | |||
| 161 | public function product_商品詳細サムネイル(\AcceptanceTester $I) |
||
| 162 | { |
||
| 163 | $I->wantTo('EF0202-UC01-T03 商品詳細 サムネイル'); |
||
| 164 | $productPage = ProductDetailPage::go($I, 2); |
||
| 165 | |||
| 166 | // デフォルトサムネイル表示確認 |
||
| 167 | $img = $productPage->サムネイル画像URL(); |
||
| 168 | $I->assertRegExp('/\/upload\/save_image\/cafe-1\.jpg$/', $img, $img.' が見つかりません'); |
||
| 169 | |||
| 170 | // 2個目のサムネイルクリック |
||
| 171 | $productPage->サムネイル切替(2); |
||
| 172 | $img = $productPage->サムネイル画像URL(); |
||
| 173 | $I->assertRegExp('/\/upload\/save_image\/cafe-2\.jpg$/', $img, $img.' が見つかりません'); |
||
| 174 | } |
||
| 175 | |||
| 176 | View Code Duplication | public function product_商品詳細カート1(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 177 | { |
||
| 178 | $I->wantTo('EF0202-UC02-T01 商品詳細 カート 注文数<販売制限数<在庫数の注文'); |
||
| 179 | $I->setStock(2, 10); |
||
| 180 | $productPage = ProductDetailPage::go($I, 2); |
||
| 181 | |||
| 182 | $I->wait(3); |
||
| 183 | // 「カートに入れる」ボタンを押下する |
||
| 184 | $productPage->カートに入れる(4); |
||
| 185 | |||
| 186 | $I->seeInPopup('カートに追加しました。'); |
||
| 187 | $I->acceptPopup(); |
||
| 188 | |||
| 189 | $cartPage = CartPage::go($I); |
||
| 190 | |||
| 191 | // 入力された個数分が、カート画面の対象商品に追加されている。 |
||
| 192 | $I->assertContains('パーコレーター', $cartPage->商品名(1)); |
||
| 193 | $I->assertContains('4', $cartPage->商品数量(1)); |
||
| 194 | |||
| 195 | // カートを空に |
||
| 196 | $cartPage->商品削除(1); |
||
| 197 | } |
||
| 198 | |||
| 199 | View Code Duplication | public function product_商品詳細カート2(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 200 | { |
||
| 201 | $I->wantTo('EF0202-UC02-T02 商品詳細 カート 販売制限数<注文数<在庫数の注文'); |
||
| 202 | $I->setStock(2, 10); |
||
| 203 | |||
| 204 | $productPage = ProductDetailPage::go($I, 2); |
||
| 205 | |||
| 206 | // 「カートに入れる」ボタンを押下する |
||
| 207 | $productPage->カートに入れる(6); |
||
| 208 | |||
| 209 | $I->seeInPopup('選択された商品(パーコレーター)は販売制限しております。'); |
||
| 210 | $I->acceptPopup(); |
||
| 211 | |||
| 212 | $cartPage = CartPage::go($I); |
||
| 213 | |||
| 214 | // 入力された個数分が、カート画面の対象商品に追加されている。 |
||
| 215 | $I->assertContains('パーコレーター', $cartPage->商品名(1)); |
||
| 216 | $I->assertContains('5', $cartPage->商品数量(1)); |
||
| 217 | |||
| 218 | // カートを空に |
||
| 219 | $cartPage->商品削除(1); |
||
| 220 | } |
||
| 221 | |||
| 222 | View Code Duplication | public function product_商品詳細カート3(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 223 | { |
||
| 224 | $I->wantTo('EF0202-UC02-T03 商品詳細 カート 販売制限数<在庫数<注文数の注文'); |
||
| 225 | $I->setStock(2, 10); |
||
| 226 | |||
| 227 | $productPage = ProductDetailPage::go($I, 2); |
||
| 228 | |||
| 229 | // 「カートに入れる」ボタンを押下する |
||
| 230 | $productPage->カートに入れる(12); |
||
| 231 | |||
| 232 | $I->seeInPopup('選択された商品(パーコレーター)は販売制限しております。'); |
||
| 233 | $I->acceptPopup(); |
||
| 234 | |||
| 235 | $cartPage = CartPage::go($I); |
||
| 236 | |||
| 237 | // 入力された個数分が、カート画面の対象商品に追加されている。 |
||
| 238 | $I->assertContains('パーコレーター', $cartPage->商品名(1)); |
||
| 239 | $I->assertContains('5', $cartPage->商品数量(1)); |
||
| 240 | |||
| 241 | // カートを空に |
||
| 242 | $cartPage->商品削除(1); |
||
| 243 | } |
||
| 244 | |||
| 245 | View Code Duplication | public function product_商品詳細カート4(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 246 | { |
||
| 247 | $I->wantTo('EF0202-UC02-T04 商品詳細(規格あり) カート 注文数<販売制限数<在庫数の注文'); |
||
| 248 | $I->setStock(1, array(10, 10, 10, 10, 10, 10, 10, 10, 10)); |
||
| 249 | |||
| 250 | ProductDetailPage::go($I, 1) |
||
| 251 | ->規格選択(['プラチナ', '150cm']) |
||
| 252 | ->カートに入れる(1); |
||
| 253 | |||
| 254 | $I->seeInPopup('カートに追加しました。'); |
||
| 255 | $I->acceptPopup(); |
||
| 256 | |||
| 257 | $cartPage = CartPage::go($I); |
||
| 258 | |||
| 259 | // 入力された個数分が、カート画面の対象商品に追加されている。 |
||
| 260 | $I->assertContains('ディナーフォーク', $cartPage->商品名(1)); |
||
| 261 | $I->assertContains('1', $cartPage->商品数量(1)); |
||
| 262 | |||
| 263 | // カートを空に |
||
| 264 | $cartPage->商品削除(1); |
||
| 265 | } |
||
| 266 | |||
| 267 | View Code Duplication | public function product_商品詳細カート5(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 268 | { |
||
| 269 | $I->wantTo('EF0202-UC02-T05 商品詳細(規格あり) カート 販売制限数<注文数<在庫数の注文'); |
||
| 270 | $I->setStock(1, array(10, 10, 10, 10, 10, 10, 10, 10, 10)); |
||
| 271 | |||
| 272 | ProductDetailPage::go($I, 1) |
||
| 273 | ->規格選択(['プラチナ', '150cm']) |
||
| 274 | ->カートに入れる(3); |
||
| 275 | |||
| 276 | $I->seeInPopup('選択された商品(ディナーフォーク - プラチナ - 150cm)は販売制限しております。'); |
||
| 277 | $I->acceptPopup(); |
||
| 278 | |||
| 279 | $cartPage = CartPage::go($I); |
||
| 280 | |||
| 281 | // 入力された個数分が、カート画面の対象商品に追加されている。 |
||
| 282 | $I->assertContains('ディナーフォーク', $cartPage->商品名(1)); |
||
| 283 | $I->assertContains('2', $cartPage->商品数量(1)); |
||
| 284 | |||
| 285 | // カートを空に |
||
| 286 | $cartPage->商品削除(1); |
||
| 287 | } |
||
| 288 | |||
| 289 | View Code Duplication | public function product_商品詳細カート6(\AcceptanceTester $I) |
|
|
0 ignored issues
–
show
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...
|
|||
| 290 | { |
||
| 291 | $I->wantTo('EF0202-UC02-T06 商品詳細(規格あり) カート 販売制限数<在庫数<注文数の注文'); |
||
| 292 | $I->setStock(1, array(10, 10, 10, 10, 10, 10, 10, 10, 10)); |
||
| 293 | |||
| 294 | ProductDetailPage::go($I, 1) |
||
| 295 | ->規格選択(['プラチナ', '150cm']) |
||
| 296 | ->カートに入れる(12); |
||
| 297 | |||
| 298 | $I->seeInPopup('選択された商品(ディナーフォーク - プラチナ - 150cm)は販売制限しております。'); |
||
| 299 | $I->acceptPopup(); |
||
| 300 | |||
| 301 | $cartPage = CartPage::go($I); |
||
| 302 | |||
| 303 | // 入力された個数分が、カート画面の対象商品に追加されている。 |
||
| 304 | $I->assertContains('ディナーフォーク', $cartPage->商品名(1)); |
||
| 305 | $I->assertContains('2', $cartPage->商品数量(1)); |
||
| 306 | |||
| 307 | // カートを空に |
||
| 308 | $cartPage->商品削除(1); |
||
| 309 | } |
||
| 310 | } |
||
| 311 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.