Updating Media dependent modules to versions compatible with core Media.
[yaffs-website] / vendor / symfony / debug / Tests / ErrorHandlerTest.php
index 03dd8074121a7e93aeb1a883a19ad318be885f5c..b354e641b46fc3ffa23f29bdc72c858d32e3f5fd 100644 (file)
@@ -65,6 +65,30 @@ class ErrorHandlerTest extends TestCase
         }
     }
 
+    public function testErrorGetLast()
+    {
+        $handler = ErrorHandler::register();
+        $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+        $handler->setDefaultLogger($logger);
+        $handler->screamAt(E_ALL);
+
+        try {
+            @trigger_error('Hello', E_USER_WARNING);
+            $expected = array(
+                'type' => E_USER_WARNING,
+                'message' => 'Hello',
+                'file' => __FILE__,
+                'line' => __LINE__ - 5,
+            );
+            $this->assertSame($expected, error_get_last());
+        } catch (\Exception $e) {
+            restore_error_handler();
+            restore_exception_handler();
+
+            throw $e;
+        }
+    }
+
     public function testNotice()
     {
         ErrorHandler::register();
@@ -545,4 +569,18 @@ class ErrorHandlerTest extends TestCase
             restore_exception_handler();
         }
     }
+
+    /**
+     * @expectedException \Exception
+     * @group no-hhvm
+     */
+    public function testCustomExceptionHandler()
+    {
+        $handler = new ErrorHandler();
+        $handler->setExceptionHandler(function ($e) use ($handler) {
+            $handler->handleException($e);
+        });
+
+        $handler->handleException(new \Exception());
+    }
 }