Esempio n. 1
0
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
  *
  * @return void
  */
 public function checkPreConditions(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer)
 {
     if ($quoteTransfer->getCustomer() !== null && $quoteTransfer->getCustomer()->getIdCustomer() !== null) {
         return;
     }
     if ($quoteTransfer->getCustomer()->getIsGuest() === true) {
         return;
     }
     if ($this->customer->hasEmail($quoteTransfer->getCustomer()->getEmail())) {
         $checkoutErrorTransfer = $this->createCheckoutErrorTransfer();
         $checkoutErrorTransfer->setErrorCode(CheckoutConstants::ERROR_CODE_CUSTOMER_ALREADY_REGISTERED)->setMessage('Email already taken');
         $checkoutResponseTransfer->setIsSuccess(false)->addError($checkoutErrorTransfer);
     }
 }
 /**
  * @return void
  */
 public function testPostConditionChangeErrorRouteIfResponseFalseAndErrorCodeMatches()
 {
     $checkoutResponseTransfer = new CheckoutResponseTransfer();
     $checkoutResponseTransfer->setIsSuccess(false);
     $checkoutErrorTransfer = new CheckoutErrorTransfer();
     $checkoutErrorTransfer->setErrorCode(static::ERROR_CODE_123);
     $checkoutResponseTransfer->addError($checkoutErrorTransfer);
     $checkoutClientMock = $this->getCheckoutClientMock();
     $checkoutClientMock->method('placeOrder')->willReturn($checkoutResponseTransfer);
     $abstractPlaceOrderStepMock = $this->getAbstractPlaceOrderStep($checkoutClientMock);
     $quoteTransfer = new QuoteTransfer();
     $quoteTransfer->setOrderReference(self::ORDER_REFERENCE);
     $abstractPlaceOrderStepMock->execute($this->getRequest(), $quoteTransfer);
     $this->assertFalse($abstractPlaceOrderStepMock->postCondition($quoteTransfer));
     $this->assertSame(self::ESCAPE_ROUTE_123, $abstractPlaceOrderStepMock->getPostConditionErrorRoute());
 }
 /**
  * @return \Generated\Shared\Transfer\CheckoutResponseTransfer
  */
 private function getCheckoutResponseTransfer()
 {
     $checkoutResponseTransfer = new CheckoutResponseTransfer();
     $checkoutResponseTransfer->setIsSuccess(true);
     $saveOrderTransfer = new SaveOrderTransfer();
     $saveOrderTransfer->setIdSalesOrder(23);
     $checkoutResponseTransfer->setSaveOrder($saveOrderTransfer);
     return $checkoutResponseTransfer;
 }