/**
  * The shutdown can display an error that is handled by it, e.g E_PARSE.
  *
  * @uses Evoke\View\HTML5\Error
  */
 public function testShutdownUsefulHandler()
 {
     // Set an error handler to allow an appropriate error to be injected
     // so that we can test the shutdown handler.
     set_error_handler(function ($errNo, $errStr) {
         return true;
     });
     $responseIndex = 0;
     $response = $this->createMock('Evoke\\Network\\HTTP\\ResponseIface');
     $response->expects($this->at($responseIndex++))->method('setStatus')->with(500);
     $response->expects($this->at($responseIndex++))->method('setBody')->with('Writer Output');
     $response->expects($this->at($responseIndex++))->method('send');
     $viewErrorIndex = 0;
     $viewError = $this->createMock('Evoke\\View\\HTML5\\Error');
     $viewError->expects($this->at($viewErrorIndex++))->method('set');
     $viewError->expects($this->at($viewErrorIndex++))->method('get')->will($this->returnValue(['div', [], 'View Error']));
     $viewMessageBoxIndex = 0;
     $viewMessageBox = $this->createMock('Evoke\\View\\HTML5\\MessageBox');
     $viewMessageBox->expects($this->at($viewMessageBoxIndex++))->method('setTitle')->with('Fatal Error');
     $viewMessageBox->expects($this->at($viewMessageBoxIndex++))->method('addContent')->with(['p', ['class' => 'Description'], 'This is an error that we were unable to handle.  Please ' . 'tell us any information that could help us avoid this ' . 'error in the future.  Useful information such as the ' . 'date, time and what you were doing when the error ' . 'occurred should help us fix this.']);
     $viewMessageBox->expects($this->at($viewMessageBoxIndex++))->method('addContent')->with(['div', ['class' => 'Contact'], 'Contact: mail@example.com']);
     $viewMessageBox->expects($this->at($viewMessageBoxIndex++))->method('addContent')->with(['div', [], 'View Error']);
     $viewMessageBox->expects($this->at($viewMessageBoxIndex++))->method('get')->will($this->returnValue('View Message Box Output'));
     $writerIndex = 0;
     $writer = $this->createMock('Evoke\\Writer\\WriterIface');
     $writer->expects($this->at($writerIndex++))->method('write')->with('View Message Box Output');
     $writer->expects($this->at($writerIndex++))->method('__toString')->will($this->returnValue('Writer Output'));
     $object = new ShutdownHandler('*****@*****.**', $response, true, $viewMessageBox, $writer, $viewError);
     uopz_set_return('error_get_last', ['type' => E_COMPILE_ERROR]);
     $object->handler();
     uopz_unset_return('error_get_last');
     restore_error_handler();
 }
Example #2
0
 protected function restoreHeaderFunctions()
 {
     uopz_unset_return('headers_sent');
     uopz_unset_return('header');
 }