Skip to content

Commit

Permalink
minor #315 Bump to phpunit-bridge ^5.3 (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.21-dev branch.

Discussion
----------

Bump to phpunit-bridge ^5.3

See symfony/symfony#39419

Commits
-------

8e4ffb6 Bump to phpunit-bridge ^5.3
  • Loading branch information
nicolas-grekas committed Dec 26, 2020
2 parents d6b374f + 8e4ffb6 commit 1c8cc31
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 221 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"require-dev": {
"symfony/intl": "^4.4|^5.0",
"symfony/phpunit-bridge": "^5"
"symfony/phpunit-bridge": "^5.3"
},
"replace": {
"symfony/polyfill-apcu": "self.version",
Expand Down
8 changes: 1 addition & 7 deletions src/Util/TestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@

namespace Symfony\Polyfill\Util;

if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
class_alias('Symfony\Polyfill\Util\TestListenerForV5', 'Symfony\Polyfill\Util\TestListener');
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
// gets defined without executing the code before it and so the definition is not properly conditional)
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
class_alias('Symfony\Polyfill\Util\TestListenerForV6', 'Symfony\Polyfill\Util\TestListener');
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '9.1.0', '<')) {
if (version_compare(\PHPUnit\Runner\Version::id(), '9.1.0', '<')) {
class_alias('Symfony\Polyfill\Util\TestListenerForV7', 'Symfony\Polyfill\Util\TestListener');
} else {
class_alias('Symfony\Polyfill\Util\TestListenerForV9', 'Symfony\Polyfill\Util\TestListener');
Expand Down
89 changes: 0 additions & 89 deletions src/Util/TestListenerForV5.php

This file was deleted.

95 changes: 0 additions & 95 deletions src/Util/TestListenerForV6.php

This file was deleted.

22 changes: 14 additions & 8 deletions src/Util/TestListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Symfony\Polyfill\Util;

use PHPUnit\Framework\SkippedTestError;
use PHPUnit\Util\Test;

/**
* @author Nicolas Grekas <p@tchwork.com>
*/
Expand All @@ -24,13 +27,16 @@ public function startTestSuite($mainSuite)
return;
}
self::$enabledPolyfills = false;
$SkippedTestError = class_exists('PHPUnit\Framework\SkippedTestError') ? 'PHPUnit\Framework\SkippedTestError' : 'PHPUnit_Framework_SkippedTestError';
$warnings = array();

foreach ($mainSuite->tests() as $suite) {
$testClass = $suite->getName();
if (!$tests = $suite->tests()) {
continue;
}
if (\in_array('class-polyfill', Test::getGroups($testClass), true)) {
continue;
}
$testedClass = new \ReflectionClass($testClass);
if (preg_match('{^ \* @requires PHP (.*)}mi', $testedClass->getDocComment(), $m) && version_compare($m[1], \PHP_VERSION, '>')) {
continue;
Expand All @@ -44,21 +50,20 @@ public function startTestSuite($mainSuite)
}
$testedClass = new \ReflectionClass($m[1].$m[2]);
$bootstrap = new \SplFileObject(\dirname($testedClass->getFileName()).'/bootstrap.php');
$warnings = array();
$newWarnings = 0;
$defLine = null;

foreach (new \RegexIterator($bootstrap, '/define\(\'/') as $defLine) {
preg_match('/define\(\'(?P<name>.+)\'/', $defLine, $matches);
preg_match("/define\('(?P<name>[^']++)'/", $defLine, $matches);
if (\defined($matches['name'])) {
continue;
}

try {
eval($defLine);
} catch (\PHPUnit_Framework_Exception $ex){
$warnings[] = TestListener::warning($ex->getMessage());
} catch (\PHPUnit\Framework\Exception $ex) {
$warnings[] = TestListener::warning($ex->getMessage());
++$newWarnings;
}
}

Expand All @@ -67,6 +72,7 @@ public function startTestSuite($mainSuite)
foreach (new \RegexIterator($bootstrap, '/return p\\\\'.$testedClass->getShortName().'::/') as $defLine) {
if (!preg_match('/^\s*function (?P<name>[^\(]++)(?P<signature>\(.*\)(?: ?: [^ ]++)?) \{ (?<return>return p\\\\'.$testedClass->getShortName().'::[^\(]++)(?P<args>\([^\)]*+\)); \}$/', $defLine, $f)) {
$warnings[] = TestListener::warning('Invalid line in bootstrap.php: '.trim($defLine));
++$newWarnings;
continue;
}
$testNamespace = substr($testClass, 0, strrpos($testClass, '\\'));
Expand All @@ -87,7 +93,7 @@ public function startTestSuite($mainSuite)
$defLine = sprintf("return \\call_user_func_array('%s', \\func_get_args())", $f['name']);
}
} catch (\ReflectionException $e) {
$defLine = sprintf("throw new \\{$SkippedTestError}('Internal function not found: %s')", $f['name']);
$defLine = sprintf("throw new \\%s('Internal function not found: %s')", SkippedTestError::class, $f['name']);
}

eval(<<<EOPHP
Expand All @@ -107,8 +113,8 @@ function {$f['name']}{$f['signature']}
EOPHP
);
}
if (!$warnings && null === $defLine) {
$warnings[] = new $SkippedTestError('No Polyfills found in bootstrap.php for '.$testClass);
if (!$newWarnings && null === $defLine) {
$warnings[] = TestListener::warning('No polyfills found in bootstrap.php for '.$testClass);
} else {
$mainSuite->addTest(new TestListener($suite));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Icu/AbstractCollatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\TestCase;
use Symfony\Polyfill\Intl\Icu\Collator;
Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Icu/AbstractIcuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\TestCase;

Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Icu/AbstractIntlDateFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\TestCase;
use Symfony\Polyfill\Intl\Icu\IntlDateFormatter;
Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Icu/AbstractLocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\TestCase;

Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Icu/AbstractNumberFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\Error\Warning;
use PHPUnit\Framework\TestCase;
Expand Down
5 changes: 4 additions & 1 deletion tests/Intl/Icu/CollatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use Symfony\Polyfill\Intl\Icu\Collator;
use Symfony\Polyfill\Intl\Icu\Exception\MethodArgumentValueNotImplementedException;
use Symfony\Polyfill\Intl\Icu\Exception\MethodNotImplementedException;
use Symfony\Polyfill\Intl\Icu\Icu;

/**
* @group class-polyfill
*/
class CollatorTest extends AbstractCollatorTest
{
public function testConstructorWithUnsupportedLocale()
Expand Down
5 changes: 4 additions & 1 deletion tests/Intl/Icu/CurrenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use PHPUnit\Framework\TestCase;
use Symfony\Polyfill\Intl\Icu\Currencies;

/**
* @group class-polyfill
*/
class CurrenciesTest extends TestCase
{
public function testMetadata()
Expand Down
2 changes: 1 addition & 1 deletion tests/Intl/Icu/IcuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use Symfony\Polyfill\Intl\Icu\Icu;

Expand Down
5 changes: 4 additions & 1 deletion tests/Intl/Icu/IntlDateFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu\Tests;
namespace Symfony\Polyfill\Tests\Intl\Icu;

use Symfony\Polyfill\Intl\Icu\Exception\MethodArgumentNotImplementedException;
use Symfony\Polyfill\Intl\Icu\Exception\MethodArgumentValueNotImplementedException;
Expand All @@ -18,6 +18,9 @@
use Symfony\Polyfill\Intl\Icu\IntlDateFormatter;
use Symfony\Polyfill\Intl\Icu\Icu;

/**
* @group class-polyfill
*/
class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
{
public function testConstructor()
Expand Down
Loading

0 comments on commit 1c8cc31

Please sign in to comment.