Author: Arnaud Langlade (arn0d.dev@gmail.com)
コード例 #1
0
ファイル: PaymentContext.php プロジェクト: ahmadrabie/Sylius
 /**
  * @Transform /^"([^"]+)" payment(s)?$/
  */
 public function getPaymentMethodByName($paymentMethodName)
 {
     $paymentMethod = $this->paymentMethodRepository->findOneByName($paymentMethodName);
     if (null === $paymentMethod) {
         throw new \InvalidArgumentException(sprintf('Payment method with name "%s" does not exist.', $paymentMethodName));
     }
     return $paymentMethod;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getDefaultPaymentMethod(PaymentInterface $payment)
 {
     $paymentMethods = $this->paymentMethodRepository->findBy(['enabled' => true]);
     if (empty($paymentMethods)) {
         throw new UnresolvedDefaultPaymentMethodException();
     }
     return $paymentMethods[0];
 }
コード例 #3
0
ファイル: PaymentContext.php プロジェクト: ahmadrabie/Sylius
 /**
  * @Given the store allows paying :paymentMethodName
  * @Given the store allows paying with :paymentMethodName
  */
 public function storeAllowsPaying($paymentMethodName)
 {
     $paymentMethod = $this->paymentMethodFactory->createNew();
     $paymentMethod->setCode('PM_' . $paymentMethodName);
     $paymentMethod->setName(ucfirst($paymentMethodName));
     $paymentMethod->setGateway($this->paymentMethodNameToGatewayConverter->convert($paymentMethodName));
     $paymentMethod->setDescription('Payment method');
     $channel = $this->sharedStorage->get('channel');
     $channel->addPaymentMethod($paymentMethod);
     $this->paymentMethodRepository->add($paymentMethod);
 }
コード例 #4
0
 /**
  * @param string $name
  * @param string $code
  * @param bool $addForCurrentChannel
  * @param string $description
  */
 private function createPaymentMethodFromNameAndCode($name, $code, $description = '', $addForCurrentChannel = true)
 {
     /** @var PaymentMethodInterface $paymentMethod */
     $paymentMethod = $this->paymentMethodFactory->createNew();
     $paymentMethod->setName(ucfirst($name));
     $paymentMethod->setCode($code);
     $paymentMethod->setGateway($this->paymentMethodNameToGatewayConverter->convert($name));
     $paymentMethod->setDescription($description);
     if ($addForCurrentChannel && $this->sharedStorage->has('channel')) {
         $channel = $this->sharedStorage->get('channel');
         $channel->addPaymentMethod($paymentMethod);
     }
     $this->sharedStorage->set('payment_method', $paymentMethod);
     $this->paymentMethodRepository->add($paymentMethod);
 }
コード例 #5
0
 function it_throws_exception_if_there_are_no_enabled_payment_methods(PaymentMethodRepositoryInterface $paymentMethodRepository, PaymentInterface $payment)
 {
     $paymentMethodRepository->findBy(['enabled' => true])->willReturn([]);
     $this->shouldThrow(UnresolvedDefaultPaymentMethodException::class)->during('getDefaultPaymentMethod', [$payment]);
 }
コード例 #6
0
ファイル: PaymentContext.php プロジェクト: polisys/Sylius
 /**
  * @Given the store has a payment method :paymentMethodName with a code :paymentMethodCode
  */
 public function theStoreHasAPaymentMethodWithACode($paymentMethodName, $paymentMethodCode)
 {
     $paymentMethod = $this->createPaymentMethodFromNameAndCode($paymentMethodName, $paymentMethodCode);
     $this->sharedStorage->set('payment_method', $paymentMethod);
     $this->paymentMethodRepository->add($paymentMethod);
 }
コード例 #7
0
 /**
  * @Transform /^"([^"]+)" payment(s)?$/
  * @Transform :paymentMethod
  */
 public function getPaymentMethodByName($paymentMethodName)
 {
     $paymentMethod = $this->paymentMethodRepository->findOneByName($paymentMethodName);
     Assert::notNull($paymentMethod, sprintf('Payment method with name "%s" does not exist', $paymentMethodName));
     return $paymentMethod;
 }
コード例 #8
0
 /**
  * @Transform :paymentMethod
  */
 public function getPaymentMethodByName($name)
 {
     $paymentMethod = $this->paymentMethodRepository->findOneByName($name);
     Assert::notNull($paymentMethod, sprintf('Cannot find payment method named %s', $name));
     return $paymentMethod;
 }
コード例 #9
0
 function it_throws_element_not_found_exception_if_payment_method_has_not_been_found(PaymentMethodRepositoryInterface $paymentMethodRepository)
 {
     $paymentMethodRepository->findOneByName('Free')->willReturn(null);
     $this->shouldThrow(\InvalidArgumentException::class)->during('getPaymentMethodByName', ['Free']);
 }
コード例 #10
0
 /**
  * @Transform /^"([^"]+)" payment(s)?$/
  * @Transform :paymentMethod
  */
 public function getPaymentMethodByName($paymentMethodName)
 {
     $paymentMethods = $this->paymentMethodRepository->findByName($paymentMethodName, 'en_US');
     Assert::eq(1, count($paymentMethods), sprintf('%d payment methods has been found with name "%s".', count($paymentMethods), $paymentMethodName));
     return $paymentMethods[0];
 }