diff --git a/tests/functional/Product/ProductCopyCest.php b/tests/functional/Product/ProductCopyCest.php index 392746f73..085c67d33 100644 --- a/tests/functional/Product/ProductCopyCest.php +++ b/tests/functional/Product/ProductCopyCest.php @@ -11,7 +11,6 @@ use Webkul\Product\Models\ProductAttributeValue; class ProductCopyCest { - public function _before(FunctionalTester $I) { $I->loginAsAdmin(); diff --git a/tests/functional/Shop/CartTaxesCest.php b/tests/functional/Shop/CartTaxesCest.php index b6414d469..22c80a7e3 100644 --- a/tests/functional/Shop/CartTaxesCest.php +++ b/tests/functional/Shop/CartTaxesCest.php @@ -2,15 +2,15 @@ namespace Tests\Functional\Shop; +use Cart; use FunctionalTester; -use Illuminate\Support\Facades\Config; -use Webkul\Core\Helpers\Laravel5Helper; use Webkul\Tax\Models\TaxMap; use Webkul\Tax\Models\TaxRate; use Webkul\Tax\Models\TaxCategory; use Webkul\Customer\Models\Customer; +use Illuminate\Support\Facades\Config; +use Webkul\Core\Helpers\Laravel5Helper; use Webkul\Customer\Models\CustomerAddress; -use Cart; class CartTaxesCest { @@ -84,15 +84,15 @@ class CartTaxesCest $expectedTaxAmount1 = round( round(1 * $product1->price, self::CART_TOTAL_PRECISION) - * $tax1->tax_rate / 100, + * $tax1->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); - // $I->amOnPage('/checkout/cart'); - // $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount1), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate) - // ); + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $I->see(core()->currency($expectedTaxAmount1), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate) + ); Cart::addProduct($product1->id, [ '_token' => session('_token'), @@ -102,15 +102,15 @@ class CartTaxesCest $expectedTaxAmount1 = round( round((1 + $prod1Quantity) * $product1->price, self::CART_TOTAL_PRECISION) - * $tax1->tax_rate / 100, + * $tax1->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); $I->amOnPage('/checkout/cart'); - // $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount1), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate) - // ); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $I->see(core()->currency($expectedTaxAmount1), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate) + ); Cart::addProduct($product2->id, [ '_token' => session('_token'), @@ -120,16 +120,16 @@ class CartTaxesCest $expectedTaxAmount2 = round( round($prod2Quantity * $product2->price, self::CART_TOTAL_PRECISION) - * $tax2->tax_rate / 100, + * $tax2->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); $I->amOnPage('/checkout/cart'); - // $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount1), '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $I->see(core()->currency($expectedTaxAmount1), '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate)); - // $I->see('Tax ' . $tax2->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax2->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount2), '#basetaxamount-' . core()->taxRateAsIdentifier($tax2->tax_rate)); + $I->see('Tax ' . $tax2->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax2->tax_rate)); + $I->see(core()->currency($expectedTaxAmount2), '#basetaxamount-' . core()->taxRateAsIdentifier($tax2->tax_rate)); $cart = Cart::getCart(); @@ -250,23 +250,23 @@ class CartTaxesCest $expectedTaxAmount11 = round( round(1 * $product1->price, self::CART_TOTAL_PRECISION) - * $tax11->tax_rate / 100, + * $tax11->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); $expectedTaxAmount12 = round( round(1 * $product1->price, self::CART_TOTAL_PRECISION) - * $tax12->tax_rate / 100, + * $tax12->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); $expectedTaxAmount21 = round( round(1 * $product2->price, self::CART_TOTAL_PRECISION) - * $tax21->tax_rate / 100, + * $tax21->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); $expectedTaxAmount22 = round( round(1 * $product2->price, self::CART_TOTAL_PRECISION) - * $tax22->tax_rate / 100, + * $tax22->tax_rate / 100, self::TAX_AMOUNT_PRECISION ); @@ -287,28 +287,32 @@ class CartTaxesCest 'shipping' => [ 'address1' => '', ], - ]); + ] + ); $I->wantToTest('customer address with postcode in range of 00000 - 49999'); $I->amOnPage('/checkout/cart'); - // $I->see('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount11), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) - // ); + $I->see('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->see(core()->currency($expectedTaxAmount11), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) + ); $I->dontSee('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount12), + $I->dontSee( + core()->currency($expectedTaxAmount12), '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) ); $I->dontSee('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount21), + $I->dontSee( + core()->currency($expectedTaxAmount21), '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) ); $I->dontSee('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount22), + $I->dontSee( + core()->currency($expectedTaxAmount22), '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) ); @@ -320,28 +324,30 @@ class CartTaxesCest $I->amOnPage('/checkout/cart'); - // $I->see('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount11), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) - // ); + $I->see('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->see(core()->currency($expectedTaxAmount11), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) + ); $I->dontSee('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount12), + $I->dontSee( + core()->currency($expectedTaxAmount12), '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) ); - // $I->see('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount21), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) - // ); + $I->see('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + $I->see(core()->currency($expectedTaxAmount21), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) + ); $I->dontSee('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount22), + $I->dontSee( + core()->currency($expectedTaxAmount22), '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) ); - // $I->see(core()->currency($expectedTaxAmount11), '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount21), '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + $I->see(core()->currency($expectedTaxAmount11), '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->see(core()->currency($expectedTaxAmount21), '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate)); $I->wantToTest('customer address with postcode in range of 50000 - 89999'); @@ -370,33 +376,36 @@ class CartTaxesCest 'shipping' => [ 'address1' => '', ], - ]); + ] + ); $I->amOnPage('/checkout/cart'); $I->dontSee('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount11), + $I->dontSee( + core()->currency($expectedTaxAmount11), '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) ); - // $I->see('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount12), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) - // ); + $I->see('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + $I->see(core()->currency($expectedTaxAmount12), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) + ); $I->dontSee('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount21), + $I->dontSee( + core()->currency($expectedTaxAmount21), '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) ); - // $I->see('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); - // $I->see( - // core()->currency(round($product2->price * $tax22->tax_rate / 100, 2)), - // '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) - // ); + $I->see('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + $I->see( + core()->currency(round($product2->price * $tax22->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) + ); - // $I->see(core()->currency($expectedTaxAmount12), '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate)); - // $I->see(core()->currency($expectedTaxAmount22), '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + $I->see(core()->currency($expectedTaxAmount12), '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + $I->see(core()->currency($expectedTaxAmount22), '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate)); $I->wantToTest('customer address with postcode in range of 90000 - 99000'); $I->wanttoTest('as we dont have any taxes in this zip range'); @@ -425,28 +434,33 @@ class CartTaxesCest 'shipping' => [ 'address1' => '', ], - ]); + ] + ); $I->amOnPage('/checkout/cart'); $I->dontSee('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount11), + $I->dontSee( + core()->currency($expectedTaxAmount11), '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) ); $I->dontSee('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount12), + $I->dontSee( + core()->currency($expectedTaxAmount12), '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) ); $I->dontSee('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount21), + $I->dontSee( + core()->currency($expectedTaxAmount21), '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) ); $I->dontSee('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); - $I->dontSee(core()->currency($expectedTaxAmount22), + $I->dontSee( + core()->currency($expectedTaxAmount22), '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) ); } -} \ No newline at end of file +} diff --git a/tests/functional/Shop/GuestCheckoutCest.php b/tests/functional/Shop/GuestCheckoutCest.php index 425dc477a..f2313520c 100644 --- a/tests/functional/Shop/GuestCheckoutCest.php +++ b/tests/functional/Shop/GuestCheckoutCest.php @@ -49,30 +49,34 @@ class GuestCheckoutCest */ public function testGuestCheckout(FunctionalTester $I, Example $example): void { - // $product = ($example['guest_product']) ? $this->productGuestCheckout : $this->productNoGuestCheckout; + $product = ($example['guest_product']) ? $this->productGuestCheckout : $this->productNoGuestCheckout; - // $I->amGoingTo('try to add products to cart with guest checkout turned on or off'); + $I->amGoingTo('try to add products to cart with guest checkout turned on or off'); - // $I->wantTo('test conjunction "' . $example['name'] . '" with globalConfig = ' . $example['globalConfig'] . ' && product config = ' . $product->getAttribute('guest_checkout')); - // $I->setConfigData(['catalog.products.guest-checkout.allow-guest-checkout' => $example['globalConfig']]); - // $I->assertEquals($example['globalConfig'], - // core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')); - // $I->amOnRoute('shop.home.index'); - // $I->sendAjaxPostRequest('/checkout/cart/add/' . $product->id, [ - // '_token' => session('_token'), - // 'product_id' => $product->id, - // 'quantity' => 1 - // ]); + $I->wantTo('test conjunction "' . $example['name'] . '" with globalConfig = ' . $example['globalConfig'] . ' && product config = ' . $product->getAttribute('guest_checkout')); + $I->setConfigData(['catalog.products.guest-checkout.allow-guest-checkout' => $example['globalConfig']]); + $I->assertEquals( + $example['globalConfig'], + core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout') + ); + $I->amOnRoute('shop.home.index'); + $I->sendAjaxPostRequest('/checkout/cart/add/' . $product->id, [ + '_token' => session('_token'), + 'product_id' => $product->id, + 'quantity' => 1 + ]); - // $I->amOnRoute('shop.checkout.cart.index'); - // $I->see('Shopping Cart', '//div[@class="title"]'); - // $I->makeHtmlSnapshot('guestCheckout_' . $example['globalConfig'] . '_' . $product->getAttribute('guest_checkout')); - // $I->see($product->name, '//div[@class="item-title"]'); - // $I->click(__('shop::app.checkout.cart.proceed-to-checkout'), - // '//a[@href="' . route('shop.checkout.onepage.index') . '"]'); - // $I->seeCurrentRouteIs($example['expectedRoute']); - // $cart = cart()->getCart(); - // $I->assertTrue(cart()->removeItem($cart->items[0]->id)); + $I->amOnRoute('shop.checkout.cart.index'); + $I->see('Shopping Cart', '//div[@class="title"]'); + $I->makeHtmlSnapshot('guestCheckout_' . $example['globalConfig'] . '_' . $product->getAttribute('guest_checkout')); + $I->see($product->name, '//div[@class="item-title"]'); + $I->click( + __('shop::app.checkout.cart.proceed-to-checkout'), + '//a[@href="' . route('shop.checkout.onepage.index') . '"]' + ); + $I->seeCurrentRouteIs($example['expectedRoute']); + $cart = cart()->getCart(); + $I->assertTrue(cart()->removeItem($cart->items[0]->id)); } protected function guestCheckoutProvider(): array @@ -108,4 +112,4 @@ class GuestCheckoutCest ], ]; } -} \ No newline at end of file +} diff --git a/tests/functional/Shop/ProductControllerCest.php b/tests/functional/Shop/ProductControllerCest.php index 45382a4ca..c69ba2fec 100644 --- a/tests/functional/Shop/ProductControllerCest.php +++ b/tests/functional/Shop/ProductControllerCest.php @@ -2,7 +2,6 @@ namespace Tests\Functional\Shop; - use Faker\Factory; use Faker\Generator; use FunctionalTester; diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php index 1e329e9f6..a30c036b1 100644 --- a/tests/unit/Tax/Helpers/TaxCest.php +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -2,12 +2,12 @@ namespace Tests\Unit\Tax\Helpers; -use Illuminate\Support\Facades\Config; +use Cart; use UnitTester; -use Webkul\Tax\Models\TaxCategory; use Webkul\Tax\Models\TaxMap; use Webkul\Tax\Models\TaxRate; -use Cart; +use Webkul\Tax\Models\TaxCategory; +use Illuminate\Support\Facades\Config; class TaxCest {