Skip to content

Commit 9599e14

Browse files
Merge branch '5.0'
* 5.0: [PhpUnitBridge] fix bad test [4.4] CS fixes [3.4] CS fixes Disable phpunit verbosity Queue name is a required parameter [FrameworkBundle] display actual target for error in AssetsInstallCommand Remove patches for Doctrine bugs and deprecations [Mime] fix bad method call on "EmailAddressContains" [DI][EventDispatcher] added contract for implementation
2 parents 3464861 + 84e7017 commit 9599e14

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

Tests/DeprecationErrorHandler/DeprecationTest.php

+25-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class DeprecationTest extends TestCase
2222
use SetUpTearDownTrait;
2323

2424
private static $vendorDir;
25+
private static $prefixDirsPsr4;
2526

2627
private static function getVendorDir()
2728
{
@@ -151,22 +152,6 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()
151152

152153
public function providerGetTypeDetectsSelf()
153154
{
154-
foreach (get_declared_classes() as $class) {
155-
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
156-
$r = new \ReflectionClass($class);
157-
$v = \dirname(\dirname($r->getFileName()));
158-
if (file_exists($v.'/composer/installed.json')) {
159-
$loader = require $v.'/autoload.php';
160-
$reflection = new \ReflectionClass($loader);
161-
$prop = $reflection->getProperty('prefixDirsPsr4');
162-
$prop->setAccessible(true);
163-
$currentValue = $prop->getValue($loader);
164-
$currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];
165-
$prop->setValue($loader, $currentValue);
166-
}
167-
}
168-
}
169-
170155
return [
171156
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
172157
'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
@@ -276,8 +261,32 @@ private static function removeDir($dir)
276261
rmdir($dir);
277262
}
278263

264+
private static function doSetupBeforeClass()
265+
{
266+
foreach (get_declared_classes() as $class) {
267+
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
268+
$r = new \ReflectionClass($class);
269+
$v = \dirname(\dirname($r->getFileName()));
270+
if (file_exists($v.'/composer/installed.json')) {
271+
$loader = require $v.'/autoload.php';
272+
$reflection = new \ReflectionClass($loader);
273+
$prop = $reflection->getProperty('prefixDirsPsr4');
274+
$prop->setAccessible(true);
275+
$currentValue = $prop->getValue($loader);
276+
self::$prefixDirsPsr4[] = [$prop, $loader, $currentValue];
277+
$currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];
278+
$prop->setValue($loader, $currentValue);
279+
}
280+
}
281+
}
282+
}
283+
279284
private static function doTearDownAfterClass()
280285
{
286+
foreach (self::$prefixDirsPsr4 as [$prop, $loader, $prefixDirsPsr4]) {
287+
$prop->setValue($loader, $prefixDirsPsr4);
288+
}
289+
281290
self::removeDir(self::getVendorDir().'/myfakevendor');
282291
}
283292
}

0 commit comments

Comments
 (0)