Esempio n. 1
0
 /**
  * Registers a error handler.
  *
  * @param integer $level
  *
  * @return ErrorHandler
  */
 private static function registerErrorHandler($level)
 {
     return ErrorHandler::register(new ErrorFactory(), $level);
 }
Esempio n. 2
0
 public function testHandleMultiple()
 {
     $that = $this;
     $errorCheck = function ($exception) use($that) {
         $that->assertInstanceOf('\\ErrorException', $exception);
         $that->assertEquals(E_ERROR, $exception->getSeverity());
         $that->assertEquals('foo.php', $exception->getFile());
         $that->assertEquals(13, $exception->getLine());
         $that->assertEquals('bar', $exception->getMessage());
     };
     $exceptionCheck = function ($exception) use($that) {
         $that->assertInstanceOf('\\Exception', $exception);
         $that->assertEquals(__FILE__, $exception->getFile());
         $that->assertEquals(__LINE__ + 10, $exception->getLine());
         $that->assertEquals('foo', $exception->getMessage());
     };
     $factory = $this->getErrorFactoryMock();
     $factory->expects($this->at(0))->method('createError')->will($this->returnCallback($errorCheck));
     $factory->expects($this->at(1))->method('createError')->will($this->returnCallback($exceptionCheck));
     $handler = ErrorHandler::register($factory);
     $handler->handleError(E_ERROR, 'bar', 'foo.php', 13);
     $handler->handleException(new \Exception('foo'));
     $this->assertCount(2, $handler->getErrors());
 }