Example #1
0
 /**
  * @Transform /^this order made by "([^"]+)"$/
  */
 public function getOrderByCustomer($email)
 {
     $customer = $this->customerRepository->findOneBy(['email' => $email]);
     Assert::notNull($customer, sprintf('Cannot find customer with email %s.', $email));
     $orders = $this->orderRepository->findByCustomer($customer);
     Assert::notEmpty($orders);
     return end($orders);
 }
Example #2
0
 function it_throws_runtime_exception_if_cannot_find_last_order_for_given_customer(SharedStorageInterface $sharedStorage, OrderRepositoryInterface $orderRepository, UserInterface $user, CustomerInterface $customer)
 {
     $sharedStorage->get('user')->willReturn($user);
     $user->getCustomer()->willReturn($customer);
     $orderRepository->findByCustomer($customer)->willReturn([]);
     $this->shouldThrow(\RuntimeException::class)->during('iTryToPayAgain');
 }
Example #3
0
 /**
  * @return OrderInterface
  *
  * @throws \RuntimeException
  */
 private function getLastOrder()
 {
     $customer = $this->sharedStorage->get('user')->getCustomer();
     $orders = $this->orderRepository->findByCustomer($customer);
     $lastOrder = end($orders);
     if (false === $lastOrder) {
         throw new \RuntimeException(sprintf('There is no last order for %s', $customer->getFullName()));
     }
     return $lastOrder;
 }