Skip to content

Commit

Permalink
Added validation and behat
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafal Malenta committed Mar 6, 2023
1 parent fa4d552 commit b974fe1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions features/adding_wishlist_product_to_cart.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ Feature: Adding wishlist product to cart
And I check "Bushmills Black Bush Whiskey"
And I add selected products to cart
Then I should be notified that I should add more products

@ui
Scenario: Adding more than available in stock wishlist products to cart
Given the store has a product "Jack Daniels Gentleman" priced at "$10.00"
And all store products appear under a main taxonomy
And the store has a product "Bushmills Black Bush Whiskey" priced at "$230.00"
And there is 1 units of product "Bushmills Black Bush Whiskey" available in the inventory
And the "Bushmills Black Bush Whiskey" product is tracked by the inventory
And I have these products in my wishlist
When I go to the wishlist page
And I select 6 quantity of "Bushmills Black Bush Whiskey" product
And I check "Bushmills Black Bush Whiskey"
And I add selected products to cart
Then I should be notified that "Bushmills Black Bush Whiskey" does not have sufficient stock
2 changes: 2 additions & 0 deletions src/Form/Type/AddProductsToCartType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Valid;

final class AddProductsToCartType extends AbstractType
{
Expand Down Expand Up @@ -56,6 +57,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void

$form
->add('cartItem', AddToCartType::class, [
'constraints'=> new Valid(),
'label' => false,
'required' => false,
'product' => $wishlistProduct->getProduct(),
Expand Down

0 comments on commit b974fe1

Please sign in to comment.