summaryrefslogtreecommitdiff
path: root/vendor/symfony/debug/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/debug/Tests')
-rw-r--r--vendor/symfony/debug/Tests/DebugClassLoaderTest.php71
-rw-r--r--vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php35
-rw-r--r--vendor/symfony/debug/Tests/ExceptionHandlerTest.php11
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php13
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php8
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/VirtualClass.php11
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/VirtualClassMagicCall.php18
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/VirtualInterface.php34
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/VirtualSubInterface.php10
-rw-r--r--vendor/symfony/debug/Tests/Fixtures/VirtualTrait.php10
-rw-r--r--vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt4
11 files changed, 222 insertions, 3 deletions
diff --git a/vendor/symfony/debug/Tests/DebugClassLoaderTest.php b/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
index da02cf855f..6ee20ae8a7 100644
--- a/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
+++ b/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
@@ -294,6 +294,11 @@ class DebugClassLoaderTest extends TestCase
$this->assertSame([
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::quzMethod()" method will require a new "Quz $quz" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::whereAmI()" method will require a new "bool $matrix" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "$noType" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "callable(\Throwable|null $reason, mixed $value) $callback" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "string $param" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "callable ($a, $b) $anotherOne" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "Type$WithDollarIsStillAType $ccc" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::isSymfony()" method will require a new "true $yes" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
], $deprecations);
}
@@ -312,6 +317,46 @@ class DebugClassLoaderTest extends TestCase
$this->assertSame([], $deprecations);
}
+ public function testVirtualUse()
+ {
+ $deprecations = [];
+ set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
+ $e = error_reporting(E_USER_DEPRECATED);
+
+ class_exists('Test\\'.__NAMESPACE__.'\\ExtendsVirtual', true);
+
+ error_reporting($e);
+ restore_error_handler();
+
+ $this->assertSame([
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::sameLineInterfaceMethodNoBraces()".',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::newLineInterfaceMethod()": Some description!',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::newLineInterfaceMethodNoBraces()": Description.',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::invalidInterfaceMethod()".',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::invalidInterfaceMethodNoBraces()".',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::complexInterfaceMethod($arg, ...$args)".',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::complexInterfaceMethodTyped($arg, int ...$args)": Description ...',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "static Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::staticMethodNoBraces()".',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "static Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::staticMethodTyped(int $arg)": Description.',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtualParent" should implement method "static Symfony\Component\Debug\Tests\Fixtures\VirtualInterface::staticMethodTypedNoBraces()".',
+ 'Class "Test\Symfony\Component\Debug\Tests\ExtendsVirtual" should implement method "Symfony\Component\Debug\Tests\Fixtures\VirtualSubInterface::subInterfaceMethod()".',
+ ], $deprecations);
+ }
+
+ public function testVirtualUseWithMagicCall()
+ {
+ $deprecations = [];
+ set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
+ $e = error_reporting(E_USER_DEPRECATED);
+
+ class_exists('Test\\'.__NAMESPACE__.'\\ExtendsVirtualMagicCall', true);
+
+ error_reporting($e);
+ restore_error_handler();
+
+ $this->assertSame([], $deprecations);
+ }
+
public function testEvaluatedCode()
{
$this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\DefinitionInEvaluatedCode', true));
@@ -372,6 +417,32 @@ class ClassLoader
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternalsParent extends \\'.__NAMESPACE__.'\Fixtures\InternalClass implements \\'.__NAMESPACE__.'\Fixtures\InternalInterface { }');
} elseif ('Test\\'.__NAMESPACE__.'\UseTraitWithInternalMethod' === $class) {
eval('namespace Test\\'.__NAMESPACE__.'; class UseTraitWithInternalMethod { use \\'.__NAMESPACE__.'\Fixtures\TraitWithInternalMethod; }');
+ } elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtual' === $class) {
+ eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsVirtual extends ExtendsVirtualParent implements \\'.__NAMESPACE__.'\Fixtures\VirtualSubInterface {
+ public function ownClassMethod() { }
+ public function classMethod() { }
+ public function sameLineInterfaceMethodNoBraces() { }
+ }');
+ } elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtualParent' === $class) {
+ eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsVirtualParent extends ExtendsVirtualAbstract {
+ public function ownParentMethod() { }
+ public function traitMethod() { }
+ public function sameLineInterfaceMethod() { }
+ public function staticMethodNoBraces() { } // should be static
+ }');
+ } elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtualAbstract' === $class) {
+ eval('namespace Test\\'.__NAMESPACE__.'; abstract class ExtendsVirtualAbstract extends ExtendsVirtualAbstractBase {
+ public static function staticMethod() { }
+ public function ownAbstractMethod() { }
+ public function interfaceMethod() { }
+ }');
+ } elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtualAbstractBase' === $class) {
+ eval('namespace Test\\'.__NAMESPACE__.'; abstract class ExtendsVirtualAbstractBase extends \\'.__NAMESPACE__.'\Fixtures\VirtualClass implements \\'.__NAMESPACE__.'\Fixtures\VirtualInterface {
+ public function ownAbstractBaseMethod() { }
+ }');
+ } elseif ('Test\\'.__NAMESPACE__.'\ExtendsVirtualMagicCall' === $class) {
+ eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsVirtualMagicCall extends \\'.__NAMESPACE__.'\Fixtures\VirtualClassMagicCall implements \\'.__NAMESPACE__.'\Fixtures\VirtualInterface {
+ }');
}
}
}
diff --git a/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php b/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php
index eb884b51c1..e86210b903 100644
--- a/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php
+++ b/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php
@@ -346,6 +346,41 @@ class FlattenExceptionTest extends TestCase
$this->assertSame('Class "RuntimeException@anonymous" blah.', $flattened->getMessage());
}
+ public function testToStringEmptyMessage()
+ {
+ $exception = new \RuntimeException();
+
+ $flattened = FlattenException::create($exception);
+
+ $this->assertSame($exception->getTraceAsString(), $flattened->getTraceAsString());
+ $this->assertSame($exception->__toString(), $flattened->getAsString());
+ }
+
+ public function testToString()
+ {
+ $test = function ($a, $b, $c, $d) {
+ return new \RuntimeException('This is a test message');
+ };
+
+ $exception = $test('foo123', 1, null, 1.5);
+
+ $flattened = FlattenException::create($exception);
+
+ $this->assertSame($exception->getTraceAsString(), $flattened->getTraceAsString());
+ $this->assertSame($exception->__toString(), $flattened->getAsString());
+ }
+
+ public function testToStringParent()
+ {
+ $exception = new \LogicException('This is message 1');
+ $exception = new \RuntimeException('This is messsage 2', 500, $exception);
+
+ $flattened = FlattenException::create($exception);
+
+ $this->assertSame($exception->getTraceAsString(), $flattened->getTraceAsString());
+ $this->assertSame($exception->__toString(), $flattened->getAsString());
+ }
+
private function createException($foo)
{
return new \Exception();
diff --git a/vendor/symfony/debug/Tests/ExceptionHandlerTest.php b/vendor/symfony/debug/Tests/ExceptionHandlerTest.php
index e166136cbb..4910fe5ec9 100644
--- a/vendor/symfony/debug/Tests/ExceptionHandlerTest.php
+++ b/vendor/symfony/debug/Tests/ExceptionHandlerTest.php
@@ -48,8 +48,17 @@ class ExceptionHandlerTest extends TestCase
$handler->sendPhpResponse(new \RuntimeException('Foo'));
$response = ob_get_clean();
- $this->assertContains('Whoops, looks like something went wrong.', $response);
+ $this->assertContains('<h1 class="break-long-words exception-message">Foo</h1>', $response);
$this->assertContains('<div class="trace trace-as-html">', $response);
+
+ // taken from https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
+ $htmlWithXss = '<body onload=alert(\'test1\')> <b onmouseover=alert(\'Wufff!\')>click me!</b> <img src="j&#X41vascript:alert(\'test2\')"> <meta http-equiv="refresh"
+content="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgndGVzdDMnKTwvc2NyaXB0Pg">';
+ ob_start();
+ $handler->sendPhpResponse(new \RuntimeException($htmlWithXss));
+ $response = ob_get_clean();
+
+ $this->assertContains(sprintf('<h1 class="break-long-words exception-message">%s</h1>', htmlspecialchars($htmlWithXss, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8')), $response);
}
public function testStatusCode()
diff --git a/vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php b/vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php
index 54abd68efa..86593db124 100644
--- a/vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php
+++ b/vendor/symfony/debug/Tests/Fixtures/InterfaceWithAnnotatedParameters.php
@@ -11,4 +11,17 @@ interface InterfaceWithAnnotatedParameters
* @param bool $matrix
*/
public function whereAmI();
+
+ /**
+ * @param $noType
+ * @param callable(\Throwable|null $reason, mixed $value) $callback and a comment
+ * about this great param
+ * @param string $param (comment with $dollar)
+ * @param $defined
+ * @param callable ($a, $b) $anotherOne
+ * @param callable (mixed $a, $b) $definedCallable
+ * @param Type$WithDollarIsStillAType $ccc
+ * @param \JustAType
+ */
+ public function iAmHere();
}
diff --git a/vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php b/vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php
index 20358e96de..5d05d79835 100644
--- a/vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php
+++ b/vendor/symfony/debug/Tests/Fixtures/SubClassWithAnnotatedParameters.php
@@ -21,4 +21,12 @@ class SubClassWithAnnotatedParameters extends ClassWithAnnotatedParameters imple
public function whereAmI()
{
}
+
+ /**
+ * @param $defined
+ * @param Type\Does\Not\Matter $definedCallable
+ */
+ public function iAmHere()
+ {
+ }
}
diff --git a/vendor/symfony/debug/Tests/Fixtures/VirtualClass.php b/vendor/symfony/debug/Tests/Fixtures/VirtualClass.php
new file mode 100644
index 0000000000..25712519a5
--- /dev/null
+++ b/vendor/symfony/debug/Tests/Fixtures/VirtualClass.php
@@ -0,0 +1,11 @@
+<?php
+
+namespace Symfony\Component\Debug\Tests\Fixtures;
+
+/**
+ * @method string classMethod()
+ */
+class VirtualClass
+{
+ use VirtualTrait;
+}
diff --git a/vendor/symfony/debug/Tests/Fixtures/VirtualClassMagicCall.php b/vendor/symfony/debug/Tests/Fixtures/VirtualClassMagicCall.php
new file mode 100644
index 0000000000..de33e8afc5
--- /dev/null
+++ b/vendor/symfony/debug/Tests/Fixtures/VirtualClassMagicCall.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Symfony\Component\Debug\Tests\Fixtures;
+
+/**
+ * @method string magicMethod()
+ * @method static string staticMagicMethod()
+ */
+class VirtualClassMagicCall
+{
+ public static function __callStatic($name, $arguments)
+ {
+ }
+
+ public function __call($name, $arguments)
+ {
+ }
+}
diff --git a/vendor/symfony/debug/Tests/Fixtures/VirtualInterface.php b/vendor/symfony/debug/Tests/Fixtures/VirtualInterface.php
new file mode 100644
index 0000000000..943014eefb
--- /dev/null
+++ b/vendor/symfony/debug/Tests/Fixtures/VirtualInterface.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Symfony\Component\Debug\Tests\Fixtures;
+
+/**
+ * @method string interfaceMethod()
+ * @method sameLineInterfaceMethod($arg)
+ * @method sameLineInterfaceMethodNoBraces
+ *
+ * Ignored
+ * @method
+ * @method
+ *
+ * Not ignored
+ * @method newLineInterfaceMethod() Some description!
+ * @method \stdClass newLineInterfaceMethodNoBraces Description
+ *
+ * Invalid
+ * @method unknownType invalidInterfaceMethod()
+ * @method unknownType|string invalidInterfaceMethodNoBraces
+ *
+ * Complex
+ * @method complexInterfaceMethod($arg, ...$args)
+ * @method string[]|int complexInterfaceMethodTyped($arg, int ...$args) Description ...
+ *
+ * Static
+ * @method static Foo&Bar staticMethod()
+ * @method static staticMethodNoBraces
+ * @method static \stdClass staticMethodTyped(int $arg) Description
+ * @method static \stdClass[] staticMethodTypedNoBraces
+ */
+interface VirtualInterface
+{
+}
diff --git a/vendor/symfony/debug/Tests/Fixtures/VirtualSubInterface.php b/vendor/symfony/debug/Tests/Fixtures/VirtualSubInterface.php
new file mode 100644
index 0000000000..dee19731dc
--- /dev/null
+++ b/vendor/symfony/debug/Tests/Fixtures/VirtualSubInterface.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace Symfony\Component\Debug\Tests\Fixtures;
+
+/**
+ * @method string subInterfaceMethod()
+ */
+interface VirtualSubInterface extends VirtualInterface
+{
+}
diff --git a/vendor/symfony/debug/Tests/Fixtures/VirtualTrait.php b/vendor/symfony/debug/Tests/Fixtures/VirtualTrait.php
new file mode 100644
index 0000000000..f584a8aa8f
--- /dev/null
+++ b/vendor/symfony/debug/Tests/Fixtures/VirtualTrait.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace Symfony\Component\Debug\Tests\Fixtures;
+
+/**
+ * @method string traitMethod()
+ */
+trait VirtualTrait
+{
+}
diff --git a/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt b/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt
index b3f0e0eb09..1736a3b5f2 100644
--- a/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt
+++ b/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt
@@ -24,7 +24,7 @@ var_dump([
$eHandler[0]->setExceptionHandler('print_r');
if (true) {
- class Broken implements \Serializable
+ class Broken implements \JsonSerializable
{
}
}
@@ -37,6 +37,6 @@ array(1) {
}
object(Symfony\Component\Debug\Exception\FatalErrorException)#%d (%d) {
["message":protected]=>
- string(199) "Error: Class Symfony\Component\Debug\Broken contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize)"
+ string(179) "Error: Class Symfony\Component\Debug\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
%a
}