Skip to content

Commit c702af4

Browse files
bug #37513 [PhpUnitBridge] ExcludeList usage for PHPUnit 9.4 (gennadigennadigennadi)
This PR was merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] ExcludeList usage for PHPUnit 9.4 | Q | A | ------------- | --- | Branch? | 4.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | #37344 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT Added: ExcludeList usage for PHPUnit >= 9.3 Commits ------- f59915d Add: ExcludeList usage for PHPUnit 9.4
2 parents 6c9a25c + f59915d commit c702af4

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PHPUnit\Framework\TestSuite;
1818
use PHPUnit\Runner\BaseTestRunner;
1919
use PHPUnit\Util\Blacklist;
20+
use PHPUnit\Util\ExcludeList;
2021
use PHPUnit\Util\Test;
2122
use Symfony\Bridge\PhpUnit\ClockMock;
2223
use Symfony\Bridge\PhpUnit\DnsMock;
@@ -48,7 +49,10 @@ class SymfonyTestsListenerTrait
4849
*/
4950
public function __construct(array $mockedNamespaces = [])
5051
{
51-
if (method_exists(Blacklist::class, 'addDirectory')) {
52+
if (class_exists(ExcludeList::class)) {
53+
(new ExcludeList())->getExcludedDirectories();
54+
ExcludeList::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2));
55+
} elseif (method_exists(Blacklist::class, 'addDirectory')) {
5256
(new BlackList())->getBlacklistedDirectories();
5357
Blacklist::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2));
5458
} else {

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
'requires' => ['php' => '*'],
194194
];
195195

196-
if (1 === \count($info['versions'])) {
196+
if (1 === count($info['versions'])) {
197197
$passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress -s dev phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\"");
198198
} else {
199199
$passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\"");
@@ -251,16 +251,20 @@
251251
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
252252
require PHPUNIT_COMPOSER_INSTALL;
253253
254-
if (!class_exists('SymfonyBlacklistPhpunit', false)) {
255-
class SymfonyBlacklistPhpunit {}
254+
if (!class_exists('SymfonyExcludeListPhpunit', false)) {
255+
class SymfonyExcludeListPhpunit {}
256256
}
257-
if (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) {
257+
if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) {
258+
(new PHPUnit\Util\Excludelist())->getExcludedDirectories();
259+
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
260+
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
261+
} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) {
258262
(new PHPUnit\Util\BlackList())->getBlacklistedDirectories();
259-
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistPhpunit'))->getFileName()));
260-
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistSimplePhpunit'))->getFileName()));
263+
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
264+
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
261265
} else {
262-
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1;
263-
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1;
266+
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1;
267+
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1;
264268
}
265269
266270
Symfony\Bridge\PhpUnit\TextUI\Command::main();
@@ -372,8 +376,8 @@ class SymfonyBlacklistPhpunit {}
372376
}
373377
}
374378
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
375-
if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) {
376-
class SymfonyBlacklistSimplePhpunit
379+
if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) {
380+
class SymfonyExcludeListSimplePhpunit
377381
{
378382
}
379383
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy