Skip to content

Commit

Permalink
fixed phpspec for PickupCartHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
arti0090 committed Dec 1, 2020
1 parent 8b8a629 commit c87076e
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Prophecy\Argument;
use Sylius\Bundle\ApiBundle\Command\Cart\PickupCart;
use Sylius\Bundle\ApiBundle\Context\UserContextInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\OrderInterface;
Expand All @@ -35,15 +35,15 @@ final class PickupCartHandlerSpec extends ObjectBehavior
function let(
FactoryInterface $cartFactory,
OrderRepositoryInterface $cartRepository,
ChannelContextInterface $channelContext,
ChannelRepositoryInterface $channelRepository,
UserContextInterface $userContext,
ObjectManager $orderManager,
RandomnessGeneratorInterface $generator
): void {
$this->beConstructedWith(
$cartFactory,
$cartRepository,
$channelContext,
$channelRepository,
$userContext,
$orderManager,
$generator
Expand All @@ -58,7 +58,7 @@ function it_is_a_message_handler(): void
function it_picks_up_a_new_cart_for_logged_in_shop_user(
FactoryInterface $cartFactory,
OrderRepositoryInterface $cartRepository,
ChannelContextInterface $channelContext,
ChannelRepositoryInterface $channelRepository,
UserContextInterface $userContext,
ShopUserInterface $user,
CustomerInterface $customer,
Expand All @@ -69,7 +69,10 @@ function it_picks_up_a_new_cart_for_logged_in_shop_user(
CurrencyInterface $currency,
LocaleInterface $locale
): void {
$channelContext->getChannel()->willReturn($channel);
$pickupCart = new PickupCart();
$pickupCart->setChannelCode('code');

$channelRepository->findOneByCode('code')->willReturn($channel);
$channel->getBaseCurrency()->willReturn($currency);
$channel->getDefaultLocale()->willReturn($locale);

Expand All @@ -91,21 +94,24 @@ function it_picks_up_a_new_cart_for_logged_in_shop_user(

$orderManager->persist($cart)->shouldBeCalled();

$this(new PickupCart());
$this($pickupCart);
}

function it_picks_up_an_existing_cart_for_logged_in_shop_user(
FactoryInterface $cartFactory,
OrderRepositoryInterface $cartRepository,
ChannelContextInterface $channelContext,
ChannelRepositoryInterface $channelRepository,
UserContextInterface $userContext,
ShopUserInterface $user,
CustomerInterface $customer,
ObjectManager $orderManager,
OrderInterface $cart,
ChannelInterface $channel
): void {
$channelContext->getChannel()->willReturn($channel);
$pickupCart = new PickupCart();
$pickupCart->setChannelCode('code');

$channelRepository->findOneByCode('code')->willReturn($channel);

$userContext->getUser()->willReturn($user);
$user->getCustomer()->willReturn($customer);
Expand All @@ -118,13 +124,13 @@ function it_picks_up_an_existing_cart_for_logged_in_shop_user(

$orderManager->persist($cart)->shouldNotBeCalled();

$this(new PickupCart());
$this($pickupCart);
}

function it_picks_up_a_cart_for_visitor(
FactoryInterface $cartFactory,
OrderRepositoryInterface $cartRepository,
ChannelContextInterface $channelContext,
ChannelRepositoryInterface $channelRepository,
UserContextInterface $userContext,
ObjectManager $orderManager,
RandomnessGeneratorInterface $generator,
Expand All @@ -133,7 +139,10 @@ function it_picks_up_a_cart_for_visitor(
CurrencyInterface $currency,
LocaleInterface $locale
): void {
$channelContext->getChannel()->willReturn($channel);
$pickupCart = new PickupCart();
$pickupCart->setChannelCode('code');

$channelRepository->findOneByCode('code')->willReturn($channel);
$channel->getBaseCurrency()->willReturn($currency);
$channel->getDefaultLocale()->willReturn($locale);

Expand All @@ -154,6 +163,6 @@ function it_picks_up_a_cart_for_visitor(

$orderManager->persist($cart)->shouldBeCalled();

$this(new PickupCart());
$this($pickupCart);
}
}

0 comments on commit c87076e

Please sign in to comment.