Ejemplo n.º 1
0
 /**
  * @return void
  */
 public function testSaveOrderCreatesAndFillsOrderItems()
 {
     $quoteTransfer = $this->getValidBaseQuoteTransfer();
     $initialState = SpyOmsOrderItemStateQuery::create()->filterByName(OmsConstants::INITIAL_STATUS)->findOneOrCreate();
     $initialState->save();
     $this->assertNotNull($initialState->getIdOmsOrderItemState());
     $item1 = new ItemTransfer();
     $item1->setName('item-test-1')->setSku('sku1')->setUnitGrossPrice(120)->setQuantity(2)->setTaxRate(19);
     $item2 = new ItemTransfer();
     $item2->setName('item-test-2')->setSku('sku2')->setUnitGrossPrice(130)->setQuantity(3)->setTaxRate(19);
     $quoteTransfer->addItem($item1);
     $quoteTransfer->addItem($item2);
     $item1Query = SpySalesOrderItemQuery::create()->filterByName('item-test-1');
     $item2Query = SpySalesOrderItemQuery::create()->filterByName('item-test-2');
     $checkoutResponseTransfer = $this->getValidBaseResponseTransfer();
     $this->salesFacade->saveOrder($quoteTransfer, $checkoutResponseTransfer);
     $savedItems = $checkoutResponseTransfer->getSaveOrder()->getOrderItems();
     $item1Entity = $item1Query->findOne();
     $item2Entity = $item2Query->findOne();
     $this->assertNotNull($item1Entity);
     $this->assertNotNull($item2Entity);
     $this->assertSame($savedItems[1]->getIdSalesOrderItem(), $item1Entity->getIdSalesOrderItem());
     $this->assertSame($item1->getName(), $item1Entity->getName());
     $this->assertSame($checkoutResponseTransfer->getSaveOrder()->getIdSalesOrder(), $item1Entity->getFkSalesOrder());
     $this->assertSame($initialState->getIdOmsOrderItemState(), $item1Entity->getFkOmsOrderItemState());
     $this->assertSame($item1->getSku(), $item1Entity->getSku());
     $this->assertSame($savedItems[1]->getUnitGrossPrice(), $item1Entity->getGrossPrice());
     $this->assertSame(1, $item1Entity->getQuantity());
     $this->assertSame($savedItems[3]->getIdSalesOrderItem(), $item2Entity->getIdSalesOrderItem());
     $this->assertSame($item2->getName(), $item2Entity->getName());
     $this->assertSame($checkoutResponseTransfer->getSaveOrder()->getIdSalesOrder(), $item2Entity->getFkSalesOrder());
     $this->assertSame($initialState->getIdOmsOrderItemState(), $item2Entity->getFkOmsOrderItemState());
     $this->assertSame($item2->getSku(), $item2Entity->getSku());
     $this->assertSame($savedItems[3]->getUnitGrossPrice(), $item2Entity->getGrossPrice());
     $this->assertSame(1, $item2Entity->getQuantity());
 }
Ejemplo n.º 2
0
 /**
  * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
  *
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 private function getQuoteTransfer(CheckoutResponseTransfer $checkoutResponseTransfer)
 {
     $orderEntity = $this->createOrderEntity();
     $paymentAddressTransfer = new AddressTransfer();
     $email = '*****@*****.**';
     $paymentAddressTransfer->setIso2Code('DE')->setEmail($email)->setFirstName('John')->setLastName('Doe')->setCellPhone('+40 175 0815')->setPhone('+30 0815')->setAddress1('Straße des 17. Juni')->setAddress2('135')->setZipCode('10623')->setSalutation(SpyPaymentPayolutionTableMap::COL_SALUTATION_MR)->setCity('Berlin');
     $payolutionPaymentTransfer = new PayolutionPaymentTransfer();
     $payolutionPaymentTransfer->setEmail($email)->setGender(SpyPaymentPayolutionTableMap::COL_GENDER_MALE)->setDateOfBirth('1970-01-02')->setClientIp('127.0.0.1')->setAccountBrand(PayolutionConstants::BRAND_INVOICE)->setLanguageIso2Code('DE')->setCurrencyIso3Code('EUR')->setAddress($paymentAddressTransfer);
     $quoteTransfer = new QuoteTransfer();
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setEmail($email);
     $customerTransfer->setIsGuest(true);
     $quoteTransfer->setCustomer($customerTransfer);
     $checkoutResponseTransfer->getSaveOrder()->setIdSalesOrder($orderEntity->getIdSalesOrder());
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPayolution($payolutionPaymentTransfer);
     $quoteTransfer->setPayment($paymentTransfer);
     foreach ($orderEntity->getItems() as $orderItemEntity) {
         $itemTransfer = new ItemTransfer();
         $itemTransfer->setName($orderItemEntity->getName())->setQuantity($orderItemEntity->getQuantity())->setUnitGrossPrice($orderItemEntity->getGrossPrice())->setFkSalesOrder($orderItemEntity->getFkSalesOrder())->setIdSalesOrderItem($orderItemEntity->getIdSalesOrderItem());
         $checkoutResponseTransfer->getSaveOrder()->addOrderItem($itemTransfer);
     }
     return $quoteTransfer;
 }