/** * @dataProvider testExecuteDataProvider */ public function testExecute($invoice) { $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') ->disableOriginalConstructor() ->getMock(); $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View') ->disableOriginalConstructor() ->getMock(); $this->requestMock->expects($this->any()) ->method('getParam') ->withAnyParameters() ->willReturnArgument(0); $this->loaderMock->expects($this->once()) ->method('load') ->willReturn($this->creditmemoMock); $this->creditmemoMock->expects($this->any()) ->method('getInvoice') ->willReturn($invoice); $layoutMock->expects($this->once()) ->method('getBlock') ->with('sales_creditmemo_view') ->willReturn($blockMock); $this->resultPageFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->atLeastOnce()) ->method('getLayout') ->willReturn($layoutMock); $this->resultPageMock->expects($this->once()) ->method('setActiveMenu') ->with('Magento_Sales::sales_creditmemo') ->willReturnSelf(); $this->resultPageMock->expects($this->atLeastOnce()) ->method('getConfig') ->willReturn($this->pageConfigMock); $this->assertInstanceOf( 'Magento\Backend\Model\View\Result\Page', $this->controller->executeInternal() ); }