/** * test _beforeSaveMethod via save() */ public function testSave() { $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->addressMock))->will($this->returnValue([])); $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->addressMock)->willReturn(true); $this->addressMock->expects($this->exactly(3))->method('getParentId')->will($this->returnValue(1)); $this->gridPoolMock->expects($this->once())->method('refreshByOrderId')->with($this->equalTo(1))->will($this->returnSelf()); $this->addressResource->save($this->addressMock); }
/** * Test method refreshByOrderId() */ public function testRefreshByOrderId() { $orderId = 1; $this->orderGridMock->expects($this->once())->method('refresh')->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id'))->will($this->returnValue($this->statementMock)); $this->invoiceGridMock->expects($this->once())->method('refresh')->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id'))->will($this->returnValue($this->statementMock)); $this->shipmentGridMock->expects($this->once())->method('refresh')->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id'))->will($this->returnValue($this->statementMock)); $this->creditmemoGridMock->expects($this->once())->method('refresh')->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id'))->will($this->returnValue($this->statementMock)); $this->assertEquals($this->gridPool, $this->gridPool->refreshByOrderId($orderId)); }
/** * test _beforeSaveMethod via save() */ public function testSave() { $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->addressMock))->will($this->returnValue([])); $this->addressMock->expects($this->once())->method('hasDataChanges')->will($this->returnValue(true)); $this->addressMock->expects($this->exactly(2))->method('getOrderId')->will($this->returnValue(2)); $this->gridPoolMock->expects($this->once())->method('refreshByOrderId')->with($this->equalTo(2))->will($this->returnSelf()); $this->addressResource->save($this->addressMock); $this->assertTrue(true); }
/** * Update related grid table after object save * * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object * @return \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { $resource = parent::_afterSave($object); if ($object->getOrderId()) { $this->gridPool->refreshByOrderId($object->getOrderId()); } return $resource; }