public function testExecuteWithException() { $objectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock(); $this->transactionMock->expects($this->once())->method('getResponseObject')->willReturn($objectMock); $this->responseValidatorMock->expects($this->once())->method('validate')->with($objectMock, $this->payflowFacade)->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('Error'))); $this->coreRegistryMock->expects($this->once())->method('register')->with('transparent_form_params', $this->arrayHasKey('error')); $this->resultLayoutMock->expects($this->once())->method('addDefaultHandle')->willReturnSelf(); $this->resultLayoutMock->expects($this->once())->method('getLayout')->willReturn($this->getLayoutMock()); $this->assertInstanceOf('\\Magento\\Framework\\Controller\\ResultInterface', $this->object->execute()); }