diff options
| author | Greg Roach <fisharebest@gmail.com> | 2018-05-31 09:45:16 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2018-05-31 09:57:27 +0100 |
| commit | ffe6005c11fdad01969e67c039b0d73beb0232e9 (patch) | |
| tree | 6d8df2e00473a813fef26155db549f9a969092f7 /vendor/symfony/debug/Tests | |
| parent | bba27599b02e0b6f90f62348bb4fa32bd74056d0 (diff) | |
| download | webtrees-ffe6005c11fdad01969e67c039b0d73beb0232e9.tar.gz webtrees-ffe6005c11fdad01969e67c039b0d73beb0232e9.tar.bz2 webtrees-ffe6005c11fdad01969e67c039b0d73beb0232e9.zip | |
Update minimum PHP version to 7.0.8 so that we can use the 3.4 LTS version of symfony
Diffstat (limited to 'vendor/symfony/debug/Tests')
15 files changed, 352 insertions, 19 deletions
diff --git a/vendor/symfony/debug/Tests/DebugClassLoaderTest.php b/vendor/symfony/debug/Tests/DebugClassLoaderTest.php index f1e3fb7c61..0219f53350 100644 --- a/vendor/symfony/debug/Tests/DebugClassLoaderTest.php +++ b/vendor/symfony/debug/Tests/DebugClassLoaderTest.php @@ -59,6 +59,23 @@ class DebugClassLoaderTest extends TestCase $this->fail('DebugClassLoader did not register'); } + /** + * @expectedException \Exception + * @expectedExceptionMessage boo + */ + public function testThrowingClass() + { + try { + class_exists(__NAMESPACE__.'\Fixtures\Throwing'); + $this->fail('Exception expected'); + } catch (\Exception $e) { + $this->assertSame('boo', $e->getMessage()); + } + + // the second call also should throw + class_exists(__NAMESPACE__.'\Fixtures\Throwing'); + } + public function testUnsilencing() { if (\PHP_VERSION_ID >= 70000) { @@ -124,6 +141,7 @@ class DebugClassLoaderTest extends TestCase /** * @expectedException \RuntimeException + * @expectedExceptionMessage Case mismatch between loaded and declared class names */ public function testNameCaseMismatch() { @@ -145,6 +163,7 @@ class DebugClassLoaderTest extends TestCase /** * @expectedException \RuntimeException + * @expectedExceptionMessage Case mismatch between loaded and declared class names */ public function testPsr4CaseMismatch() { @@ -312,6 +331,42 @@ class DebugClassLoaderTest extends TestCase $this->assertSame($xError, $lastError); } + + public function testExtendedDeprecatedMethodDoesntTriggerAnyNotice() + { + set_error_handler(function () { return false; }); + $e = error_reporting(0); + trigger_error('', E_USER_NOTICE); + + class_exists('Test\\'.__NAMESPACE__.'\\ExtendsAnnotatedClass', true); + + error_reporting($e); + restore_error_handler(); + + $lastError = error_get_last(); + unset($lastError['file'], $lastError['line']); + + $this->assertSame(array('type' => E_USER_NOTICE, 'message' => ''), $lastError); + } + + public function testInternalsUse() + { + $deprecations = array(); + set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; }); + $e = error_reporting(E_USER_DEPRECATED); + + class_exists('Test\\'.__NAMESPACE__.'\\ExtendsInternals', true); + + error_reporting($e); + restore_error_handler(); + + $this->assertSame($deprecations, array( + 'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal since version 3.4. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', + 'The "Symfony\Component\Debug\Tests\Fixtures\InternalInterface" interface is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', + 'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait" trait is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', + 'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait2::internalMethod()" method is considered internal since version 3.4. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', + )); + } } class ClassLoader @@ -335,22 +390,12 @@ class ClassLoader eval('namespace '.__NAMESPACE__.'; class TestingStacking { function foo() {} }'); } elseif (__NAMESPACE__.'\TestingCaseMismatch' === $class) { eval('namespace '.__NAMESPACE__.'; class TestingCaseMisMatch {}'); - } elseif (__NAMESPACE__.'\Fixtures\CaseMismatch' === $class) { - return $fixtureDir.'CaseMismatch.php'; } elseif (__NAMESPACE__.'\Fixtures\Psr4CaseMismatch' === $class) { return $fixtureDir.'psr4'.DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php'; } elseif (__NAMESPACE__.'\Fixtures\NotPSR0' === $class) { return $fixtureDir.'reallyNotPsr0.php'; } elseif (__NAMESPACE__.'\Fixtures\NotPSR0bis' === $class) { return $fixtureDir.'notPsr0Bis.php'; - } elseif (__NAMESPACE__.'\Fixtures\DeprecatedInterface' === $class) { - return $fixtureDir.'DeprecatedInterface.php'; - } elseif (__NAMESPACE__.'\Fixtures\FinalClass' === $class) { - return $fixtureDir.'FinalClass.php'; - } elseif (__NAMESPACE__.'\Fixtures\FinalMethod' === $class) { - return $fixtureDir.'FinalMethod.php'; - } elseif (__NAMESPACE__.'\Fixtures\ExtendedFinalMethod' === $class) { - return $fixtureDir.'ExtendedFinalMethod.php'; } elseif ('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent' === $class) { eval('namespace Symfony\Bridge\Debug\Tests\Fixtures; class ExtendsDeprecatedParent extends \\'.__NAMESPACE__.'\Fixtures\DeprecatedClass {}'); } elseif ('Test\\'.__NAMESPACE__.'\DeprecatedParentClass' === $class) { @@ -363,6 +408,18 @@ class ClassLoader eval('namespace Test\\'.__NAMESPACE__.'; class Float {}'); } elseif ('Test\\'.__NAMESPACE__.'\ExtendsFinalClass' === $class) { eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsFinalClass extends \\'.__NAMESPACE__.'\Fixtures\FinalClass {}'); + } elseif ('Test\\'.__NAMESPACE__.'\ExtendsAnnotatedClass' === $class) { + eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsAnnotatedClass extends \\'.__NAMESPACE__.'\Fixtures\AnnotatedClass { + public function deprecatedMethod() { } + }'); + } elseif ('Test\\'.__NAMESPACE__.'\ExtendsInternals' === $class) { + eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternals extends ExtendsInternalsParent { + use \\'.__NAMESPACE__.'\Fixtures\InternalTrait; + + public function internalMethod() { } + }'); + } elseif ('Test\\'.__NAMESPACE__.'\ExtendsInternalsParent' === $class) { + eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternalsParent extends \\'.__NAMESPACE__.'\Fixtures\InternalClass implements \\'.__NAMESPACE__.'\Fixtures\InternalInterface { }'); } } } diff --git a/vendor/symfony/debug/Tests/ErrorHandlerTest.php b/vendor/symfony/debug/Tests/ErrorHandlerTest.php index a14accf3df..b354e641b4 100644 --- a/vendor/symfony/debug/Tests/ErrorHandlerTest.php +++ b/vendor/symfony/debug/Tests/ErrorHandlerTest.php @@ -35,7 +35,7 @@ class ErrorHandlerTest extends TestCase $newHandler = new ErrorHandler(); - $this->assertSame($newHandler, ErrorHandler::register($newHandler, false)); + $this->assertSame($handler, ErrorHandler::register($newHandler, false)); $h = set_error_handler('var_dump'); restore_error_handler(); $this->assertSame(array($handler, 'handleError'), $h); @@ -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(); @@ -98,8 +122,6 @@ class ErrorHandlerTest extends TestCase // dummy function to test trace in error handler. private static function triggerNotice($that) { - // dummy variable to check for in error handler. - $foobar = 123; $that->assertSame('', $foo.$foo.$bar); } @@ -301,6 +323,9 @@ class ErrorHandlerTest extends TestCase @$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array()); } + /** + * @group no-hhvm + */ public function testHandleException() { try { @@ -342,6 +367,9 @@ class ErrorHandlerTest extends TestCase } } + /** + * @group legacy + */ public function testErrorStacking() { try { @@ -422,6 +450,9 @@ class ErrorHandlerTest extends TestCase $handler->setLoggers(array(E_DEPRECATED => array($mockLogger, LogLevel::WARNING))); } + /** + * @group no-hhvm + */ public function testSettingLoggerWhenExceptionIsBuffered() { $bootLogger = new BufferingLogger(); @@ -441,6 +472,9 @@ class ErrorHandlerTest extends TestCase $handler->handleException($exception); } + /** + * @group no-hhvm + */ public function testHandleFatalError() { try { @@ -499,6 +533,9 @@ class ErrorHandlerTest extends TestCase $this->assertStringStartsWith("Attempted to load class \"Foo\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage()); } + /** + * @group no-hhvm + */ public function testHandleFatalErrorOnHHVM() { try { @@ -532,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()); + } } diff --git a/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php b/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php index e7762bdec8..66171e3ae7 100644 --- a/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php +++ b/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php @@ -111,7 +111,7 @@ class FlattenExceptionTest extends TestCase /** * @dataProvider flattenDataProvider */ - public function testFlattenHttpException(\Exception $exception, $statusCode) + public function testFlattenHttpException(\Exception $exception) { $flattened = FlattenException::create($exception); $flattened2 = FlattenException::create($exception); @@ -126,7 +126,7 @@ class FlattenExceptionTest extends TestCase /** * @dataProvider flattenDataProvider */ - public function testPrevious(\Exception $exception, $statusCode) + public function testPrevious(\Exception $exception) { $flattened = FlattenException::create($exception); $flattened2 = FlattenException::create($exception); @@ -173,7 +173,7 @@ class FlattenExceptionTest extends TestCase /** * @dataProvider flattenDataProvider */ - public function testToArray(\Exception $exception, $statusCode) + public function testToArray(\Exception $exception) { $flattened = FlattenException::create($exception); $flattened->setTrace(array(), 'foo.php', 123); @@ -193,7 +193,7 @@ class FlattenExceptionTest extends TestCase public function flattenDataProvider() { return array( - array(new \Exception('test', 123), 500), + array(new \Exception('test', 123)), ); } @@ -261,6 +261,7 @@ class FlattenExceptionTest extends TestCase public function testRecursionInArguments() { + $a = null; $a = array('foo', array(2, &$a)); $exception = $this->createException($a); diff --git a/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php b/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php new file mode 100644 index 0000000000..dff9517d0a --- /dev/null +++ b/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php @@ -0,0 +1,13 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +class AnnotatedClass +{ + /** + * @deprecated since version 3.4. + */ + public function deprecatedMethod() + { + } +} diff --git a/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php b/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php index b4c78cd140..51fde5af8a 100644 --- a/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php +++ b/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Debug\Tests\Fixtures; /** * @deprecated but this is a test - * deprecation notice. + * deprecation notice * @foobar */ class DeprecatedClass diff --git a/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php b/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php index 505eccae75..6bab62f956 100644 --- a/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php +++ b/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Debug\Tests\Fixtures; /** * @deprecated but this is a test - * deprecation notice. + * deprecation notice * @foobar */ interface DeprecatedInterface diff --git a/vendor/symfony/debug/Tests/Fixtures/InternalClass.php b/vendor/symfony/debug/Tests/Fixtures/InternalClass.php new file mode 100644 index 0000000000..119842c260 --- /dev/null +++ b/vendor/symfony/debug/Tests/Fixtures/InternalClass.php @@ -0,0 +1,15 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +/** + * @internal since version 3.4. + */ +class InternalClass +{ + use InternalTrait2; + + public function usedInInternalClass() + { + } +} diff --git a/vendor/symfony/debug/Tests/Fixtures/InternalInterface.php b/vendor/symfony/debug/Tests/Fixtures/InternalInterface.php new file mode 100644 index 0000000000..dd79f501e8 --- /dev/null +++ b/vendor/symfony/debug/Tests/Fixtures/InternalInterface.php @@ -0,0 +1,10 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +/** + * @internal + */ +interface InternalInterface +{ +} diff --git a/vendor/symfony/debug/Tests/Fixtures/InternalTrait.php b/vendor/symfony/debug/Tests/Fixtures/InternalTrait.php new file mode 100644 index 0000000000..7bb4635cc4 --- /dev/null +++ b/vendor/symfony/debug/Tests/Fixtures/InternalTrait.php @@ -0,0 +1,10 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +/** + * @internal + */ +trait InternalTrait +{ +} diff --git a/vendor/symfony/debug/Tests/Fixtures/InternalTrait2.php b/vendor/symfony/debug/Tests/Fixtures/InternalTrait2.php new file mode 100644 index 0000000000..05f18e83e4 --- /dev/null +++ b/vendor/symfony/debug/Tests/Fixtures/InternalTrait2.php @@ -0,0 +1,23 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +/** + * @internal + */ +trait InternalTrait2 +{ + /** + * @internal since version 3.4 + */ + public function internalMethod() + { + } + + /** + * @internal but should not trigger a deprecation + */ + public function usedInInternalClass() + { + } +} diff --git a/vendor/symfony/debug/Tests/Fixtures/Throwing.php b/vendor/symfony/debug/Tests/Fixtures/Throwing.php new file mode 100644 index 0000000000..21e0aba17d --- /dev/null +++ b/vendor/symfony/debug/Tests/Fixtures/Throwing.php @@ -0,0 +1,3 @@ +<?php + +throw new \Exception('boo'); diff --git a/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt b/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt new file mode 100644 index 0000000000..b9d3d72887 --- /dev/null +++ b/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test DebugClassLoader with previously loaded parents +--FILE-- +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +use Symfony\Component\Debug\DebugClassLoader; + +$vendor = __DIR__; +while (!file_exists($vendor.'/vendor')) { + $vendor = dirname($vendor); +} +require $vendor.'/vendor/autoload.php'; + +class_exists(FinalMethod::class); + +set_error_handler(function ($type, $msg) { echo $msg, "\n"; }); + +DebugClassLoader::enable(); + +class_exists(ExtendedFinalMethod::class); + +?> +--EXPECTF-- +The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod". diff --git a/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt b/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt new file mode 100644 index 0000000000..7ce7b9dc6f --- /dev/null +++ b/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test catching fatal errors when handlers are nested +--FILE-- +<?php + +namespace Symfony\Component\Debug; + +$vendor = __DIR__; +while (!file_exists($vendor.'/vendor')) { + $vendor = dirname($vendor); +} +require $vendor.'/vendor/autoload.php'; + +set_error_handler('var_dump'); +set_exception_handler('var_dump'); + +ErrorHandler::register(null, false); + +if (true) { + class foo extends missing + { + } +} + +?> +--EXPECTF-- +Fatal error: Class 'Symfony\Component\Debug\missing' not found in %s on line %d +object(Symfony\Component\Debug\Exception\ClassNotFoundException)#%d (8) { + ["message":protected]=> + string(131) "Attempted to load class "missing" from namespace "Symfony\Component\Debug". +Did you forget a "use" statement for another namespace?" + ["string":"Exception":private]=> + string(0) "" + ["code":protected]=> + int(0) + ["file":protected]=> + string(%d) "%s" + ["line":protected]=> + int(%d) + ["trace":"Exception":private]=> + array(0) { + } + ["previous":"Exception":private]=> + NULL + ["severity":protected]=> + int(1) +} diff --git a/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt b/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt new file mode 100644 index 0000000000..9df0a65cf7 --- /dev/null +++ b/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test rethrowing in custom exception handler +--FILE-- +<?php + +namespace Symfony\Component\Debug; + +$vendor = __DIR__; +while (!file_exists($vendor.'/vendor')) { + $vendor = dirname($vendor); +} +require $vendor.'/vendor/autoload.php'; + +if (true) { + class TestLogger extends \Psr\Log\AbstractLogger + { + public function log($level, $message, array $context = array()) + { + echo $message, "\n"; + } + } +} + +set_exception_handler(function ($e) { echo 123; throw $e; }); +ErrorHandler::register()->setDefaultLogger(new TestLogger()); +ini_set('display_errors', 1); + +throw new \Exception('foo'); +?> +--EXPECTF-- +Uncaught Exception: foo +123 +Fatal error: Uncaught %s:25 +Stack trace: +%a diff --git a/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt b/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt new file mode 100644 index 0000000000..5c5245c069 --- /dev/null +++ b/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test catching fatal errors when handlers are nested +--FILE-- +<?php + +namespace Symfony\Component\Debug; + +$vendor = __DIR__; +while (!file_exists($vendor.'/vendor')) { + $vendor = dirname($vendor); +} +require $vendor.'/vendor/autoload.php'; + +Debug::enable(); +ini_set('display_errors', 0); + +$eHandler = set_error_handler('var_dump'); +$xHandler = set_exception_handler('var_dump'); + +var_dump(array( + $eHandler[0] === $xHandler[0] ? 'Error and exception handlers do match' : 'Error and exception handlers are different', +)); + +$eHandler[0]->setExceptionHandler('print_r'); + +if (true) { + class Broken implements \Serializable + { + } +} + +?> +--EXPECTF-- +array(1) { + [0]=> + string(37) "Error and exception handlers do match" +} +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)" +%a +} |
