8000 [Bridge/PhpUnit] Fix compat with phpunit 4.8 & bridge <=3.3.13 · symfony/symfony@0187e9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0187e9b

Browse files
[Bridge/PhpUnit] Fix compat with phpunit 4.8 & bridge <=3.3.13
1 parent f2fc7bf commit 0187e9b

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
9898
"predis/predis": "~1.0",
9999
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
100-
"symfony/phpunit-bridge": "~3.2",
100+
"symfony/phpunit-bridge": "~3.4|~4.0",
101101
"symfony/security-acl": "~2.8|~3.0",
102102
"phpdocumentor/reflection-docblock": "^3.0|^4.0",
103103
"sensio/framework-extra-bundle": "^3.0.2"

src/Symfony/Bridge/PhpUnit/Blacklist.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ class Blacklist
2323

2424
public function getBlacklistedDirectories()
2525
{
26-
$root = dirname(__DIR__);
27-
while ($root !== $parent = dirname($root)) {
28-
$root = $parent;
26+
$blacklist = array();
27+
28+
foreach (get_declared_classes() as $class) {
29+
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
30+
$r = new \ReflectionClass($class);
31+
$v = dirname(dirname($r->getFileName()));
32+
if (file_exists($v.'/composer/installed.json')) {
33+
$blacklist[] = $v;
34+
}
35+
}
2936
}
3037

31-
return array($root);
38+
return $blacklist;
3239
}
3340

3441
public function isBlacklisted($file)
@@ -37,5 +44,9 @@ public function isBlacklisted($file)
3744
}
3845
}
3946

40-
class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit\Util\Blacklist');
41-
class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit_Util_Blacklist');
47+
if (class_exists('PHPUnit\Util\Test')) {
48+
class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit\Util\Blacklist');
49+
}
50+
if (class_exists('PHPUnit_Util_Test')) {
51+
class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit_Util_Blacklist');
52+
}

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
6868
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
6969
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
7070
}
71-
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"~3.3.11@dev|~3.4.0-beta2@dev|^4.0.0-beta2@dev\"");
71+
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"~3.4-beta5@dev|^4.0-beta5@dev\"");
7272
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
7373
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
7474
$exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true)));

src/Symfony/Bridge/PhpUnit/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1414

1515
// Replace the native phpunit Blacklist, it's a broken artifact from the past
16-
require_once __DIR__.'/Blacklist.php';
16+
if (!class_exists('Symfony\Bridge\PhpUnit\Blacklist', false)) {
17+
require_once __DIR__.'/Blacklist.php';
18+
}
1719

1820
// Detect if we need to serialize deprecations to a file.
1921
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {

0 commit comments

Comments
 (0)
0