add functional test for cart, fix tests with usage of

This commit is contained in:
Steffen Mahler 2020-01-28 16:28:29 +01:00
parent 0d696c6b1a
commit d3e00d4543
5 changed files with 53 additions and 8 deletions

View File

@ -108,7 +108,7 @@
<a href="{{ route('shop.home.index') }}" class="link">{{ __('shop::app.checkout.cart.continue-shopping') }}</a>
<div>
@if (! $cart->hasProductsWithQuantityBox())
@if ($cart->hasProductsWithQuantityBox())
<button type="submit" class="btn btn-lg btn-primary" id="update_cart_button">
{{ __('shop::app.checkout.cart.update-cart') }}
</button>

View File

@ -7,6 +7,7 @@ use Faker\Factory;
use Webkul\Attribute\Models\Attribute;
use Webkul\Attribute\Models\AttributeFamily;
use Webkul\Attribute\Models\AttributeOption;
use Webkul\Core\Helpers\Laravel5Helper;
use Webkul\Core\Models\Locale;
use Webkul\Product\Models\Product;
use Webkul\Product\Models\ProductAttributeValue;
@ -56,7 +57,7 @@ class ProductCest
public function testIndex(FunctionalTester $I): void
{
$product = $I->haveProduct([], ['simple']);
$product = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, [], ['simple']);
$I->loginAsAdmin();
$I->amOnAdminRoute('admin.dashboard.index');

View File

@ -4,6 +4,7 @@ namespace Tests\Functional\Admin\Customer;
use FunctionalTester;
use Webkul\Core\Helpers\Laravel5Helper;
use Webkul\Product\Models\ProductReview;
@ -11,7 +12,7 @@ class ReviewCest
{
public function testIndex(FunctionalTester $I): void
{
$product = $I->haveProduct([], ['simple']);
$product = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, [], ['simple']);
$review = $I->have(ProductReview::class, ['product_id' => $product->id]);
$I->loginAsAdmin();

View File

@ -3,11 +3,54 @@
namespace Tests\Functional\Checkout\Cart;
use FunctionalTester;
use Webkul\Core\Helpers\Laravel5Helper;
use Cart;
class CartCest
{
public $cart;
public $productWithQuantityBox;
public $productWithoutQuantityBox;
public function _before(FunctionalTester $I)
{
$productConfig = [
'productAttributes' => [],
'productInventory' => [
'qty' => 10,
],
'attributeValues' => [
'status' => 1,
],
];
$this->productWithQuantityBox = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $productConfig);
$this->productWithoutQuantityBox = $I->haveProduct(Laravel5Helper::DOWNLOADABLE_PRODUCT, $productConfig);
}
public function checkCartWithQuantityBox(FunctionalTester $I)
{
Cart::addProduct($this->productWithQuantityBox->id, [
'_token' => session('_token'),
'product_id' => $this->productWithoutQuantityBox->id,
'links' => $this->productWithoutQuantityBox->downloadable_links->pluck('id')->all(),
'quantity' => 1,
]);
$I->amOnPage('/checkout/cart');
$I->seeElement('#update_cart_button');
}
public function checkCartWithoutQuantityBox(FunctionalTester $I)
{
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');
$I->dontSeeElement('#update_cart_button');
}
}

View File

@ -40,19 +40,19 @@ class CartModelCest
{
$I->wantTo('check function with cart, that contains a product with QuantityBox() == false');
$this->cart = Cart::addProduct($this->productWithoutQuantityBox->id, [
'_token' => session('_token'),
'_token' => session('_token'),
'product_id' => $this->productWithoutQuantityBox->id,
'links' => $this->productWithoutQuantityBox->downloadable_links->pluck('id')->all(),
'quantity' => 1,
'links' => $this->productWithoutQuantityBox->downloadable_links->pluck('id')->all(),
'quantity' => 1,
]);
$cartItemIdOfProductWithoutQuantityBox = $this->cart->items[0]->id;
$I->assertFalse(Cart::getCart()->hasProductsWithQuantityBox());
$I->wantTo('check function with cart, that is mixed');
Cart::addProduct($this->productWithQuantityBox->id, [
'_token' => session('_token'),
'_token' => session('_token'),
'product_id' => $this->productWithQuantityBox->id,
'quantity' => 1,
'quantity' => 1,
]);
$I->assertTrue(Cart::getCart()->hasProductsWithQuantityBox());