Esempio n. 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);
 }
Esempio n. 2
0
 /**
  * @Transform :customer
  */
 public function getOrCreateCustomerByEmail($email)
 {
     /** @var CustomerInterface $customer */
     $customer = $this->customerRepository->findOneBy(['email' => $email]);
     if (null === $customer) {
         $customer = $this->customerFactory->createNew();
         $customer->setEmail($email);
         $this->customerRepository->add($customer);
     }
     return $customer;
 }
Esempio n. 3
0
 function it_provides_new_customer_from_repository_if_it_exists(CustomerInterface $customer, CustomerRepositoryInterface $customerRepository)
 {
     $customerRepository->findOneBy(['email' => '*****@*****.**'])->willReturn($customer);
     $this->getOrCreateCustomerByEmail('*****@*****.**')->shouldReturn($customer);
 }