|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Extcode\CartProducts\Tests\Acceptance; |
| 6 | + |
| 7 | +/* |
| 8 | + * This file is part of the package extcode/cart-products. |
| 9 | + * |
| 10 | + * For the full copyright and license information, please read the |
| 11 | + * LICENSE file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +use Extcode\CartProducts\Tests\Acceptance\Support\Tester; |
| 15 | + |
| 16 | +class AddConfigurableProductWithStockHandlingToCartCest |
| 17 | +{ |
| 18 | + public function testAddDifferentItemsWithinAvailableAmountToCart(Tester $I): void |
| 19 | + { |
| 20 | + $I->amOnUrl('http://127.0.0.1:8080/product?tx_cartproducts_showproduct%5Baction%5D=show&tx_cartproducts_showproduct%5Bcontroller%5D=Product&tx_cartproducts_showproduct%5Bproduct%5D=6&cHash=93520e7d2c5c85e6563ce0e5b8eba102'); |
| 21 | + |
| 22 | + $I->see('Configurable Product 2', 'h1'); |
| 23 | + $I->see(' ', '#product-price .in-stock'); |
| 24 | + |
| 25 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 26 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 27 | + |
| 28 | + $I->fillField('tx_cart_cart[quantity]', 1); |
| 29 | + $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); |
| 30 | + $I->click('#product-6.add-to-cart-form input.btn[type="submit"]'); |
| 31 | + $I->see('In stock (5 pieces)', '#product-price .in-stock'); |
| 32 | + |
| 33 | + $I->see('Item was added to cart.', '#product-6 .form-message .form-success'); |
| 34 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 35 | + $I->wait(3); |
| 36 | + |
| 37 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 38 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 39 | + |
| 40 | + $I->fillField('tx_cart_cart[quantity]', 2); |
| 41 | + $I->selectOption('tx_cart_cart[beVariants][1]', 'M - green'); |
| 42 | + $I->click('#product-6.add-to-cart-form input.btn[type="submit"]'); |
| 43 | + $I->see('In stock (3 pieces)', '#product-price .in-stock'); |
| 44 | + |
| 45 | + $I->see('2 Items were added to cart.', '#product-6 .form-message .form-success'); |
| 46 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 47 | + $I->wait(3); |
| 48 | + |
| 49 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 50 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 51 | + |
| 52 | + $I->fillField('tx_cart_cart[quantity]', 4); |
| 53 | + $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); |
| 54 | + $I->click('#product-6.add-to-cart-form input.btn[type="submit"]'); |
| 55 | + $I->see('In stock (5 pieces)', '#product-price .in-stock'); |
| 56 | + |
| 57 | + $I->see('4 Items were added to cart.', '#product-6 .form-message .form-success'); |
| 58 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 59 | + $I->wait(3); |
| 60 | + |
| 61 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 62 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 63 | + } |
| 64 | + |
| 65 | + public function testAddMoreItemsThanInStockOfASimpleProductToCart(Tester $I): void |
| 66 | + { |
| 67 | + $I->amOnUrl('http://127.0.0.1:8080/product?tx_cartproducts_showproduct%5Baction%5D=show&tx_cartproducts_showproduct%5Bcontroller%5D=Product&tx_cartproducts_showproduct%5Bproduct%5D=6&cHash=93520e7d2c5c85e6563ce0e5b8eba102'); |
| 68 | + |
| 69 | + $I->see('Configurable Product 2', 'h1'); |
| 70 | + $I->see(' ', '#product-price .in-stock'); |
| 71 | + |
| 72 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 73 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 74 | + |
| 75 | + $I->fillField('tx_cart_cart[quantity]', 6); |
| 76 | + $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); |
| 77 | + $I->click('#product-6.add-to-cart-form input.btn[type="submit"]'); |
| 78 | + $I->see('In stock (5 pieces)', '#product-price .in-stock'); |
| 79 | + |
| 80 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 81 | + $I->see('Desired number of this item not available.', '#product-6 .form-message .form-error'); |
| 82 | + |
| 83 | + $I->wait(3); |
| 84 | + |
| 85 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 86 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 87 | + } |
| 88 | + |
| 89 | + public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Tester $I): void |
| 90 | + { |
| 91 | + $I->amOnUrl('http://127.0.0.1:8080/product?tx_cartproducts_showproduct%5Baction%5D=show&tx_cartproducts_showproduct%5Bcontroller%5D=Product&tx_cartproducts_showproduct%5Bproduct%5D=6&cHash=93520e7d2c5c85e6563ce0e5b8eba102'); |
| 92 | + |
| 93 | + $I->see('Configurable Product 2', 'h1'); |
| 94 | + $I->see(' ', '#product-price .in-stock'); |
| 95 | + |
| 96 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 97 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 98 | + |
| 99 | + $I->fillField('tx_cart_cart[quantity]', 1); |
| 100 | + $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); |
| 101 | + $I->click('#product-6.add-to-cart-form input.btn[type="submit"]'); |
| 102 | + $I->see('In stock (5 pieces)', '#product-price .in-stock'); |
| 103 | + |
| 104 | + $I->see('Item was added to cart.', '#product-6 .form-message .form-success'); |
| 105 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 106 | + $I->wait(3); |
| 107 | + |
| 108 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 109 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 110 | + |
| 111 | + $I->fillField('tx_cart_cart[quantity]', 5); |
| 112 | + $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); |
| 113 | + $I->click('#product-6.add-to-cart-form input.btn[type="submit"]'); |
| 114 | + $I->see('In stock (5 pieces)', '#product-price .in-stock'); |
| 115 | + |
| 116 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 117 | + $I->see('Desired number of this item not available.', '#product-6 .form-message .form-error'); |
| 118 | + |
| 119 | + $I->wait(3); |
| 120 | + |
| 121 | + $I->dontSeeElement('#product-6 .form-message .form-success'); |
| 122 | + $I->dontSeeElement('#product-6 .form-message .form-error'); |
| 123 | + } |
| 124 | +} |
0 commit comments