sarga/tests/functional/Checkout/Cart/CartCest.php

68 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Functional\Checkout\Cart;
use FunctionalTester;
use Helper\Bagisto;
class CartCest
{
public $cart;
2022-07-11 12:21:33 +00:00
public $productWithQuantityBox;
2022-07-11 12:21:33 +00:00
public $productWithoutQuantityBox;
2020-06-11 12:23:34 +00:00
public function _before(FunctionalTester $I): void
{
$productConfig = [
'productAttributes' => [],
2022-07-11 12:21:33 +00:00
'productInventory' => [
'qty' => 10,
],
2022-07-11 12:21:33 +00:00
'attributeValues' => [
'status' => 1,
],
];
2022-07-11 12:21:33 +00:00
$this->productWithQuantityBox = $I->haveProduct(Bagisto::SIMPLE_PRODUCT, $productConfig);
2022-07-11 12:21:33 +00:00
$this->productWithoutQuantityBox = $I->haveProduct(Bagisto::DOWNLOADABLE_PRODUCT, $productConfig);
}
2020-06-11 12:23:34 +00:00
public function checkCartWithQuantityBox(FunctionalTester $I): void
{
2020-06-11 12:23:34 +00:00
$I->useDefaultTheme();
2022-07-11 12:21:33 +00:00
cart()->deactivateCurrentCartIfBuyNowIsActive();
2020-06-11 12:23:34 +00:00
cart()->addProduct($this->productWithQuantityBox->id, [
'_token' => session('_token'),
2020-01-28 15:32:55 +00:00
'product_id' => $this->productWithQuantityBox->id,
'quantity' => 1,
]);
$I->amOnPage('/checkout/cart');
2022-07-11 12:21:33 +00:00
2021-04-13 11:58:51 +00:00
$I->seeElement('#update_cart_button');
}
2020-06-11 12:23:34 +00:00
public function checkCartWithoutQuantityBox(FunctionalTester $I): void
{
2021-04-13 11:58:51 +00:00
$I->useDefaultTheme();
2020-06-11 12:23:34 +00:00
cart()->addProduct($this->productWithoutQuantityBox->id, [
'_token' => session('_token'),
'product_id' => $this->productWithoutQuantityBox->id,
'links' => $this->productWithoutQuantityBox->downloadable_links->pluck('id')->all(),
'quantity' => 1,
]);
$I->amOnPage('/checkout/cart');
2022-07-11 12:21:33 +00:00
$I->dontSeeElement('#update_cart_button');
}
2021-04-13 11:58:51 +00:00
}