/** * 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('getOrderIdField')->willReturn('sfo.entity_id'); $this->invoiceGridMock->expects($this->once())->method('getOrderIdField')->willReturn('sfo.entity_id'); $this->shipmentGridMock->expects($this->once())->method('getOrderIdField')->willReturn('sfo.entity_id'); $this->creditmemoGridMock->expects($this->once())->method('getOrderIdField')->willReturn('sfo.entity_id'); $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)); }
/** * Update related grid table after object save * * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb */ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { $resource = parent::_afterSave($object); if ($object->getParentId()) { $this->gridPool->refreshByOrderId($object->getParentId()); } return $resource; }
/** * Refresh addresses in grids according to performed changed * This is manual admin action, as result we perform this operation without delay * * @param EventObserver $observer * @return void */ public function execute(EventObserver $observer) { $this->gridPool->refreshByOrderId($observer->getOrderId()); }
public function testGridsReindex() { $this->eventObserverMock->expects($this->once())->method('getOrderId')->willReturn(100500); $this->gridPoolMock->expects($this->once())->method('refreshByOrderId')->with(100500); $this->assertNull($this->observer->execute($this->eventObserverMock)); }