Skip to content

Commit

Permalink
Merge branch '5.0'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed May 8, 2020
2 parents 3464861 + 84e7017 commit 9599e14
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions Tests/DeprecationErrorHandler/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DeprecationTest extends TestCase
use SetUpTearDownTrait;

private static $vendorDir;
private static $prefixDirsPsr4;

private static function getVendorDir()
{
Expand Down Expand Up @@ -151,22 +152,6 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()

public function providerGetTypeDetectsSelf()
{
foreach (get_declared_classes() as $class) {
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
$v = \dirname(\dirname($r->getFileName()));
if (file_exists($v.'/composer/installed.json')) {
$loader = require $v.'/autoload.php';
$reflection = new \ReflectionClass($loader);
$prop = $reflection->getProperty('prefixDirsPsr4');
$prop->setAccessible(true);
$currentValue = $prop->getValue($loader);
$currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];
$prop->setValue($loader, $currentValue);
}
}
}

return [
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
Expand Down Expand Up @@ -276,8 +261,32 @@ private static function removeDir($dir)
rmdir($dir);
}

private static function doSetupBeforeClass()
{
foreach (get_declared_classes() as $class) {
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
$v = \dirname(\dirname($r->getFileName()));
if (file_exists($v.'/composer/installed.json')) {
$loader = require $v.'/autoload.php';
$reflection = new \ReflectionClass($loader);
$prop = $reflection->getProperty('prefixDirsPsr4');
$prop->setAccessible(true);
$currentValue = $prop->getValue($loader);
self::$prefixDirsPsr4[] = [$prop, $loader, $currentValue];
$currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];
$prop->setValue($loader, $currentValue);
}
}
}
}

private static function doTearDownAfterClass()
{
foreach (self::$prefixDirsPsr4 as [$prop, $loader, $prefixDirsPsr4]) {
$prop->setValue($loader, $prefixDirsPsr4);
}

self::removeDir(self::getVendorDir().'/myfakevendor');
}
}

0 comments on commit 9599e14

Please sign in to comment.