/** * Perform actions before object save * * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object * @return $this */ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) { if ($object instanceof EntityInterface && $object->getIncrementId() == null) { $object->setIncrementId($this->salesIncrement->getNextValue($object->getStoreId())); } parent::_beforeSave($object); return $this; }
public function testNextValue() { $this->type->expects($this->once())->method('fetchNewIncrementId')->with(1)->willReturn(2); $this->eavConfig->expects($this->once())->method('getEntityType')->with('order')->willReturn($this->type); $this->assertEquals(2, $this->model->getNextValue(1)); }