public function testExecute() { $response = 'output'; $this->requestMock->expects($this->any())->method('getParam')->withAnyParameters()->willReturnArgument(0); $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock(); $blockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Order\\Items')->disableOriginalConstructor()->setMethods([])->getMock(); $blockMock->expects($this->once())->method('toHtml')->willReturn($response); $layoutMock->expects($this->once())->method('getBlock')->with('order_items')->willReturn($blockMock); $this->viewMock->expects($this->once())->method('getLayout')->willReturn($layoutMock); $this->assertNull($this->controller->execute()); }
/** * Test execute * * @return void */ public function testExecute() { $response = 'output'; $this->requestMock->expects($this->any())->method('getParam')->withAnyParameters()->willReturnArgument(0); $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock(); $blockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Order\\Items')->disableOriginalConstructor()->getMock(); $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($layoutMock); $blockMock->expects($this->once())->method('toHtml')->willReturn($response); $layoutMock->expects($this->once())->method('getBlock')->with('order_items')->willReturn($blockMock); $this->resultRawFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRawMock); $this->resultRawMock->expects($this->once())->method('setContents')->with($response)->willReturnSelf(); $this->assertInstanceOf('Magento\\Framework\\Controller\\Result\\Raw', $this->controller->execute()); }