summaryrefslogtreecommitdiff
path: root/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-02-03 13:44:03 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-02-04 11:17:33 +0000
commit7def76c7d817a9ec81e9ae4a03a850514b1a2e1c (patch)
tree3fcf7e8236356daac44f7c17b8c0c5bc736a0926 /vendor/symfony/debug/Tests/DebugClassLoaderTest.php
parentadfb3656b8dac8505590490f4f8aaf4bea27881b (diff)
downloadwebtrees-7def76c7d817a9ec81e9ae4a03a850514b1a2e1c.tar.gz
webtrees-7def76c7d817a9ec81e9ae4a03a850514b1a2e1c.tar.bz2
webtrees-7def76c7d817a9ec81e9ae4a03a850514b1a2e1c.zip
Working on upgrade wizard and testing
Diffstat (limited to 'vendor/symfony/debug/Tests/DebugClassLoaderTest.php')
-rw-r--r--vendor/symfony/debug/Tests/DebugClassLoaderTest.php88
1 files changed, 48 insertions, 40 deletions
diff --git a/vendor/symfony/debug/Tests/DebugClassLoaderTest.php b/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
index c7e03fbef8..fc68b86460 100644
--- a/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
+++ b/vendor/symfony/debug/Tests/DebugClassLoaderTest.php
@@ -27,14 +27,14 @@ class DebugClassLoaderTest extends TestCase
{
$this->errorReporting = error_reporting(E_ALL);
$this->loader = new ClassLoader();
- spl_autoload_register(array($this->loader, 'loadClass'), true, true);
+ spl_autoload_register([$this->loader, 'loadClass'], true, true);
DebugClassLoader::enable();
}
protected function tearDown()
{
DebugClassLoader::disable();
- spl_autoload_unregister(array($this->loader, 'loadClass'));
+ spl_autoload_unregister([$this->loader, 'loadClass']);
error_reporting($this->errorReporting);
}
@@ -136,20 +136,20 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
- $xError = array(
+ $xError = [
'type' => E_USER_DEPRECATED,
'message' => 'The "Test\Symfony\Component\Debug\Tests\\'.$class.'" class '.$type.' "Symfony\Component\Debug\Tests\Fixtures\\'.$super.'" that is deprecated but this is a test deprecation notice.',
- );
+ ];
$this->assertSame($xError, $lastError);
}
public function provideDeprecatedSuper()
{
- return array(
- array('DeprecatedInterfaceClass', 'DeprecatedInterface', 'implements'),
- array('DeprecatedParentClass', 'DeprecatedClass', 'extends'),
- );
+ return [
+ ['DeprecatedInterfaceClass', 'DeprecatedInterface', 'implements'],
+ ['DeprecatedParentClass', 'DeprecatedClass', 'extends'],
+ ];
}
public function testInterfaceExtendsDeprecatedInterface()
@@ -166,10 +166,10 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
- $xError = array(
+ $xError = [
'type' => E_USER_NOTICE,
'message' => '',
- );
+ ];
$this->assertSame($xError, $lastError);
}
@@ -188,39 +188,46 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
- $xError = array(
+ $xError = [
'type' => E_USER_NOTICE,
'message' => '',
- );
+ ];
$this->assertSame($xError, $lastError);
}
public function testExtendedFinalClass()
{
- set_error_handler(function () { return false; });
- $e = error_reporting(0);
- trigger_error('', E_USER_NOTICE);
+ $deprecations = [];
+ set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
+ $e = error_reporting(E_USER_DEPRECATED);
+
+ require __DIR__.'/Fixtures/FinalClasses.php';
- class_exists('Test\\'.__NAMESPACE__.'\\ExtendsFinalClass', true);
+ $i = 1;
+ while(class_exists($finalClass = __NAMESPACE__.'\\Fixtures\\FinalClass'.$i++, false)) {
+ spl_autoload_call($finalClass);
+ class_exists('Test\\'.__NAMESPACE__.'\\Extends'.substr($finalClass, strrpos($finalClass, '\\') + 1), true);
+ }
error_reporting($e);
restore_error_handler();
- $lastError = error_get_last();
- unset($lastError['file'], $lastError['line']);
-
- $xError = array(
- 'type' => E_USER_DEPRECATED,
- 'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass".',
- );
-
- $this->assertSame($xError, $lastError);
+ $this->assertSame([
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass1" class 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 "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass1".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass2" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass2".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass3" class is considered final comment with @@@ and ***. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass3".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass4" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass4".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass5" class is considered final multiline comment. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass5".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass6" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass6".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass7" class is considered final another multiline comment... It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass7".',
+ 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass8" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass8".',
+ ], $deprecations);
}
public function testExtendedFinalMethod()
{
- $deprecations = array();
+ $deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@@ -229,10 +236,10 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
- $xError = array(
+ $xError = [
'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".',
'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod2()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".',
- );
+ ];
$this->assertSame($xError, $deprecations);
}
@@ -251,12 +258,12 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
- $this->assertSame(array('type' => E_USER_NOTICE, 'message' => ''), $lastError);
+ $this->assertSame(['type' => E_USER_NOTICE, 'message' => ''], $lastError);
}
public function testInternalsUse()
{
- $deprecations = array();
+ $deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@@ -265,17 +272,17 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
- $this->assertSame($deprecations, array(
+ $this->assertSame($deprecations, [
'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\InternalClass" class 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\InternalClass::internalMethod()" method is considered internal. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".',
- ));
+ ]);
}
public function testExtendedMethodDefinesNewParameters()
{
- $deprecations = array();
+ $deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@@ -284,16 +291,16 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
- $this->assertSame(array(
+ $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::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);
+ ], $deprecations);
}
public function testUseTraitWithInternalMethod()
{
- $deprecations = array();
+ $deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@@ -302,7 +309,7 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
- $this->assertSame(array(), $deprecations);
+ $this->assertSame([], $deprecations);
}
}
@@ -314,7 +321,7 @@ class ClassLoader
public function getClassMap()
{
- return array(__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php');
+ return [__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php'];
}
public function findFile($class)
@@ -343,8 +350,9 @@ class ClassLoader
eval('namespace Test\\'.__NAMESPACE__.'; class NonDeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\NonDeprecatedInterface {}');
} elseif ('Test\\'.__NAMESPACE__.'\Float' === $class) {
eval('namespace Test\\'.__NAMESPACE__.'; class Float {}');
- } elseif ('Test\\'.__NAMESPACE__.'\ExtendsFinalClass' === $class) {
- eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsFinalClass extends \\'.__NAMESPACE__.'\Fixtures\FinalClass {}');
+ } elseif (0 === strpos($class, 'Test\\'.__NAMESPACE__.'\ExtendsFinalClass')) {
+ $classShortName = substr($class, strrpos($class, '\\') + 1);
+ eval('namespace Test\\'.__NAMESPACE__.'; class '.$classShortName.' extends \\'.__NAMESPACE__.'\Fixtures\\'.substr($classShortName, 7).' {}');
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsAnnotatedClass' === $class) {
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsAnnotatedClass extends \\'.__NAMESPACE__.'\Fixtures\AnnotatedClass {
public function deprecatedMethod() { }