Ejemplo n.º 1
0
 /**
  * @param string $stateName
  *
  * @return \Orm\Zed\Oms\Persistence\SpyOmsOrderItemState
  */
 public function getStateEntity($stateName)
 {
     if (array_key_exists($stateName, self::$stateEntityBuffer)) {
         return self::$stateEntityBuffer[$stateName];
     }
     $stateEntity = SpyOmsOrderItemStateQuery::create()->findOneByName($stateName);
     if (!isset($stateEntity)) {
         $stateEntity = new SpyOmsOrderItemState();
         $stateEntity->setName($stateName);
         $stateEntity->save();
     }
     $stateBuffer[$stateName] = $stateEntity;
     return $stateEntity;
 }
Ejemplo n.º 2
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem
  * @param string $stateName
  *
  * @return void
  */
 protected function setState($orderItem, $stateName)
 {
     if (isset($this->states[$stateName])) {
         $state = $this->states[$stateName];
     } else {
         $state = SpyOmsOrderItemStateQuery::create()->findOneByName($stateName);
         if (!isset($state)) {
             $state = new SpyOmsOrderItemState();
             $state->setName($stateName);
             $state->save();
         }
         $this->states[$stateName] = $state;
     }
     $orderItem->setState($state);
 }
Ejemplo n.º 3
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.º 4
0
 /**
  * @return \Orm\Zed\Oms\Persistence\SpyOmsOrderItemStateQuery
  */
 public function createOmsOrderItemStateQuery()
 {
     return SpyOmsOrderItemStateQuery::create();
 }