Updated from some -dev modules to alpha, beta or full releases
[yaffs-website] / vendor / psy / psysh / test / Exception / ErrorExceptionTest.php
index 2fd9ab7ffaac735947936ae8dd96918517d45c75..e66319b919b37249ac9e0f9ea026362f46ebd6f8 100644 (file)
@@ -59,12 +59,15 @@ class ErrorExceptionTest extends \PHPUnit\Framework\TestCase
     public function getLevels()
     {
         return [
-            [E_WARNING,         'Warning'],
-            [E_CORE_WARNING,    'Warning'],
-            [E_COMPILE_WARNING, 'Warning'],
-            [E_USER_WARNING,    'Warning'],
-            [E_STRICT,          'Strict error'],
-            [0,                 'Error'],
+            [E_WARNING,           'Warning'],
+            [E_CORE_WARNING,      'Warning'],
+            [E_COMPILE_WARNING,   'Warning'],
+            [E_USER_WARNING,      'Warning'],
+            [E_STRICT,            'Strict error'],
+            [E_DEPRECATED,        'Deprecated'],
+            [E_USER_DEPRECATED,   'Deprecated'],
+            [E_RECOVERABLE_ERROR, 'Recoverable fatal error'],
+            [0,                   'Error'],
         ];
     }
 
@@ -104,4 +107,19 @@ class ErrorExceptionTest extends \PHPUnit\Framework\TestCase
         $e = new ErrorException('{{message}}', 0, 1, '/fake/path/to/Psy/File.php');
         $this->assertNotEmpty($e->getFile());
     }
+
+    public function testFromError()
+    {
+        if (version_compare(PHP_VERSION, '7.0.0', '<')) {
+            $this->markTestSkipped();
+        }
+
+        $error = new \Error('{{message}}', 0);
+        $exception = ErrorException::fromError($error);
+
+        $this->assertContains('PHP Error:  {{message}}', $exception->getMessage());
+        $this->assertEquals(0, $exception->getCode());
+        $this->assertEquals($error->getFile(), $exception->getFile());
+        $this->assertSame($exception->getPrevious(), $error);
+    }
 }