public function testExecute() { $layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface'); $block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle\\Option\\Search\\Grid')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock(); $this->response->expects($this->once())->method('setBody')->willReturnSelf(); $this->request->expects($this->once())->method('getParam')->with('index')->willReturn('index'); $this->view->expects($this->once())->method('getLayout')->willReturn($layout); $layout->expects($this->once())->method('createBlock')->willReturn($block); $block->expects($this->once())->method('setIndex')->willReturnSelf(); $block->expects($this->once())->method('toHtml')->willReturnSelf(); $this->assertEquals($this->response, $this->controller->execute()); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid parameter "index" */ public function testExecuteWithException() { $this->request->expects($this->once())->method('getParam')->with('index')->willReturn('<index"'); $this->controller->execute(); }