Example #1
0
 /**
  * Tests that LoggingExceptions behave the same way as normal Exceptions
  * when no Logger instance has been registered.
  *
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testVanillaUsage()
 {
     $this->assertFalse(Exception::hasLogger());
     try {
         throw new Exception('This should behave as a normal exception');
     } catch (Exception $e) {
         /* There's no need to make any assertions about the exception's
            type, because we did so by catching it. */
         $this->assertEquals('This should behave as a normal exception', $e->getMessage());
     }
     try {
         throw new Exception('This should behave as a normal exception', 12345, new \Exception('And it should have a previous exception in the chain'));
     } catch (Exception $e) {
         $this->assertSame(12345, $e->getCode());
         $this->assertEquals('This should behave as a normal exception', $e->getMessage());
         $this->assertEquals('Exception', get_class($e->getPrevious()));
         $this->assertEquals('And it should have a previous exception in the chain', $e->getPrevious()->getMessage());
     }
 }