Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 20 | class EA03ProductCest |
||
| 21 | { |
||
| 22 | const ページタイトル = '#main .page-header'; |
||
| 23 | const ページタイトルStyleGuide = '.c-pageTitle'; |
||
| 24 | |||
| 25 | public function _before(\AcceptanceTester $I) |
||
| 26 | { |
||
| 27 | // すべてのテストケース実施前にログインしておく |
||
| 28 | // ログイン後は管理アプリのトップページに遷移している |
||
| 29 | $I->loginAsAdmin(); |
||
| 30 | } |
||
| 31 | |||
| 32 | public function _after(\AcceptanceTester $I) |
||
| 33 | { |
||
| 34 | } |
||
| 35 | |||
| 36 | public function product_商品検索(\AcceptanceTester $I) |
||
| 37 | { |
||
| 38 | $I->wantTo('EA0301-UC01-T01 (& UC01-T02) 商品検索'); |
||
| 39 | |||
| 40 | ProductManagePage::go($I)->検索('フォーク'); |
||
| 41 | |||
| 42 | $I->see("検索結果:1件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 43 | $I->see("ディナーフォーク", ProductManagePage::$検索結果_一覧); |
||
| 44 | |||
| 45 | ProductManagePage::go($I)->検索('[email protected]'); |
||
| 46 | $I->see('検索結果:0件が該当しました', ProductManagePage::$検索結果_メッセージ); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function product_商品検索エラー(\AcceptanceTester $I) |
||
| 50 | { |
||
| 51 | $I->wantTo('EA0301-UC01-T03 商品検索 エラー'); |
||
| 52 | |||
| 53 | // バリデーションエラーが発生するフォーム項目がないため, ダミーのステータスを作っておく |
||
| 54 | /** @var \Doctrine\ORM\EntityManager $em */ |
||
| 55 | $em = Fixtures::get('entityManager'); |
||
| 56 | $ProductStatus = new \Eccube\Entity\Master\ProductStatus(); |
||
| 57 | $ProductStatus->setName('ダミー'); |
||
| 58 | $ProductStatus->setSortNo(999); |
||
| 59 | $ProductStatus->setId(999); |
||
| 60 | $em->persist($ProductStatus); |
||
| 61 | $em->flush(); |
||
| 62 | |||
| 63 | // 商品マスターを表示 |
||
| 64 | $page = ProductManagePage::go($I); |
||
| 65 | |||
| 66 | // ダミーのステータスを削除する |
||
| 67 | $em->remove($ProductStatus); |
||
| 68 | $em->flush(); |
||
| 69 | |||
| 70 | // 存在しないステータスで検索するため, `有効な値ではありません`のバリデーションエラーが発生するはず |
||
| 71 | $page->詳細検索_ステータス(999); |
||
| 72 | $I->see('検索条件に誤りがあります。', ProductManagePage::$検索結果_エラーメッセージ); |
||
| 73 | } |
||
| 74 | |||
| 75 | public function product_規格確認のポップアップ表示(\AcceptanceTester $I) |
||
| 76 | { |
||
| 77 | $I->wantTo('EA0301-UC01-T03 規格確認のポップアップを表示'); |
||
| 78 | |||
| 79 | ProductManagePage::go($I) |
||
| 80 | ->検索() |
||
| 81 | ->規格確認ボタンをクリック() |
||
| 82 | ->規格確認をキャンセル(); |
||
| 83 | |||
| 84 | $I->dontSeeElement(['css' => 'div.modal.show']); |
||
| 85 | } |
||
| 86 | |||
| 87 | public function product_ポップアップから規格編集画面に遷移(\AcceptanceTester $I) |
||
| 88 | { |
||
| 89 | $I->wantTo('EA0301-UC01-T04 ポップアップから規格編集画面に遷移'); |
||
| 90 | |||
| 91 | ProductManagePage::go($I) |
||
| 92 | ->検索() |
||
| 93 | ->規格確認ボタンをクリック() |
||
| 94 | ->規格編集画面に遷移(); |
||
| 95 | |||
| 96 | $I->see('商品登録(規格設定)商品管理', self::ページタイトルStyleGuide); |
||
| 97 | } |
||
| 98 | |||
| 99 | public function product_商品検索結果無(\AcceptanceTester $I) |
||
| 100 | { |
||
| 101 | $I->wantTo('EA0301-UC01-T02 商品検索 検索結果なし'); |
||
| 102 | |||
| 103 | ProductManagePage::go($I)->検索('お箸'); |
||
| 104 | |||
| 105 | $I->see("検索条件に合致するデータが見つかりませんでした", ProductManagePage::$検索結果_結果なしメッセージ); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @env firefox |
||
| 110 | * @env chrome |
||
| 111 | */ |
||
| 112 | public function product_CSV出力(\AcceptanceTester $I) |
||
| 113 | { |
||
| 114 | $I->wantTo('EA0301-UC02-T01 CSV出力'); |
||
| 115 | |||
| 116 | $findProducts = Fixtures::get('findProducts'); |
||
| 117 | $Products = $findProducts(); |
||
| 118 | ProductManagePage::go($I) |
||
| 119 | ->検索() |
||
| 120 | ->CSVダウンロード(); |
||
| 121 | |||
| 122 | $I->see("検索結果:".count($Products)."件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 123 | |||
| 124 | $ProductCSV = $I->getLastDownloadFile('/^product_\d{14}\.csv$/'); |
||
| 125 | $I->assertGreaterOrEquals(count($Products), count(file($ProductCSV)), '検索結果以上の行数があるはず'); |
||
| 126 | } |
||
| 127 | |||
| 128 | public function product_CSV出力項目設定(\AcceptanceTester $I) |
||
| 129 | { |
||
| 130 | $I->wantTo('EA0301-UC02-T02 CSV出力項目設定'); |
||
| 131 | |||
| 132 | ProductManagePage::go($I) |
||
| 133 | ->検索() |
||
| 134 | ->CSV出力項目設定(); |
||
| 135 | |||
| 136 | $I->see('CSV出力項目設定基本情報設定', self::ページタイトルStyleGuide); |
||
| 137 | $value = $I->grabValueFrom(CsvSettingsPage::$CSVタイプ); |
||
| 138 | $I->assertEquals('1', $value); |
||
| 139 | } |
||
| 140 | |||
| 141 | public function product_一覧からの規格編集規格なし失敗(\AcceptanceTester $I) |
||
| 142 | { |
||
| 143 | $I->wantTo('EA0310-UC01-T02 一覧からの規格編集 規格なし 失敗'); |
||
| 144 | |||
| 145 | ProductManagePage::go($I) |
||
| 146 | ->検索('規格なし商品') |
||
| 147 | ->検索結果_選択(1); |
||
| 148 | |||
| 149 | ProductEditPage::at($I) |
||
| 150 | ->規格管理(); |
||
| 151 | |||
| 152 | ProductClassEditPage::at($I) |
||
| 153 | ->規格設定(); |
||
| 154 | |||
| 155 | $I->seeElement(['css' => '#product_class_matrix_class_name1:invalid']); //規格1がエラー |
||
| 156 | $I->dontSeeElement(ProductClassEditPage::$規格一覧); // 規格編集行が表示されていない |
||
| 157 | } |
||
| 158 | |||
| 159 | public function product_一覧からの規格編集規格なし_(\AcceptanceTester $I) |
||
| 160 | { |
||
| 161 | $I->wantTo('EA0310-UC01-T01 一覧からの規格編集 規格なし'); |
||
| 162 | |||
| 163 | ProductManagePage::go($I) |
||
| 164 | ->検索('規格なし商品') |
||
| 165 | ->検索結果_選択(1); |
||
| 166 | |||
| 167 | ProductEditPage::at($I) |
||
| 168 | ->規格管理(); |
||
| 169 | |||
| 170 | $ProductClassEditPage = ProductClassEditPage::at($I) |
||
| 171 | ->入力_規格1('材質') |
||
| 172 | ->規格設定(); |
||
| 173 | |||
| 174 | $I->see('3 件の規格の組み合わせがあります', 'div.c-contentsArea__cols > div > div > form div.card-header > div > div.col-6 > span'); |
||
| 175 | |||
| 176 | $ProductClassEditPage |
||
| 177 | ->選択(1) |
||
| 178 | ->入力_在庫数無制限(1) |
||
| 179 | ->入力_販売価格(1, 1000) |
||
| 180 | ->選択(2) |
||
| 181 | ->入力_在庫数無制限(2) |
||
| 182 | ->入力_販売価格(2, 1000) |
||
| 183 | ->選択(3) |
||
| 184 | ->入力_在庫数無制限(3) |
||
| 185 | ->入力_販売価格(3, 1000) |
||
| 186 | ->登録(); |
||
| 187 | |||
| 188 | $I->waitForElement(ProductClassEditPage::$登録完了メッセージ); |
||
| 189 | $I->see('商品規格を登録しました。', ProductClassEditPage::$登録完了メッセージ); |
||
| 190 | $I->seeElement(ProductClassEditPage::$初期化ボタン); |
||
| 191 | } |
||
| 192 | |||
| 193 | public function product_一覧からの規格編集規格あり2(\AcceptanceTester $I) |
||
| 194 | { |
||
| 195 | $I->wantTo('EA0310-UC02-T02 一覧からの規格編集 規格あり2'); |
||
| 196 | |||
| 197 | $findProducts = Fixtures::get('findProducts'); |
||
| 198 | $Products = array_filter($findProducts(), function ($Product) { |
||
| 199 | return $Product->hasProductClass(); |
||
| 200 | }); |
||
| 201 | $Product = array_pop($Products); |
||
| 202 | ProductManagePage::go($I) |
||
| 203 | ->検索($Product->getName()) |
||
| 204 | ->検索結果_選択(1); |
||
| 205 | |||
| 206 | ProductEditPage::at($I) |
||
| 207 | ->規格管理(); |
||
| 208 | |||
| 209 | ProductClassEditPage::at($I) |
||
| 210 | ->登録(); |
||
| 211 | |||
| 212 | $I->see('商品規格を更新しました。', ProductClassEditPage::$登録完了メッセージ); |
||
| 213 | } |
||
| 214 | |||
| 215 | public function product_一覧からの商品複製(\AcceptanceTester $I) |
||
| 216 | { |
||
| 217 | $I->wantTo('EA0310-UC05-T02 一覧からの商品複製'); |
||
| 218 | |||
| 219 | $findProducts = Fixtures::get('findProducts'); |
||
| 220 | $Products = array_filter($findProducts(), function ($Product) { |
||
| 221 | return $Product->hasProductClass(); |
||
| 222 | }); |
||
| 223 | $Product = array_pop($Products); |
||
| 224 | ProductManagePage::go($I) |
||
| 225 | ->検索($Product->getName()) |
||
| 226 | ->検索結果_複製(1); |
||
| 227 | |||
| 228 | $I->acceptPopup(); |
||
| 229 | } |
||
| 230 | |||
| 231 | /** |
||
| 232 | * ATTENTION 削除すると後続の規格編集関連のテストが失敗するため、最後に実行する |
||
| 233 | */ |
||
| 234 | public function product_一覧からの規格編集規格あり1(\AcceptanceTester $I) |
||
| 235 | { |
||
| 236 | $I->wantTo('EA0310-UC02-T01 一覧からの規格編集 規格あり1'); |
||
| 237 | |||
| 238 | $findProducts = Fixtures::get('findProducts'); |
||
| 239 | $Products = array_filter($findProducts(), function ($Product) { |
||
| 240 | return $Product->hasProductClass(); |
||
| 241 | }); |
||
| 242 | $Product = array_pop($Products); |
||
| 243 | ProductManagePage::go($I) |
||
| 244 | ->検索($Product->getName()) |
||
| 245 | ->検索結果_選択(1); |
||
| 246 | |||
| 247 | ProductEditPage::at($I) |
||
| 248 | ->規格管理(); |
||
| 249 | |||
| 250 | $I->seeElement(ProductClassEditPage::$規格一覧); |
||
| 251 | |||
| 252 | ProductClassEditPage::at($I) |
||
| 253 | ->規格初期化(); |
||
| 254 | |||
| 255 | $I->see('商品規格を削除しました', ProductClassEditPage::$登録完了メッセージ); |
||
| 256 | $I->dontSeeElement(ProductClassEditPage::$規格一覧); |
||
| 257 | } |
||
| 258 | |||
| 259 | public function product_商品登録非公開(\AcceptanceTester $I) |
||
| 260 | { |
||
| 261 | $I->wantTo('EA0302-UC01-T01 商品登録 非公開'); |
||
| 262 | |||
| 263 | ProductEditPage::go($I) |
||
| 264 | ->入力_商品名('test product1') |
||
| 265 | ->入力_販売価格('1000') |
||
| 266 | ->入力_カテゴリ(1) |
||
| 267 | ->登録(); |
||
| 268 | |||
| 269 | $I->see('登録が完了しました。', ProductEditPage::$登録結果メッセージ); |
||
| 270 | } |
||
| 271 | |||
| 272 | public function product_商品登録公開(\AcceptanceTester $I) |
||
| 273 | { |
||
| 274 | $I->wantTo('EA0302-UC01-T02 商品登録 公開'); |
||
| 275 | |||
| 276 | ProductEditPage::go($I) |
||
| 277 | ->入力_商品名('test product2') |
||
| 278 | ->入力_販売価格('1000') |
||
| 279 | ->入力_カテゴリ(1) |
||
| 280 | ->入力_公開() |
||
| 281 | ->登録(); |
||
| 282 | |||
| 283 | $I->see('登録が完了しました。', ProductEditPage::$登録結果メッセージ); |
||
| 284 | } |
||
| 285 | |||
| 286 | public function product_商品編集規格なし(\AcceptanceTester $I) |
||
| 287 | { |
||
| 288 | $I->wantTo('EA0302-UC01-T03 商品編集 規格なし'); |
||
| 289 | |||
| 290 | ProductManagePage::go($I) |
||
| 291 | ->検索('test product1') |
||
| 292 | ->検索結果_選択(1); |
||
| 293 | |||
| 294 | ProductEditPage::at($I) |
||
| 295 | ->入力_商品名('test product11') |
||
| 296 | ->入力_カテゴリ(1) |
||
| 297 | ->入力_カテゴリ(2) |
||
| 298 | ->登録(); |
||
| 299 | |||
| 300 | $I->see('登録が完了しました。', ProductEditPage::$登録結果メッセージ); |
||
| 301 | } |
||
| 302 | |||
| 303 | public function product_商品編集規格あり(\AcceptanceTester $I) |
||
| 304 | { |
||
| 305 | $I->wantTo('EA0302-UC01-T04 商品編集 規格あり'); |
||
| 306 | |||
| 307 | // 規格なし商品では商品種別等が編集可能 |
||
| 308 | ProductManagePage::go($I) |
||
| 309 | ->検索('パーコレーター') |
||
| 310 | ->検索結果_選択(1); |
||
| 311 | ProductEditPage::at($I); |
||
| 312 | |||
| 313 | $I->click(['css' => '#basicConfig > div > div:nth-child(7) > div.col > div.d-inline-block.mb-2 > a']); |
||
| 314 | $I->seeElement(ProductEditPage::$販売種別); |
||
| 315 | $I->seeElement(ProductEditPage::$販売価格); |
||
| 316 | $I->waitForElement(ProductEditPage::$通常価格); |
||
| 317 | $I->seeElement(ProductEditPage::$在庫数); |
||
| 318 | $I->waitForElement(ProductEditPage::$商品コード); |
||
| 319 | $I->seeElement(ProductEditPage::$販売制限数); |
||
| 320 | $I->seeElement(ProductEditPage::$お届可能日); |
||
| 321 | |||
| 322 | // 規格あり商品では商品種別等が編集不可 |
||
| 323 | ProductManagePage::go($I) |
||
| 324 | ->検索('ディナーフォーク') |
||
| 325 | ->検索結果_選択(1); |
||
| 326 | $ProductEditPage = ProductEditPage::at($I); |
||
| 327 | |||
| 328 | $I->dontSeeElements([ |
||
| 329 | ProductEditPage::$販売種別, |
||
| 330 | ProductEditPage::$販売価格, |
||
| 331 | ProductEditPage::$通常価格, |
||
| 332 | ProductEditPage::$在庫数, |
||
| 333 | ProductEditPage::$商品コード, |
||
| 334 | ProductEditPage::$販売制限数, |
||
| 335 | ProductEditPage::$お届可能日 |
||
| 336 | ]); |
||
| 337 | |||
| 338 | $ProductEditPage->登録(); |
||
| 339 | $I->see('登録が完了しました。', ProductEditPage::$登録結果メッセージ); |
||
| 340 | } |
||
| 341 | |||
| 342 | public function product_新製品はタグを持っています(\AcceptanceTester $I) |
||
| 343 | { |
||
| 344 | $I->wantTo('EA0302-UC01-T05-タグを商品に追加する'); |
||
| 345 | |||
| 346 | ProductEditPage::go($I) |
||
| 347 | ->入力_商品名("規格なし商品") |
||
| 348 | ->入力_販売価格(50000) |
||
| 349 | ->クリックして開くタグリスト() |
||
| 350 | ->クリックして選択タグ(2) |
||
| 351 | ->クリックして選択タグ(3) |
||
| 352 | ->クリックして選択タグ(4) |
||
| 353 | ->登録(); |
||
| 354 | $I->see('登録が完了しました。', 'div.c-container > div.c-contentsArea > div.alert'); |
||
| 355 | |||
| 356 | $I->seeElement(['xpath' => '//*[@id="tag"]/div/div[1]/button']); |
||
| 357 | $I->seeElement(['xpath' => '//*[@id="tag"]/div/div[2]/button']); |
||
| 358 | $I->seeElement(['xpath' => '//*[@id="tag"]/div/div[3]/button']); |
||
| 359 | } |
||
| 360 | |||
| 361 | public function product_一覧からの商品削除(\AcceptanceTester $I) |
||
| 362 | { |
||
| 363 | $I->wantTo('EA0310-UC05-T03 一覧からの商品削除'); |
||
| 364 | |||
| 365 | ProductManagePage::go($I) |
||
| 366 | ->検索('') |
||
| 367 | ->検索結果_削除(1) |
||
| 368 | ->wait() |
||
| 369 | ->Accept_削除(1); |
||
| 370 | } |
||
| 371 | |||
| 372 | public function product_商品の一括削除_正常(\AcceptanceTester $I) |
||
| 373 | { |
||
| 374 | $I->wantTo('EA0302-UC05-T04 商品の一括削除(正常)'); |
||
| 375 | |||
| 376 | $createProduct = Fixtures::get('createProduct'); |
||
| 377 | foreach (range(1, 5) as $i) { |
||
| 378 | $createProduct("一括削除用_${i}"); |
||
| 379 | } |
||
| 380 | $ProductManagePage = ProductManagePage::go($I) |
||
| 381 | ->検索('一括削除用') |
||
| 382 | ->すべて選択(); |
||
| 383 | |||
| 384 | $I->see("検索結果:5件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 385 | |||
| 386 | $ProductManagePage |
||
| 387 | ->完全に削除() |
||
| 388 | ->一括削除完了(); |
||
| 389 | |||
| 390 | $I->see("検索結果:0件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 391 | } |
||
| 392 | |||
| 393 | |||
| 394 | |||
| 395 | public function product_商品の一括削除_削除エラー(\AcceptanceTester $I) |
||
| 396 | { |
||
| 397 | $I->wantTo('EA0302-UC05-T04 商品の一括削除(正常)'); |
||
| 398 | |||
| 399 | $createProduct = Fixtures::get('createProduct'); |
||
| 400 | $createOrders = Fixtures::get('createOrders'); |
||
| 401 | |||
| 402 | $timestamp = time(); |
||
| 403 | // 受注に紐付いていない商品と紐付いている商品を作成 |
||
| 404 | foreach (range(1, 5) as $i) { |
||
| 405 | $createProduct("一括削除用_${timestamp}_受注なし_${i}"); |
||
| 406 | } |
||
| 407 | $Customer = (Fixtures::get('createCustomer'))(); |
||
| 408 | foreach (range(1, 5) as $i) { |
||
| 409 | $Product = $createProduct("一括削除用_${timestamp}_受注あり_${i}"); |
||
| 410 | $createOrders($Customer, 1, $Product->getProductClasses()->toArray()); |
||
| 411 | } |
||
| 412 | |||
| 413 | $ProductManagePage = ProductManagePage::go($I) |
||
| 414 | ->検索("一括削除用_${timestamp}") |
||
| 415 | ->すべて選択(); |
||
| 416 | |||
| 417 | $I->see("検索結果:10件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 418 | $I->see("一括削除用_${timestamp}_受注あり", ProductManagePage::$検索結果_一覧); |
||
| 419 | $I->see("一括削除用_${timestamp}_受注なし", ProductManagePage::$検索結果_一覧); |
||
| 420 | |||
| 421 | $ProductManagePage->完全に削除(); |
||
| 422 | |||
| 423 | $I->see("一括削除用_${timestamp}_受注あり_1", ProductManagePage::$一括削除エラー); |
||
| 424 | $I->see("一括削除用_${timestamp}_受注あり_2", ProductManagePage::$一括削除エラー); |
||
| 425 | $I->see("一括削除用_${timestamp}_受注あり_3", ProductManagePage::$一括削除エラー); |
||
| 426 | $I->see("一括削除用_${timestamp}_受注あり_4", ProductManagePage::$一括削除エラー); |
||
| 427 | $I->see("一括削除用_${timestamp}_受注あり_5", ProductManagePage::$一括削除エラー); |
||
| 428 | |||
| 429 | $ProductManagePage->一括削除完了(); |
||
| 430 | |||
| 431 | $I->see("検索結果:5件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 432 | $I->see("一括削除用_${timestamp}_受注あり", ProductManagePage::$検索結果_一覧); |
||
| 433 | $I->dontSee("一括削除用_${timestamp}_受注なし", ProductManagePage::$検索結果_一覧); |
||
| 434 | } |
||
| 435 | |||
| 436 | public function product_規格登録_(\AcceptanceTester $I) |
||
| 437 | { |
||
| 438 | $I->wantTo('EA0303-UC01-T01 規格登録'); |
||
| 439 | |||
| 440 | ClassNameManagePage::go($I) |
||
| 441 | ->入力_管理名('backend test class1') |
||
| 442 | ->入力_表示名('display test class1') |
||
| 443 | ->規格作成(); |
||
| 444 | |||
| 445 | $I->see('規格を保存しました。', ClassNameManagePage::$登録完了メッセージ); |
||
| 446 | } |
||
| 447 | |||
| 448 | public function product_規格登録未登録時(\AcceptanceTester $I) |
||
| 449 | { |
||
| 450 | $I->wantTo('EA0303-UC01-T02 規格登録 未登録時'); |
||
| 451 | // TODO [fixture] 規格が1件も登録されていない状態にする |
||
| 452 | } |
||
| 453 | |||
| 454 | public function product_規格編集(\AcceptanceTester $I) |
||
| 455 | { |
||
| 456 | $I->wantTo('EA0303-UC02-T01 規格編集'); |
||
| 457 | |||
| 458 | $ProductClassPage = ClassNameManagePage::go($I)->一覧_編集(2); |
||
| 459 | |||
| 460 | $backendValue = $I->grabValueFrom(ClassNameManagePage::$管理名編集3); |
||
| 461 | $I->assertEquals('backend test class1', $backendValue); |
||
| 462 | |||
| 463 | $displayValue = $I->grabValueFrom(ClassNameManagePage::$表示名編集3); |
||
| 464 | $I->assertEquals('display test class1', $displayValue); |
||
| 465 | |||
| 466 | $ProductClassPage->規格編集(2); |
||
| 467 | |||
| 468 | $I->see('規格を保存しました。', ClassNameManagePage::$登録完了メッセージ); |
||
| 469 | // remove added class |
||
| 470 | ClassNameManagePage::go($I)->一覧_削除(1) |
||
| 471 | ->acceptModal(1); |
||
| 472 | } |
||
| 473 | |||
| 474 | public function product_規格削除(\AcceptanceTester $I) |
||
| 475 | { |
||
| 476 | $I->wantTo('EA0303-UC03-T01 規格削除'); |
||
| 477 | |||
| 478 | // Create a class name for test |
||
| 479 | ClassNameManagePage::go($I) |
||
| 480 | ->入力_管理名('backend test class1') |
||
| 481 | ->入力_表示名('display test class1') |
||
| 482 | ->規格作成(); |
||
| 483 | |||
| 484 | ClassNameManagePage::go($I)->一覧_削除(1) |
||
| 485 | ->acceptModal(1); |
||
| 486 | |||
| 487 | $I->see('規格を削除しました。', ClassNameManagePage::$登録完了メッセージ); |
||
| 488 | } |
||
| 489 | |||
| 490 | public function product_規格表示順の変更(\AcceptanceTester $I) |
||
| 491 | { |
||
| 492 | $I->wantTo('EA0308-UC01-T01 規格表示順の変更'); |
||
| 493 | |||
| 494 | $ProductClassPage = ClassNameManagePage::go($I); |
||
| 495 | $I->see("サイズ", $ProductClassPage->一覧_名称(1)); |
||
| 496 | $I->see("材質", $ProductClassPage->一覧_名称(2)); |
||
| 497 | |||
| 498 | $ProductClassPage->一覧_下に(1); |
||
| 499 | $I->see("材質", $ProductClassPage->一覧_名称(1)); |
||
| 500 | $I->see("サイズ", $ProductClassPage->一覧_名称(2)); |
||
| 501 | |||
| 502 | $ProductClassPage->一覧_上に(2); |
||
| 503 | $I->see("サイズ", $ProductClassPage->一覧_名称(1)); |
||
| 504 | $I->see("材質", $ProductClassPage->一覧_名称(2)); |
||
| 505 | } |
||
| 506 | |||
| 507 | public function product_分類表示順の変更(\AcceptanceTester $I) |
||
| 508 | { |
||
| 509 | $I->wantTo('EA0311-UC01-T01 分類表示順の変更'); |
||
| 510 | |||
| 511 | ClassNameManagePage::go($I) |
||
| 512 | ->一覧_分類登録(1); |
||
| 513 | |||
| 514 | $ProductClassCategoryPage = ClassCategoryManagePage::at($I); |
||
| 515 | $I->see('150cm', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 516 | $I->see('170mm', $ProductClassCategoryPage->一覧_名称(2)); |
||
| 517 | $I->see('120mm', $ProductClassCategoryPage->一覧_名称(3)); |
||
| 518 | |||
| 519 | $ProductClassCategoryPage->一覧_下に(1); |
||
| 520 | $I->see('170mm', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 521 | $I->see('150cm', $ProductClassCategoryPage->一覧_名称(2)); |
||
| 522 | $I->see('120mm', $ProductClassCategoryPage->一覧_名称(3)); |
||
| 523 | |||
| 524 | $ProductClassCategoryPage->一覧_下に(2); |
||
| 525 | $I->see('170mm', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 526 | $I->see('120mm', $ProductClassCategoryPage->一覧_名称(2)); |
||
| 527 | $I->see('150cm', $ProductClassCategoryPage->一覧_名称(3)); |
||
| 528 | |||
| 529 | $ProductClassCategoryPage->一覧_上に(3); |
||
| 530 | $I->see('170mm', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 531 | $I->see('150cm', $ProductClassCategoryPage->一覧_名称(2)); |
||
| 532 | $I->see('120mm', $ProductClassCategoryPage->一覧_名称(3)); |
||
| 533 | |||
| 534 | $ProductClassCategoryPage->一覧_上に(2); |
||
| 535 | $I->see('150cm', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 536 | $I->see('170mm', $ProductClassCategoryPage->一覧_名称(2)); |
||
| 537 | $I->see('120mm', $ProductClassCategoryPage->一覧_名称(3)); |
||
| 538 | } |
||
| 539 | |||
| 540 | public function product_分類登録(\AcceptanceTester $I) |
||
| 541 | { |
||
| 542 | $I->wantTo('EA0304-UC01-T01(& UC01-T02/UC02-T01/UC03-T01) 分類登録/編集/削除'); |
||
| 543 | |||
| 544 | $ProductClassPage = ClassNameManagePage::go($I) |
||
| 545 | ->入力_管理名('test class2') |
||
| 546 | ->入力_表示名('test class2') |
||
| 547 | ->規格作成(); |
||
| 548 | |||
| 549 | $I->see('規格を保存しました。', ClassNameManagePage::$登録完了メッセージ); |
||
| 550 | |||
| 551 | $ProductClassPage->一覧_分類登録(1); |
||
| 552 | $I->see('test class2', '#page_admin_product_class_category > div > div.c-contentsArea > div.c-contentsArea__cols > div > div.c-primaryCol > div:nth-child(1) > div.card-body > div:nth-child(2) > div:nth-child(2) > span'); |
||
| 553 | |||
| 554 | // Create a class category |
||
| 555 | $ProductClassCategoryPage = ClassCategoryManagePage::at($I) |
||
| 556 | ->入力_分類名('test class2 category1') |
||
| 557 | ->分類作成(); |
||
| 558 | |||
| 559 | $I->see('分類を保存しました。', ClassCategoryManagePage::$登録完了メッセージ); |
||
| 560 | $I->see('test class2 category1', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 561 | |||
| 562 | // Edit class category 1 |
||
| 563 | $ProductClassCategoryPage->一覧_編集(1) |
||
| 564 | ->一覧_入力_分類名(1, 'edit class category') |
||
| 565 | ->一覧_分類作成(1); |
||
| 566 | |||
| 567 | $I->see('分類を保存しました。', ClassCategoryManagePage::$登録完了メッセージ); |
||
| 568 | $I->see('edit class category', $ProductClassCategoryPage->一覧_名称(1)); |
||
| 569 | |||
| 570 | // delete test |
||
| 571 | $ProductClassCategoryPage->一覧_削除(1) |
||
| 572 | ->acceptModal(1); |
||
| 573 | |||
| 574 | $I->see('分類を削除しました。', ClassCategoryManagePage::$登録完了メッセージ); |
||
| 575 | } |
||
| 576 | |||
| 577 | public function product_カテゴリ登録(\AcceptanceTester $I) |
||
| 578 | { |
||
| 579 | $I->wantTo('EA0305-UC01-T01(& UC01-T02/UC02-T01/UC04-T01) カテゴリ登録/編集/削除'); |
||
| 580 | |||
| 581 | $CategoryPage = CategoryManagePage::go($I) |
||
| 582 | ->入力_カテゴリ名('test category1') |
||
| 583 | ->カテゴリ作成(); |
||
| 584 | |||
| 585 | $I->see('カテゴリを保存しました。', CategoryManagePage::$登録完了メッセージ); |
||
| 586 | |||
| 587 | $CategoryPage->一覧_編集(2); |
||
| 588 | |||
| 589 | $I->seeElement('body > div > div.c-contentsArea > div.c-contentsArea__cols > div.c-contentsArea__primaryCol > div > div > div > div > ul > li:nth-child(2) > form.mode-edit'); |
||
| 590 | |||
| 591 | $CategoryPage->一覧_インライン編集_カテゴリ名(2, 'test category11') |
||
| 592 | ->一覧_インライン編集_決定(2); |
||
| 593 | |||
| 594 | $I->see('カテゴリを保存しました。', CategoryManagePage::$登録完了メッセージ); |
||
| 595 | |||
| 596 | // csv EA0305-UC04-T01 |
||
| 597 | $CategoryPage |
||
| 598 | ->CSVダウンロード実行(); |
||
| 599 | /* csvがダウンロードされたかは確認不可 */ |
||
| 600 | |||
| 601 | // csv EA0305-UC04-T02 |
||
| 602 | $CategoryPage->CSV出力項目設定(); |
||
| 603 | |||
| 604 | CsvSettingsPage::at($I); |
||
| 605 | $value = $I->grabValueFrom(CsvSettingsPage::$CSVタイプ); |
||
| 606 | $I->assertEquals('5', $value); |
||
| 607 | |||
| 608 | // サブカテゴリ EA0305-UC01-03 & UC01-04 |
||
| 609 | $CategoryPage = CategoryManagePage::go($I) |
||
| 610 | ->一覧_選択(2); |
||
| 611 | |||
| 612 | $I->see('test category11', CategoryManagePage::$パンくず_1階層); |
||
| 613 | |||
| 614 | $CategoryPage |
||
| 615 | ->入力_カテゴリ名('test category11-1') |
||
| 616 | ->カテゴリ作成(); |
||
| 617 | $I->see('カテゴリを保存しました。', CategoryManagePage::$登録完了メッセージ); |
||
| 618 | |||
| 619 | // カテゴリ削除 (children) |
||
| 620 | $CategoryPage->一覧_削除(2); |
||
| 621 | $I->acceptPopup(); |
||
| 622 | |||
| 623 | // Delete category root |
||
| 624 | CategoryManagePage::go($I)->一覧_削除(2); |
||
| 625 | $I->acceptPopup(); |
||
| 626 | } |
||
| 627 | |||
| 628 | public function product_カテゴリ表示順の変更(\AcceptanceTester $I) |
||
| 629 | { |
||
| 630 | $I->wantTo("EA0309-UC01-T01 カテゴリ表示順の変更"); |
||
| 631 | |||
| 632 | $CategoryPage = CategoryManagePage::go($I); |
||
| 633 | $I->see('インテリア', $CategoryPage->一覧_名称(2)); |
||
| 634 | $I->see('キッチンツール', $CategoryPage->一覧_名称(3)); |
||
| 635 | $I->see('新入荷', $CategoryPage->一覧_名称(4)); |
||
| 636 | |||
| 637 | $CategoryPage->一覧_下に(2); |
||
| 638 | $I->see('キッチンツール', $CategoryPage->一覧_名称(2)); |
||
| 639 | $I->see('インテリア', $CategoryPage->一覧_名称(3)); |
||
| 640 | $I->see('新入荷', $CategoryPage->一覧_名称(4)); |
||
| 641 | |||
| 642 | $CategoryPage->一覧_下に(3); |
||
| 643 | $I->see('キッチンツール', $CategoryPage->一覧_名称(2)); |
||
| 644 | $I->see('新入荷', $CategoryPage->一覧_名称(3)); |
||
| 645 | $I->see('インテリア', $CategoryPage->一覧_名称(4)); |
||
| 646 | |||
| 647 | $CategoryPage->一覧_上に(4); |
||
| 648 | $I->see('キッチンツール', $CategoryPage->一覧_名称(2)); |
||
| 649 | $I->see('インテリア', $CategoryPage->一覧_名称(3)); |
||
| 650 | $I->see('新入荷', $CategoryPage->一覧_名称(4)); |
||
| 651 | |||
| 652 | $CategoryPage->一覧_上に(3); |
||
| 653 | $I->see('インテリア', $CategoryPage->一覧_名称(2)); |
||
| 654 | $I->see('キッチンツール', $CategoryPage->一覧_名称(3)); |
||
| 655 | $I->see('新入荷', $CategoryPage->一覧_名称(4)); |
||
| 656 | } |
||
| 657 | |||
| 658 | public function product_商品CSV登録(\AcceptanceTester $I) |
||
| 659 | { |
||
| 660 | $I->wantTo('EA0306-UC01-T01 商品CSV登録'); |
||
| 661 | |||
| 662 | ProductManagePage::go($I)->検索('アップロード商品'); |
||
| 663 | $I->see('検索条件に合致するデータが見つかりませんでした', ProductManagePage::$検索結果_結果なしメッセージ); |
||
| 664 | |||
| 665 | ProductCsvUploadPage::go($I) |
||
| 666 | ->入力_CSVファイル('product.csv') |
||
| 667 | ->CSVアップロード(); |
||
| 668 | $I->see('商品登録CSVファイルをアップロードしました', ProductCsvUploadPage::$完了メッセージ); |
||
| 669 | |||
| 670 | ProductManagePage::go($I)->検索('アップロード商品'); |
||
| 671 | $I->see("検索結果:3件が該当しました", ProductManagePage::$検索結果_メッセージ); |
||
| 672 | } |
||
| 673 | |||
| 674 | /** |
||
| 675 | * @env firefox |
||
| 676 | * @env chrome |
||
| 677 | */ |
||
| 678 | public function product_商品CSV登録雛形ファイルダウンロード(\AcceptanceTester $I) |
||
| 679 | { |
||
| 680 | $I->wantTo('EA0306-UC01-T02 商品CSV登録雛形ファイルダウンロード'); |
||
| 681 | |||
| 682 | ProductCsvUploadPage::go($I)->雛形ダウンロード(); |
||
| 683 | $ProductTemplateCSV = $I->getLastDownloadFile('/^product\.csv$/'); |
||
| 684 | $I->assertEquals(1, count(file($ProductTemplateCSV)), 'ヘッダ行だけのファイル'); |
||
| 685 | } |
||
| 686 | |||
| 687 | public function product_カテゴリCSV登録(\AcceptanceTester $I) |
||
| 688 | { |
||
| 689 | $I->wantTo('EA0307-UC01-T01(& UC01-T02) カテゴリCSV登録'); |
||
| 690 | |||
| 691 | CategoryManagePage::go($I); |
||
| 692 | $I->dontSeeElement(['xpath' => '//div[@id="sortable_list_box"]//a[contains(text(), "アップロードカテゴリ")]']); |
||
| 693 | |||
| 694 | CategoryCsvUploadPage::go($I) |
||
| 695 | ->入力_CSVファイル('category.csv') |
||
| 696 | ->CSVアップロード(); |
||
| 697 | |||
| 698 | $I->see('カテゴリ登録CSVファイルをアップロードしました', CategoryCsvUploadPage::$完了メッセージ); |
||
| 699 | |||
| 700 | CategoryManagePage::go($I); |
||
| 701 | |||
| 702 | $I->seeElement(['xpath' => CategoryManagePage::XPathでタグを取得する('アップロードカテゴリ1')]); |
||
| 703 | $I->seeElement(['xpath' => CategoryManagePage::XPathでタグを取得する('アップロードカテゴリ2')]); |
||
| 704 | $I->seeElement(['xpath' => CategoryManagePage::XPathでタグを取得する('アップロードカテゴリ3')]); |
||
| 705 | } |
||
| 706 | |||
| 707 | /** |
||
| 708 | * @env firefox |
||
| 709 | * @env chrome |
||
| 710 | */ |
||
| 711 | public function product_カテゴリCSV登録雛形ファイルダウンロード(\AcceptanceTester $I) |
||
| 712 | { |
||
| 713 | $I->wantTo('EA0307-UC01-T02 カテゴリCSV登録雛形ファイルダウンロード'); |
||
| 714 | |||
| 715 | // 雛形のダウンロード |
||
| 716 | CategoryCsvUploadPage::go($I)->雛形ダウンロード(); |
||
| 717 | $CategoryTemplateCSV = $I->getLastDownloadFile('/^category\.csv$/'); |
||
| 718 | $I->assertEquals(1, count(file($CategoryTemplateCSV)), 'ヘッダ行だけのファイル'); |
||
| 719 | } |
||
| 720 | |||
| 721 | public function product_一覧からの商品確認(\AcceptanceTester $I) |
||
| 722 | { |
||
| 723 | $I->wantTo('EA0310-UC05-T01 一覧からの商品確認'); |
||
| 724 | |||
| 725 | ProductManagePage::go($I) |
||
| 726 | ->検索('パーコレーター') |
||
| 727 | ->検索結果_確認(1); |
||
| 728 | |||
| 729 | $I->switchToNewWindow(); |
||
| 730 | $I->seeInCurrentUrl('/products/detail/'); |
||
| 731 | } |
||
| 732 | } |