public function testExecuteWithoutFormKey() { /** @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */ $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock(); $this->resultFactoryMock->expects($this->once())->method('create')->willReturnMap([[\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT, [], $redirectMock]]); $this->validatorMock->expects($this->once())->method('validate')->with($this->requestMock)->willReturn(false); $redirectMock->expects($this->once())->method('setPath')->with('sendfriend/product/send', ['_current' => true])->willReturnSelf(); $this->assertEquals($redirectMock, $this->model->execute()); }