gridAggregatorMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\GridInterface::class) ->getMockForAbstractClass(); $this->salesModelMock = $this->getMockBuilder(\Magento\Sales\Model\AbstractModel::class) ->disableOriginalConstructor() ->setMethods( [ 'getId' ] ) ->getMockForAbstractClass(); $this->scopeConfigurationMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); $this->unit = new \Magento\Sales\Model\GridAsyncInsert( $this->gridAggregatorMock, $this->scopeConfigurationMock ); } public function testAsyncInsert() { $this->scopeConfigurationMock->expects($this->once()) ->method('getValue') ->with('dev/grid/async_indexing', 'default', null) ->willReturn(true); $this->gridAggregatorMock->expects($this->once()) ->method('refreshBySchedule'); $this->unit->asyncInsert(); } public function testAsyncInsertDisabled() { $this->scopeConfigurationMock->expects($this->once()) ->method('getValue') ->with('dev/grid/async_indexing', 'default', null) ->willReturn(false); $this->gridAggregatorMock->expects($this->never()) ->method('refreshBySchedule'); $this->unit->asyncInsert(); } }