public function testCatchExceptionDeveloperMode() { $bootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock(); $bootstrap->expects($this->once())->method('isDeveloperMode')->willReturn(true); $exception = new \Exception('Error: nothing works'); $this->response->expects($this->once())->method('setHttpResponseCode')->with(404); $this->response->expects($this->once())->method('sendResponse'); $this->assertTrue($this->object->catchException($bootstrap, $exception)); }
public function testCatchException() { $bootstrap = $this->getMock('Magento\\Framework\\App\\Bootstrap', [], [], '', false); $bootstrap->expects($this->at(0))->method('isDeveloperMode')->willReturn(false); $bootstrap->expects($this->at(1))->method('isDeveloperMode')->willReturn(true); $exception = new \Exception('message'); $this->response->expects($this->exactly(2))->method('setHttpResponseCode')->with(404); $this->response->expects($this->exactly(2))->method('setHeader')->with('Content-Type', 'text/plain'); $this->response->expects($this->exactly(2))->method('sendResponse'); $this->response->expects($this->once())->method('setBody')->with($this->stringStartsWith('message')); $this->assertTrue($this->object->catchException($bootstrap, $exception)); $this->assertTrue($this->object->catchException($bootstrap, $exception)); }
/** * @param string $mode * @param string $requestedPath * @param string $expectedModule * @param bool $moduleExists * @param string $expectedFile * @param array $expectedParams * * @dataProvider launchDataProvider */ public function testLaunch($mode, $requestedPath, $expectedModule, $moduleExists, $expectedFile, array $expectedParams) { $this->state->expects($this->once())->method('getMode')->will($this->returnValue($mode)); $this->state->expects($this->once())->method('setAreaCode')->with('area'); $this->configLoader->expects($this->once())->method('load')->with('area')->will($this->returnValue(array('config'))); $this->objectManager->expects($this->once())->method('configure')->with(array('config')); $this->request->expects($this->once())->method('get')->with('resource')->will($this->returnValue($requestedPath)); $this->moduleList->expects($this->any())->method('getModule')->with($expectedModule)->will($this->returnValue($moduleExists)); $asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface'); $asset->expects($this->once())->method('getSourceFile')->will($this->returnValue('resource/file.css')); $this->assetRepo->expects($this->once())->method('createAsset')->with($expectedFile, $expectedParams)->will($this->returnValue($asset)); $this->publisher->expects($this->once())->method('publish')->with($asset); $this->response->expects($this->once())->method('setFilePath')->with('resource/file.css'); $this->object->launch(); }