public function DebugClassLoaderTest::testStacking in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/debug/Tests/DebugClassLoaderTest.php \Symfony\Component\Debug\Tests\DebugClassLoaderTest::testStacking()
File
- vendor/
symfony/ debug/ Tests/ DebugClassLoaderTest.php, line 85
Class
Namespace
Symfony\Component\Debug\TestsCode
public function testStacking() {
// the ContextErrorException must not be loaded to test the workaround
// for https://bugs.php.net/65322.
if (class_exists('Symfony\\Component\\Debug\\Exception\\ContextErrorException', false)) {
$this
->markTestSkipped('The ContextErrorException class is already loaded.');
}
if (defined('HHVM_VERSION')) {
$this
->markTestSkipped('HHVM is not handled in this test case.');
}
ErrorHandler::register();
try {
// Trigger autoloading + E_STRICT at compile time
// which in turn triggers $errorHandler->handle()
// that again triggers autoloading for ContextErrorException.
// Error stacking works around the bug above and everything is fine.
eval('
namespace ' . __NAMESPACE__ . ';
class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
');
$this
->fail('ContextErrorException expected');
} catch (\ErrorException $exception) {
// if an exception is thrown, the test passed
restore_error_handler();
restore_exception_handler();
$this
->assertStringStartsWith(__FILE__, $exception
->getFile());
if (PHP_VERSION_ID < 70000) {
$this
->assertRegExp('/^Runtime Notice: Declaration/', $exception
->getMessage());
$this
->assertEquals(E_STRICT, $exception
->getSeverity());
}
else {
$this
->assertRegExp('/^Warning: Declaration/', $exception
->getMessage());
$this
->assertEquals(E_WARNING, $exception
->getSeverity());
}
} catch (\Exception $exception) {
restore_error_handler();
restore_exception_handler();
throw $exception;
}
}