コード例 #1
0
ファイル: StateTest.php プロジェクト: nja78/magento2
 /**
  * test check order - set state processing
  */
 public function testCheckSetStateProcessing()
 {
     $this->orderMock->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->orderMock->expects($this->once())->method('isCanceled')->will($this->returnValue(false));
     $this->orderMock->expects($this->once())->method('canUnhold')->will($this->returnValue(false));
     $this->orderMock->expects($this->once())->method('canInvoice')->will($this->returnValue(false));
     $this->orderMock->expects($this->once())->method('canShip')->will($this->returnValue(true));
     $this->orderMock->expects($this->once())->method('getState')->will($this->returnValue(Order::STATE_NEW));
     $this->orderMock->expects($this->once())->method('getIsInProcess')->will($this->returnValue(true));
     $this->orderMock->expects($this->once())->method('setState')->with(Order::STATE_PROCESSING)->will($this->returnSelf());
     $this->assertEquals($this->state, $this->state->check($this->orderMock));
 }
コード例 #2
0
 public function testSave()
 {
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
     $this->adapterMock->expects($this->any())->method('quoteInto');
     $this->adapterMock->expects($this->any())->method('describeTable')->will($this->returnValue([]));
     $this->adapterMock->expects($this->any())->method('update');
     $this->adapterMock->expects($this->any())->method('lastInsertId');
     $this->addressHandlerMock->expects($this->once())->method('removeEmptyAddresses')->with($this->equalTo($this->orderMock))->will($this->returnSelf());
     $this->stateHandlerMock->expects($this->once())->method('check')->with($this->equalTo($this->orderMock))->will($this->returnSelf());
     $this->orderMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->orderMock->expects($this->once())->method('getRelatedObjects')->willReturn([]);
     $this->resource->save($this->orderMock);
 }
コード例 #3
0
ファイル: Order.php プロジェクト: kid17/magento2
 /**
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order $object */
     $this->stateHandler->check($object);
     if (!$object->getId()) {
         /** @var \Magento\Store\Model\Store $store */
         $store = $object->getStore();
         $name = [$store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()];
         $object->setStoreName(implode(PHP_EOL, $name));
         $object->setTotalItemCount($this->calculateItems($object));
     }
     $object->setData('protect_code', substr(md5(uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6));
     $isNewCustomer = !$object->getCustomerId() || $object->getCustomerId() === true;
     if ($isNewCustomer && $object->getCustomer()) {
         $object->setCustomerId($object->getCustomer()->getId());
     }
     return parent::_beforeSave($object);
 }
コード例 #4
0
ファイル: Order.php プロジェクト: niranjanssiet/magento2
 /**
  * {@inheritdoc}
  */
 public function save(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order $object */
     $this->stateHandler->check($object);
     return parent::save($object);
 }