Skip to content

Commit

Permalink
Fix API commands
Browse files Browse the repository at this point in the history
  • Loading branch information
marekrzytki committed May 14, 2024
1 parent 10930a3 commit 1d8594e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/Command/Wishlist/AddProductToWishlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 3 additions & 1 deletion src/Command/Wishlist/AddProductVariantToWishlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down

0 comments on commit 1d8594e

Please sign in to comment.