function it_throws_cart_not_found_exception_and_removes_id_from_session_when_cart_was_not_found(SessionInterface $session, CartRepositoryInterface $cartRepository, ChannelContextInterface $channelContext, ChannelInterface $channel)
 {
     $channelContext->getChannel()->willReturn($channel);
     $channel->getCode()->willReturn('Poland');
     $session->has('session_key_name.Poland')->willReturn(true);
     $session->get('session_key_name.Poland')->willReturn(12345);
     $cartRepository->findCartByIdAndChannel(12345, $channel)->willReturn(null);
     $session->remove('session_key_name.Poland')->shouldBeCalled();
     $this->shouldThrow(CartNotFoundException::class)->during('getCart');
 }
 /**
  * {@inheritdoc}
  */
 public function getCart()
 {
     try {
         $channel = $this->channelContext->getChannel();
     } catch (ChannelNotFoundException $exception) {
         throw new CartNotFoundException($exception);
     }
     if (!$this->session->has(sprintf('%s.%s', $this->sessionKeyName, $channel->getCode()))) {
         throw new CartNotFoundException('Sylius was not able to find the cart in session');
     }
     $cart = $this->cartRepository->findCartByIdAndChannel($this->session->get(sprintf('%s.%s', $this->sessionKeyName, $channel->getCode())), $channel);
     if (null === $cart) {
         $this->session->remove(sprintf('%s.%s', $this->sessionKeyName, $channel->getCode()));
         throw new CartNotFoundException('Sylius was not able to find the cart in session');
     }
     return $cart;
 }