From 1d8594e82cf3acc503f5aa1cd5961f090a61d782 Mon Sep 17 00:00:00 2001 From: Marek Rzytki Date: Tue, 14 May 2024 09:07:09 +0200 Subject: [PATCH] Fix API commands --- .../Wishlist/AddProductToWishlistHandlerSpec.php | 6 ++++-- .../Wishlist/AddProductVariantToWishlistHandlerSpec.php | 6 ++++-- src/Command/Wishlist/AddProductToWishlist.php | 4 +++- src/Command/Wishlist/AddProductVariantToWishlist.php | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/spec/CommandHandler/Wishlist/AddProductToWishlistHandlerSpec.php b/spec/CommandHandler/Wishlist/AddProductToWishlistHandlerSpec.php index 008de160..a7c37b82 100644 --- a/spec/CommandHandler/Wishlist/AddProductToWishlistHandlerSpec.php +++ b/spec/CommandHandler/Wishlist/AddProductToWishlistHandlerSpec.php @@ -59,7 +59,8 @@ public function it_adds_product_to_wishlist( $wishlistManager->persist($wishlistProduct)->shouldBeCalled(); $wishlistManager->flush()->shouldBeCalled(); - $addProductToWishlist = new AddProductToWishlist(1, $wishlist->getWrappedObject()); + $addProductToWishlist = new AddProductToWishlist(1); + $addProductToWishlist->setWishlist($wishlist->getWrappedObject()); $this->__invoke($addProductToWishlist); } @@ -81,7 +82,8 @@ public function it_doesnt_add_product_to_wishlist_if_product_isnt_found( $wishlistManager->persist($wishlistProduct)->shouldNotBeCalled(); $wishlistManager->flush()->shouldNotBeCalled(); - $addProductToWishlist = new AddProductToWishlist(1, $wishlist->getWrappedObject()); + $addProductToWishlist = new AddProductToWishlist(1); + $addProductToWishlist->setWishlist($wishlist->getWrappedObject()); $this ->shouldThrow(ProductNotFoundException::class) diff --git a/spec/CommandHandler/Wishlist/AddProductVariantToWishlistHandlerSpec.php b/spec/CommandHandler/Wishlist/AddProductVariantToWishlistHandlerSpec.php index e43a9cb5..b2c3563b 100644 --- a/spec/CommandHandler/Wishlist/AddProductVariantToWishlistHandlerSpec.php +++ b/spec/CommandHandler/Wishlist/AddProductVariantToWishlistHandlerSpec.php @@ -58,7 +58,8 @@ public function it_adds_product_variant_to_wishlist( $wishlistManager->persist($wishlist)->shouldBeCalled(); $wishlistManager->flush()->shouldBeCalled(); - $addProductVariantToWishlist = new AddProductVariantToWishlist(1, $wishlist->getWrappedObject()); + $addProductVariantToWishlist = new AddProductVariantToWishlist(1); + $addProductVariantToWishlist->setWishlist($wishlist->getWrappedObject()); $this->__invoke($addProductVariantToWishlist); } @@ -80,7 +81,8 @@ public function it_doesnt_add_product_variant_to_wishlist_if_variant_isnt_found( $wishlistManager->persist($wishlistProduct)->shouldNotBeCalled(); $wishlistManager->flush()->shouldNotBeCalled(); - $addProductVariantToWishlist = new AddProductVariantToWishlist(1, $wishlist->getWrappedObject()); + $addProductVariantToWishlist = new AddProductVariantToWishlist(1); + $addProductVariantToWishlist->setWishlist($wishlist->getWrappedObject()); $this ->shouldThrow(ProductVariantNotFoundException::class) diff --git a/src/Command/Wishlist/AddProductToWishlist.php b/src/Command/Wishlist/AddProductToWishlist.php index c4f9e263..367dba58 100644 --- a/src/Command/Wishlist/AddProductToWishlist.php +++ b/src/Command/Wishlist/AddProductToWishlist.php @@ -15,7 +15,9 @@ final class AddProductToWishlist implements WishlistTokenValueAwareInterface { - public function __construct(public int $productId, private WishlistInterface $wishlist) + private WishlistInterface $wishlist; + + public function __construct(public int $productId) { } diff --git a/src/Command/Wishlist/AddProductVariantToWishlist.php b/src/Command/Wishlist/AddProductVariantToWishlist.php index e1a5f208..b7df6138 100644 --- a/src/Command/Wishlist/AddProductVariantToWishlist.php +++ b/src/Command/Wishlist/AddProductVariantToWishlist.php @@ -15,7 +15,9 @@ final class AddProductVariantToWishlist implements WishlistTokenValueAwareInterface { - public function __construct(public int $productVariantId, private WishlistInterface $wishlist) + private WishlistInterface $wishlist; + + public function __construct(public int $productVariantId) { }