コード例 #1
0
 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));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Requested path 'short/path.js' is wrong
  */
 public function testLaunchWrongPath()
 {
     $this->state->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER));
     $this->request->expects($this->once())->method('get')->with('resource')->will($this->returnValue('short/path.js'));
     $this->object->launch();
 }