From 134e0b1d98c3ca3a9564c8c1e766d9dc8b2ce61e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Jun 2025 16:08:14 +0200 Subject: [PATCH 01/18] Allow Symfony ^8.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index de9101f..169f0e6 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "symfony/deprecation-contracts": "^2.5|^3.0", - "symfony/error-handler": "^5.4|^6.4|^7.0", + "symfony/error-handler": "^6.4|^7.0|^8.0", "symfony/polyfill-php81": "^1.27" }, "conflict": { From b732d159fe96d122ed8248950de0a3366829e802 Mon Sep 17 00:00:00 2001 From: jprivet-dev Date: Thu, 15 May 2025 08:45:41 +0200 Subject: [PATCH 02/18] [PhpUnitBridge] Add `strtotime()` to `ClockMock` --- CHANGELOG.md | 5 +++++ ClockMock.php | 17 +++++++++++++++++ Tests/ClockMockTest.php | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b139af..579fd88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.4 +--- + + * Add support for mocking the `strtotime()` function + 7.3 --- diff --git a/ClockMock.php b/ClockMock.php index 4cca8fc..7c76596 100644 --- a/ClockMock.php +++ b/ClockMock.php @@ -109,6 +109,18 @@ public static function hrtime($asNumber = false) return [(int) self::$now, (int) $ns]; } + /** + * @return false|int + */ + public static function strtotime(string $datetime, ?int $timestamp = null) + { + if (null === $timestamp) { + $timestamp = self::time(); + } + + return \strtotime($datetime, $timestamp); + } + public static function register($class): void { $self = static::class; @@ -161,6 +173,11 @@ function hrtime(\$asNumber = false) { return \\$self::hrtime(\$asNumber); } + +function strtotime(\$datetime, \$timestamp = null) +{ + return \\$self::strtotime(\$datetime, \$timestamp); +} EOPHP ); } diff --git a/Tests/ClockMockTest.php b/Tests/ClockMockTest.php index 7df7865..8424108 100644 --- a/Tests/ClockMockTest.php +++ b/Tests/ClockMockTest.php @@ -79,4 +79,9 @@ public function testHrTimeAsNumber() { $this->assertSame(1234567890125000000, hrtime(true)); } + + public function testStrToTime() + { + $this->assertSame(1234567890, strtotime('now')); + } } From 0be807e438edb7f965f99786b6d18b4f75e9e400 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 Jul 2025 10:59:01 +0200 Subject: [PATCH 03/18] [PhpUnitBridge] Bump v7.4 to PHP >= 8.1 --- ClassExistsMock.php | 4 +- ClockMock.php | 2 +- ConstraintTrait.php | 7 +- CoverageListener.php | 8 +-- DeprecationErrorHandler.php | 4 +- DeprecationErrorHandler/Deprecation.php | 30 ++++----- DnsMock.php | 2 +- Legacy/{CommandForV7.php => CommandForV8.php} | 2 +- Legacy/ConstraintTraitForV7.php | 64 ------------------- Legacy/ExpectDeprecationTraitForV8_4.php | 6 +- Legacy/SymfonyTestsListenerTrait.php | 24 +++---- Tests/CoverageListenerTest.php | 2 +- .../ConfigurationTest.php | 8 +-- .../DeprecationGroupTest.php | 9 +++ .../DeprecationNoticeTest.php | 9 +++ .../DeprecationTest.php | 4 +- .../deprecation/deprecation.php | 9 +++ .../fake_app/AppService.php | 13 +++- .../fake_app/BarService.php | 9 +++ .../fake_app/ExtendsDeprecatedFromVendor.php | 9 +++ .../ExtendsDeprecatedClassFromOtherVendor.php | 9 +++ .../fake_vendor/acme/lib/PhpDeprecation.php | 9 +++ .../fake_vendor/acme/lib/SomeService.php | 13 +++- .../acme/lib/deprecation_riddled.php | 9 +++ .../fake_vendor/autoload.php | 9 +++ .../fake_vendor/bar/lib/AnotherService.php | 13 +++- .../fake_vendor/composer/autoload_real.php | 11 +++- .../fake_vendor/fcy/lib/DeprecatedClass.php | 9 +++ .../fake_vendor_bis/autoload.php | 9 +++ .../composer/autoload_real.php | 11 +++- .../foo/lib/SomeOtherService.php | 9 +++ .../DeprecationErrorHandler/generate_phar.php | 9 +++ .../php_deprecation_from_vendor_class.phpt | 2 - Tests/EnumExistsMockTest.php | 3 - Tests/Metadata/AttributeReaderTest.php | 5 +- TextUI/Command.php | 2 +- bin/simple-phpunit.php | 27 ++------ bootstrap.php | 14 ---- composer.json | 10 +-- 39 files changed, 229 insertions(+), 179 deletions(-) rename Legacy/{CommandForV7.php => CommandForV8.php} (97%) delete mode 100644 Legacy/ConstraintTraitForV7.php diff --git a/ClassExistsMock.php b/ClassExistsMock.php index 72ec51e..6158242 100644 --- a/ClassExistsMock.php +++ b/ClassExistsMock.php @@ -62,7 +62,7 @@ public static function trait_exists($name, $autoload = true): bool return isset(self::$classes[$name]) ? (bool) self::$classes[$name] : \trait_exists($name, $autoload); } - public static function enum_exists($name, $autoload = true):bool + public static function enum_exists($name, $autoload = true): bool { $name = ltrim($name, '\\'); @@ -77,7 +77,7 @@ public static function register($class): void if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); - } elseif (0 === strpos($class, 'Tests\\')) { + } elseif (str_starts_with($class, 'Tests\\')) { $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { diff --git a/ClockMock.php b/ClockMock.php index 7c76596..9a9c910 100644 --- a/ClockMock.php +++ b/ClockMock.php @@ -129,7 +129,7 @@ public static function register($class): void if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); - } elseif (0 === strpos($class, 'Tests\\')) { + } elseif (str_starts_with($class, 'Tests\\')) { $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { diff --git a/ConstraintTrait.php b/ConstraintTrait.php index ceb6041..9090cc4 100644 --- a/ConstraintTrait.php +++ b/ConstraintTrait.php @@ -14,12 +14,7 @@ use PHPUnit\Framework\Constraint\Constraint; $r = new \ReflectionClass(Constraint::class); -if ($r->getProperty('exporter')->isProtected()) { - trait ConstraintTrait - { - use Legacy\ConstraintTraitForV7; - } -} elseif (!$r->getMethod('evaluate')->hasReturnType()) { +if (!$r->getMethod('evaluate')->hasReturnType()) { trait ConstraintTrait { use Legacy\ConstraintTraitForV8; diff --git a/CoverageListener.php b/CoverageListener.php index 65d6aa9..c7c70c9 100644 --- a/CoverageListener.php +++ b/CoverageListener.php @@ -29,7 +29,7 @@ class CoverageListener implements TestListener public function __construct(?callable $sutFqcnResolver = null, bool $warningOnSutNotFound = false) { $this->sutFqcnResolver = $sutFqcnResolver ?? static function (Test $test): ?string { - $class = \get_class($test); + $class = $test::class; $sutFqcn = str_replace('\\Tests\\', '\\', $class); $sutFqcn = preg_replace('{Test$}', '', $sutFqcn); @@ -46,7 +46,7 @@ public function startTest(Test $test): void return; } - $annotations = TestUtil::parseTestMethodAnnotations(\get_class($test), $test->getName(false)); + $annotations = TestUtil::parseTestMethodAnnotations($test::class, $test->getName(false)); $ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing']; @@ -90,7 +90,7 @@ private function addCoversForClassToAnnotationCache(Test $test, array $covers): $cache = $r->getValue(); $cache = array_replace_recursive($cache, [ - \get_class($test) => [ + $test::class => [ 'covers' => $covers, ], ]); @@ -100,7 +100,7 @@ private function addCoversForClassToAnnotationCache(Test $test, array $covers): private function addCoversForDocBlockInsideRegistry(Test $test, array $covers): void { - $docBlock = Registry::getInstance()->forClassName(\get_class($test)); + $docBlock = Registry::getInstance()->forClassName($test::class); $symbolAnnotations = new \ReflectionProperty($docBlock, 'symbolAnnotations'); $symbolAnnotations->setAccessible(true); diff --git a/DeprecationErrorHandler.php b/DeprecationErrorHandler.php index e597908..01bb653 100644 --- a/DeprecationErrorHandler.php +++ b/DeprecationErrorHandler.php @@ -97,7 +97,7 @@ public static function collectDeprecations($outputFile) { $deprecations = []; $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) { - if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) { + if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || !str_contains($msg, '" targeting switch is equivalent to "break'))) { if ($previousErrorHandler) { return $previousErrorHandler($type, $msg, $file, $line, $context); } @@ -129,7 +129,7 @@ public static function collectDeprecations($outputFile) */ public function handleError($type, $msg, $file, $line, $context = []) { - if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) { + if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || !str_contains($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) { return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context); } diff --git a/DeprecationErrorHandler/Deprecation.php b/DeprecationErrorHandler/Deprecation.php index 822e980..6a1315f 100644 --- a/DeprecationErrorHandler/Deprecation.php +++ b/DeprecationErrorHandler/Deprecation.php @@ -99,7 +99,7 @@ public function __construct(string $message, array $trace, string $file, bool $l $this->getOriginalFilesStack(); array_splice($this->originalFilesStack, 0, $j, [$this->triggeringFile]); - if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/', $message, $m) || (false === strpos($message, '()" will return') && false === strpos($message, 'native return type declaration') && preg_match('/^(?:The|Method) "([^":]++)/', $message, $m))) { + if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/', $message, $m) || (!str_contains($message, '()" will return') && !str_contains($message, 'native return type declaration') && preg_match('/^(?:The|Method) "([^":]++)/', $message, $m))) { $this->triggeringFile = (new \ReflectionClass($m[1]))->getFileName(); array_unshift($this->originalFilesStack, $this->triggeringFile); } @@ -137,7 +137,7 @@ public function __construct(string $message, array $trace, string $file, bool $l return; } - if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) { + if (!isset($line['class'], $trace[$i - 2]['function']) || !str_starts_with($line['class'], SymfonyTestsListenerFor::class)) { $this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class']; $this->originMethod = $line['function']; @@ -147,7 +147,7 @@ public function __construct(string $message, array $trace, string $file, bool $l $test = $line['args'][0] ?? null; if (($test instanceof TestCase || $test instanceof TestSuite) && ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class']))) { - $this->originClass = \get_class($test); + $this->originClass = $test::class; $this->originMethod = $test->getName(); } } @@ -159,7 +159,7 @@ private function lineShouldBeSkipped(array $line): bool } $class = $line['class']; - return 'ReflectionMethod' === $class || 0 === strpos($class, 'PHPUnit\\'); + return 'ReflectionMethod' === $class || str_starts_with($class, 'PHPUnit\\'); } public function originatesFromDebugClassLoader(): bool @@ -189,7 +189,7 @@ public function originatingClass(): string $class = $this->originClass; - return false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; + return str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; } public function originatingMethod(): string @@ -215,9 +215,9 @@ public function isLegacy(): bool $method = $this->originatingMethod(); $groups = class_exists(Groups::class, false) ? [new Groups(), 'groups'] : [Test::class, 'getGroups']; - return 0 === strpos($method, 'testLegacy') - || 0 === strpos($method, 'provideLegacy') - || 0 === strpos($method, 'getLegacy') + return str_starts_with($method, 'testLegacy') + || str_starts_with($method, 'provideLegacy') + || str_starts_with($method, 'getLegacy') || strpos($this->originClass, '\Legacy') || \in_array('legacy', $groups($this->originClass, $method), true); } @@ -228,10 +228,10 @@ public function isMuted(): bool return false; } if (isset($this->trace[1]['class'])) { - return 0 === strpos($this->trace[1]['class'], 'PHPUnit\\'); + return str_starts_with($this->trace[1]['class'], 'PHPUnit\\'); } - return false !== strpos($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR); + return str_contains($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR); } /** @@ -300,7 +300,7 @@ private function getPackage(string $path): string { $path = realpath($path) ?: $path; foreach (self::getVendors() as $vendorRoot) { - if (0 === strpos($path, $vendorRoot)) { + if (str_starts_with($path, $vendorRoot)) { $relativePath = substr($path, \strlen($vendorRoot) + 1); $vendor = strstr($relativePath, \DIRECTORY_SEPARATOR, true); if (false === $vendor) { @@ -326,7 +326,7 @@ private static function getVendors(): array self::$vendors[] = \dirname((new \ReflectionClass(DebugClassLoader::class))->getFileName()); } foreach (get_declared_classes() as $class) { - if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { + if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { @@ -341,7 +341,7 @@ private static function getVendors(): array } foreach ($paths as $path) { foreach (self::$vendors as $vendor) { - if (0 !== strpos($path, $vendor)) { + if (!str_starts_with($path, $vendor)) { self::$internalPaths[] = $path; } } @@ -371,13 +371,13 @@ private function getPathType(string $path): string return self::PATH_TYPE_UNDETERMINED; } foreach (self::getVendors() as $vendor) { - if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) { + if (str_starts_with($realPath, $vendor) && false !== strpbrk(substr($realPath, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) { return self::PATH_TYPE_VENDOR; } } foreach (self::$internalPaths as $internalPath) { - if (0 === strpos($realPath, $internalPath)) { + if (str_starts_with($realPath, $internalPath)) { return self::PATH_TYPE_SELF; } } diff --git a/DnsMock.php b/DnsMock.php index 84251c1..bc2ac1a 100644 --- a/DnsMock.php +++ b/DnsMock.php @@ -170,7 +170,7 @@ public static function register($class): void if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); - } elseif (0 === strpos($class, 'Tests\\')) { + } elseif (str_starts_with($class, 'Tests\\')) { $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { diff --git a/Legacy/CommandForV7.php b/Legacy/CommandForV8.php similarity index 97% rename from Legacy/CommandForV7.php rename to Legacy/CommandForV8.php index 99a1e68..ffeb2b8 100644 --- a/Legacy/CommandForV7.php +++ b/Legacy/CommandForV8.php @@ -19,7 +19,7 @@ /** * @internal */ -class CommandForV7 extends BaseCommand +class CommandForV8 extends BaseCommand { protected function createRunner(): BaseRunner { diff --git a/Legacy/ConstraintTraitForV7.php b/Legacy/ConstraintTraitForV7.php deleted file mode 100644 index b132f47..0000000 --- a/Legacy/ConstraintTraitForV7.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -use SebastianBergmann\Exporter\Exporter; - -/** - * @internal - */ -trait ConstraintTraitForV7 -{ - use ConstraintLogicTrait; - - /** - * @return bool|null - */ - public function evaluate($other, $description = '', $returnResult = false) - { - return $this->doEvaluate($other, $description, $returnResult); - } - - public function count(): int - { - return $this->doCount(); - } - - public function toString(): string - { - return $this->doToString(); - } - - protected function additionalFailureDescription($other): string - { - return $this->doAdditionalFailureDescription($other); - } - - protected function exporter(): Exporter - { - if (null === $this->exporter) { - $this->exporter = new Exporter(); - } - - return $this->exporter; - } - - protected function failureDescription($other): string - { - return $this->doFailureDescription($other); - } - - protected function matches($other): bool - { - return $this->doMatches($other); - } -} diff --git a/Legacy/ExpectDeprecationTraitForV8_4.php b/Legacy/ExpectDeprecationTraitForV8_4.php index d159635..95823c2 100644 --- a/Legacy/ExpectDeprecationTraitForV8_4.php +++ b/Legacy/ExpectDeprecationTraitForV8_4.php @@ -22,7 +22,7 @@ trait ExpectDeprecationTraitForV8_4 public function expectDeprecation(): void { if (1 > \func_num_args() || !\is_string($message = func_get_arg(0))) { - throw new \InvalidArgumentException(sprintf('The "%s()" method requires the string $message argument.', __FUNCTION__)); + throw new \InvalidArgumentException(\sprintf('The "%s()" method requires the string $message argument.', __FUNCTION__)); } // Expected deprecations set by isolated tests need to be written to a file @@ -52,7 +52,7 @@ public function expectDeprecation(): void */ public function expectDeprecationMessage(string $message): void { - throw new \BadMethodCallException(sprintf('The "%s()" method is not supported by Symfony\'s PHPUnit Bridge ExpectDeprecationTrait, pass the message to expectDeprecation() instead.', __FUNCTION__)); + throw new \BadMethodCallException(\sprintf('The "%s()" method is not supported by Symfony\'s PHPUnit Bridge ExpectDeprecationTrait, pass the message to expectDeprecation() instead.', __FUNCTION__)); } /** @@ -60,6 +60,6 @@ public function expectDeprecationMessage(string $message): void */ public function expectDeprecationMessageMatches(string $regularExpression): void { - throw new \BadMethodCallException(sprintf('The "%s()" method is not supported by Symfony\'s PHPUnit Bridge ExpectDeprecationTrait.', __FUNCTION__)); + throw new \BadMethodCallException(\sprintf('The "%s()" method is not supported by Symfony\'s PHPUnit Bridge ExpectDeprecationTrait.', __FUNCTION__)); } } diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index 486d3bf..07c5264 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -57,7 +57,7 @@ public function __construct(array $mockedNamespaces = []) (new ExcludeList())->getExcludedDirectories(); ExcludeList::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2)); } elseif (method_exists(Blacklist::class, 'addDirectory')) { - (new BlackList())->getBlacklistedDirectories(); + (new Blacklist())->getBlacklistedDirectories(); Blacklist::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2)); } else { Blacklist::$blacklistedClassNames[__CLASS__] = 2; @@ -124,7 +124,7 @@ public function startTestSuite($suite): void if (!$test instanceof TestCase) { continue; } - if (null === Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) { + if (null === Test::getPreserveGlobalStateSettings($test::class, $test->getName(false))) { $test->setPreserveGlobalState(false); } } @@ -181,7 +181,7 @@ public function startTestSuite($suite): void continue; } if ($test instanceof TestCase - && isset($this->wasSkipped[\get_class($test)][$test->getName()]) + && isset($this->wasSkipped[$test::class][$test->getName()]) ) { $skipped[] = $test; } @@ -196,10 +196,10 @@ public function addSkippedTest($test, \Exception $e, $time): void if (0 < $this->state) { if ($test instanceof DataProviderTestSuite) { foreach ($test->tests() as $testWithDataProvider) { - $this->isSkipped[\get_class($testWithDataProvider)][$testWithDataProvider->getName()] = 1; + $this->isSkipped[$testWithDataProvider::class][$testWithDataProvider->getName()] = 1; } } else { - $this->isSkipped[\get_class($test)][$test->getName()] = 1; + $this->isSkipped[$test::class][$test->getName()] = 1; } } } @@ -214,15 +214,15 @@ public function startTest($test): void putenv('SYMFONY_EXPECTED_DEPRECATIONS_SERIALIZE='.tempnam(sys_get_temp_dir(), 'expectdeprec')); } - $groups = Test::getGroups(\get_class($test), $test->getName(false)); + $groups = Test::getGroups($test::class, $test->getName(false)); if (!$this->runsInSeparateProcess) { if (\in_array('time-sensitive', $groups, true)) { - ClockMock::register(\get_class($test)); + ClockMock::register($test::class); ClockMock::withClockMock(true); } if (\in_array('dns-sensitive', $groups, true)) { - DnsMock::register(\get_class($test)); + DnsMock::register($test::class); } } @@ -230,7 +230,7 @@ public function startTest($test): void return; } - $annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false)); + $annotations = Test::parseTestMethodAnnotations($test::class, $test->getName(false)); if (isset($annotations['class']['expectedDeprecation'])) { $test->getTestResultObject()->addError($test, new AssertionFailedError('"@expectedDeprecation" annotations are not allowed at the class level.'), 0); @@ -268,14 +268,14 @@ public function endTest($test, $time): void DebugClassLoader::checkClasses(); } - $className = \get_class($test); + $className = $test::class; $groups = Test::getGroups($className, $test->getName(false)); if ($this->checkNumAssertions) { $assertions = \count(self::$expectedDeprecations) + $test->getNumAssertions(); if ($test->doesNotPerformAssertions() && $assertions > 0) { - $test->getTestResultObject()->addFailure($test, new RiskyTestError(sprintf('This test is annotated with "@doesNotPerformAssertions", but performed %s assertions', $assertions)), $time); - } elseif ($assertions === 0 && !$test->doesNotPerformAssertions() && $test->getTestResultObject()->noneSkipped()) { + $test->getTestResultObject()->addFailure($test, new RiskyTestError(\sprintf('This test is annotated with "@doesNotPerformAssertions", but performed %s assertions', $assertions)), $time); + } elseif (0 === $assertions && !$test->doesNotPerformAssertions() && $test->getTestResultObject()->noneSkipped()) { $test->getTestResultObject()->addFailure($test, new RiskyTestError('This test did not perform any assertions'), $time); } diff --git a/Tests/CoverageListenerTest.php b/Tests/CoverageListenerTest.php index 99d4a4b..54cfcdd 100644 --- a/Tests/CoverageListenerTest.php +++ b/Tests/CoverageListenerTest.php @@ -34,7 +34,7 @@ public function test() exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text --colors=never 2> /dev/null", $output); $output = implode("\n", $output); - if (false === strpos($output, 'FooCov')) { + if (!str_contains($output, 'FooCov')) { $this->addToAssertionCount(1); } else { $this->assertMatchesRegularExpression('/FooCov\n\s*Methods:\s+0.00%[^\n]+Lines:\s+0.00%/', $output); diff --git a/Tests/DeprecationErrorHandler/ConfigurationTest.php b/Tests/DeprecationErrorHandler/ConfigurationTest.php index 7eec029..e9c83d2 100644 --- a/Tests/DeprecationErrorHandler/ConfigurationTest.php +++ b/Tests/DeprecationErrorHandler/ConfigurationTest.php @@ -245,7 +245,7 @@ public function testToleratesForIndividualGroups(string $deprecationsHelper, arr $groups = $this->buildGroups($deprecationsPerType); foreach ($expected as $groupName => $tolerates) { - $this->assertSame($tolerates, $configuration->toleratesForGroup($groupName, $groups), sprintf('Deprecation type "%s" is %s', $groupName, $tolerates ? 'tolerated' : 'not tolerated')); + $this->assertSame($tolerates, $configuration->toleratesForGroup($groupName, $groups), \sprintf('Deprecation type "%s" is %s', $groupName, $tolerates ? 'tolerated' : 'not tolerated')); } } @@ -515,7 +515,7 @@ public function testBaselineFileException() $filename = $this->createFile(); unlink($filename); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('The baselineFile "%s" does not exist.', $filename)); + $this->expectExceptionMessage(\sprintf('The baselineFile "%s" does not exist.', $filename)); Configuration::fromUrlEncodedString('baselineFile='.urlencode($filename)); } @@ -529,7 +529,7 @@ public function testBaselineFileWriteError() $this->expectExceptionMessageMatches('/[Ff]ailed to open stream: Permission denied/'); set_error_handler(static function (int $errno, string $errstr, ?string $errfile = null, ?int $errline = null): bool { - if ($errno & (E_WARNING | E_WARNING)) { + if ($errno & (\E_WARNING | \E_WARNING)) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); } @@ -595,7 +595,7 @@ public function testIgnoreFileException() $filename = $this->createFile(); unlink($filename); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('The ignoreFile "%s" does not exist.', $filename)); + $this->expectExceptionMessage(\sprintf('The ignoreFile "%s" does not exist.', $filename)); Configuration::fromUrlEncodedString('ignoreFile='.urlencode($filename)); } diff --git a/Tests/DeprecationErrorHandler/DeprecationGroupTest.php b/Tests/DeprecationErrorHandler/DeprecationGroupTest.php index df746e5..6b55820 100644 --- a/Tests/DeprecationErrorHandler/DeprecationGroupTest.php +++ b/Tests/DeprecationErrorHandler/DeprecationGroupTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; use PHPUnit\Framework\TestCase; diff --git a/Tests/DeprecationErrorHandler/DeprecationNoticeTest.php b/Tests/DeprecationErrorHandler/DeprecationNoticeTest.php index c0a88c4..fe4c456 100644 --- a/Tests/DeprecationErrorHandler/DeprecationNoticeTest.php +++ b/Tests/DeprecationErrorHandler/DeprecationNoticeTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; use PHPUnit\Framework\TestCase; diff --git a/Tests/DeprecationErrorHandler/DeprecationTest.php b/Tests/DeprecationErrorHandler/DeprecationTest.php index 4c17a80..0b7fa17 100644 --- a/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -28,7 +28,7 @@ private static function getVendorDir() } foreach (get_declared_classes() as $class) { - if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { + if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $vendorDir = \dirname($r->getFileName(), 2); if (file_exists($vendorDir.'/composer/installed.json') && @mkdir($vendorDir.'/myfakevendor/myfakepackage1', 0777, true)) { @@ -268,7 +268,7 @@ private static function removeDir($dir) public static function setUpBeforeClass(): void { foreach (get_declared_classes() as $class) { - if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { + if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { diff --git a/Tests/DeprecationErrorHandler/deprecation/deprecation.php b/Tests/DeprecationErrorHandler/deprecation/deprecation.php index 92efd95..0ea3e5c 100644 --- a/Tests/DeprecationErrorHandler/deprecation/deprecation.php +++ b/Tests/DeprecationErrorHandler/deprecation/deprecation.php @@ -1,3 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + @trigger_error('I come from… afar! :D', \E_USER_DEPRECATED); diff --git a/Tests/DeprecationErrorHandler/fake_app/AppService.php b/Tests/DeprecationErrorHandler/fake_app/AppService.php index 2b6cb31..b8f6dc2 100644 --- a/Tests/DeprecationErrorHandler/fake_app/AppService.php +++ b/Tests/DeprecationErrorHandler/fake_app/AppService.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App\Services; use acme\lib\SomeService; @@ -20,9 +29,9 @@ public function selfDeprecation(bool $useContracts = false) { $args = [__FUNCTION__, __FUNCTION__]; if ($useContracts) { - trigger_deprecation('App', '3.0', sprintf('%s is deprecated, use %s_new instead.', ...$args)); + trigger_deprecation('App', '3.0', \sprintf('%s is deprecated, use %s_new instead.', ...$args)); } else { - @trigger_error(sprintf('Since App 3.0: %s is deprecated, use %s_new instead.', ...$args), \E_USER_DEPRECATED); + @trigger_error(\sprintf('Since App 3.0: %s is deprecated, use %s_new instead.', ...$args), \E_USER_DEPRECATED); } } diff --git a/Tests/DeprecationErrorHandler/fake_app/BarService.php b/Tests/DeprecationErrorHandler/fake_app/BarService.php index 868de5b..5e0d66c 100644 --- a/Tests/DeprecationErrorHandler/fake_app/BarService.php +++ b/Tests/DeprecationErrorHandler/fake_app/BarService.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App\Services; use acme\lib\ExtendsDeprecatedClassFromOtherVendor; diff --git a/Tests/DeprecationErrorHandler/fake_app/ExtendsDeprecatedFromVendor.php b/Tests/DeprecationErrorHandler/fake_app/ExtendsDeprecatedFromVendor.php index b4305e0..2105c3c 100644 --- a/Tests/DeprecationErrorHandler/fake_app/ExtendsDeprecatedFromVendor.php +++ b/Tests/DeprecationErrorHandler/fake_app/ExtendsDeprecatedFromVendor.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace App\Services; use fcy\lib\DeprecatedClass; diff --git a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/ExtendsDeprecatedClassFromOtherVendor.php b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/ExtendsDeprecatedClassFromOtherVendor.php index f748109..600faca 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/ExtendsDeprecatedClassFromOtherVendor.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/ExtendsDeprecatedClassFromOtherVendor.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace acme\lib; use fcy\lib\DeprecatedClass; diff --git a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php index 26a3237..e38211b 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace acme\lib; class PhpDeprecation implements \Serializable diff --git a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/SomeService.php b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/SomeService.php index cc237e6..6064426 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/SomeService.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/SomeService.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace acme\lib; use bar\lib\AnotherService; @@ -10,9 +19,9 @@ public function deprecatedApi(bool $useContracts = false) { $args = [__FUNCTION__, __FUNCTION__]; if ($useContracts) { - trigger_deprecation('acme/lib', '3.0', sprintf('%s is deprecated, use %s_new instead.', ...$args)); + trigger_deprecation('acme/lib', '3.0', \sprintf('%s is deprecated, use %s_new instead.', ...$args)); } else { - @trigger_error(sprintf('Since acme/lib 3.0: %s is deprecated, use %s_new instead.', ...$args), \E_USER_DEPRECATED); + @trigger_error(\sprintf('Since acme/lib 3.0: %s is deprecated, use %s_new instead.', ...$args), \E_USER_DEPRECATED); } } diff --git a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php index c6507d7..5784566 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + eval(<<<'EOPHP' namespace PHPUnit\Util; diff --git a/Tests/DeprecationErrorHandler/fake_vendor/autoload.php b/Tests/DeprecationErrorHandler/fake_vendor/autoload.php index 3c4471b..68db330 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/autoload.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/autoload.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + require_once __DIR__.'/composer/autoload_real.php'; return ComposerAutoloaderInitFake::getLoader(); diff --git a/Tests/DeprecationErrorHandler/fake_vendor/bar/lib/AnotherService.php b/Tests/DeprecationErrorHandler/fake_vendor/bar/lib/AnotherService.php index 2e2f0f9..2724186 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/bar/lib/AnotherService.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/bar/lib/AnotherService.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace bar\lib; class AnotherService @@ -8,9 +17,9 @@ public function deprecatedApi(bool $useContracts = false) { $args = [__FUNCTION__, __FUNCTION__]; if ($useContracts) { - trigger_deprecation('bar/lib', '3.0', sprintf('%s is deprecated, use %s_new instead.', ...$args)); + trigger_deprecation('bar/lib', '3.0', \sprintf('%s is deprecated, use %s_new instead.', ...$args)); } else { - @trigger_error(sprintf('Since bar/lib 3.0: %s is deprecated, use %s_new instead.', ...$args), \E_USER_DEPRECATED); + @trigger_error(\sprintf('Since bar/lib 3.0: %s is deprecated, use %s_new instead.', ...$args), \E_USER_DEPRECATED); } } } diff --git a/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php b/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php index 4b80d96..231ae4f 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + class ComposerLoaderFake { public function getPrefixes() @@ -27,7 +36,7 @@ public function loadClass($className) public function findFile($class) { foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) { - if (0 !== strpos($class, $prefix)) { + if (!str_starts_with($class, $prefix)) { continue; } diff --git a/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php b/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php index f6672ce..16edcaf 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php +++ b/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace fcy\lib; /** diff --git a/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php b/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php index c1c9639..f1aec32 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php +++ b/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + require_once __DIR__.'/composer/autoload_real.php'; return ComposerAutoloaderInitFakeBis::getLoader(); diff --git a/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php b/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php index aabb103..2a52065 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php +++ b/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + class ComposerLoaderFakeBis { public function getPrefixes() @@ -17,7 +26,7 @@ public function getPrefixesPsr4() public function loadClass($className) { foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) { - if (0 !== strpos($className, $prefix)) { + if (!str_starts_with($className, $prefix)) { continue; } diff --git a/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php b/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php index 8ab3230..d9c67b1 100644 --- a/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php +++ b/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace foo\lib; class SomeOtherService diff --git a/Tests/DeprecationErrorHandler/generate_phar.php b/Tests/DeprecationErrorHandler/generate_phar.php index 75125d5..df87511 100644 --- a/Tests/DeprecationErrorHandler/generate_phar.php +++ b/Tests/DeprecationErrorHandler/generate_phar.php @@ -1,4 +1,13 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $phar = new Phar(__DIR__.\DIRECTORY_SEPARATOR.'deprecation.phar', 0, 'deprecation.phar'); $phar->buildFromDirectory(__DIR__.\DIRECTORY_SEPARATOR.'deprecation'); diff --git a/Tests/DeprecationErrorHandler/php_deprecation_from_vendor_class.phpt b/Tests/DeprecationErrorHandler/php_deprecation_from_vendor_class.phpt index 1ead2ef..3048efb 100644 --- a/Tests/DeprecationErrorHandler/php_deprecation_from_vendor_class.phpt +++ b/Tests/DeprecationErrorHandler/php_deprecation_from_vendor_class.phpt @@ -1,7 +1,5 @@ --TEST-- Test that a PHP deprecation from a vendor class autoload is considered indirect. ---SKIPIF-- - --FILE-- = 80000) { - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.6') ?: '9.6'; -} else { - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.5') ?: '8.5'; -} +$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.6') ?: '9.6'; $MAX_PHPUNIT_VERSION = $getEnvVar('SYMFONY_MAX_PHPUNIT_VERSION', false); @@ -178,7 +174,7 @@ $prevCacheDir = false; } } -$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : '')); +$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'); $SYMFONY_PHPUNIT_REQUIRE = $getEnvVar('SYMFONY_PHPUNIT_REQUIRE', ''); $configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, $SYMFONY_PHPUNIT_REQUIRE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); $PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT); @@ -240,9 +236,6 @@ if ($SYMFONY_PHPUNIT_REQUIRE) { $passthruOrFail("$COMPOSER require --no-update ".$SYMFONY_PHPUNIT_REQUIRE); } - if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { - $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); - } if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) { $passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\""); @@ -267,9 +260,8 @@ } $prevRoot = getenv('COMPOSER_ROOT_VERSION'); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); - $q = '\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 80000 ? '"' : ''; // --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS - $exit = proc_close(proc_open("$q$COMPOSER update --no-dev --prefer-dist --no-progress $q", [], $p, getcwd())); + $exit = proc_close(proc_open("$COMPOSER update --no-dev --prefer-dist --no-progress", [], $p, getcwd())); putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : '')); if ($prevCacheDir) { putenv("COMPOSER_CACHE_DIR=$prevCacheDir"); @@ -340,16 +332,7 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla } chdir($oldPwd); -if ($PHPUNIT_VERSION < 8.0) { - $argv = array_filter($argv, function ($v) use (&$argc) { - if ('--do-not-cache-result' !== $v) { - return true; - } - --$argc; - - return false; - }); -} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { +if (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { $argv[] = '--do-not-cache-result'; ++$argc; } diff --git a/bootstrap.php b/bootstrap.php index 24d5934..5540904 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ -use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Deprecations\Deprecation; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; @@ -35,19 +34,6 @@ if (class_exists(Deprecation::class)) { Deprecation::withoutDeduplication(); - - if (\PHP_VERSION_ID < 80000) { - // Ignore deprecations about the annotation mapping driver when it's not possible to move to the attribute driver yet - Deprecation::ignoreDeprecations('https://github.com/doctrine/orm/issues/10098'); - } -} - -if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } } if ( diff --git a/composer.json b/composer.json index 169f0e6..b9dda6b 100644 --- a/composer.json +++ b/composer.json @@ -18,17 +18,13 @@ } ], "require": { - "php": ">=7.2.5 EVEN ON LATEST SYMFONY VERSIONS TO ALLOW USING", + "php": ">=8.1.0 EVEN ON LATEST SYMFONY VERSIONS TO ALLOW USING", "php": "THIS BRIDGE WHEN TESTING LOWEST SYMFONY VERSIONS.", - "php": ">=7.2.5" + "php": ">=8.1.0" }, "require-dev": { "symfony/deprecation-contracts": "^2.5|^3.0", - "symfony/error-handler": "^6.4|^7.0|^8.0", - "symfony/polyfill-php81": "^1.27" - }, - "conflict": { - "phpunit/phpunit": "<7.5|9.1.2" + "symfony/error-handler": "^6.4.3|^7.0.3|^8.0" }, "autoload": { "files": [ "bootstrap.php" ], From 6f802233b486131d8c23d3d88e6e6a9e091a133b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 9 Oct 2024 11:06:51 +0200 Subject: [PATCH 04/18] run tests using PHPUnit 11.5 --- Tests/CoverageListenerTest.php | 5 ++--- Tests/DeprecationErrorHandler/ConfigurationTest.php | 5 ++--- Tests/ExpectDeprecationTraitTest.php | 5 ++--- Tests/ExpectedDeprecationAnnotationTest.php | 5 ++--- Tests/FailTests/ExpectDeprecationTraitTestFail.php | 4 ++-- Tests/FailTests/NoAssertionsTestNotRisky.php | 4 ++-- Tests/FailTests/NoAssertionsTestRisky.php | 4 ++-- Tests/ProcessIsolationTest.php | 4 ++-- phpunit.xml.dist | 7 ++++--- 9 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Tests/CoverageListenerTest.php b/Tests/CoverageListenerTest.php index 54cfcdd..9d6e26e 100644 --- a/Tests/CoverageListenerTest.php +++ b/Tests/CoverageListenerTest.php @@ -11,11 +11,10 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; -/** - * @requires PHPUnit < 10 - */ +#[RequiresPhpunit('<10')] class CoverageListenerTest extends TestCase { public function test() diff --git a/Tests/DeprecationErrorHandler/ConfigurationTest.php b/Tests/DeprecationErrorHandler/ConfigurationTest.php index e9c83d2..741c1a5 100644 --- a/Tests/DeprecationErrorHandler/ConfigurationTest.php +++ b/Tests/DeprecationErrorHandler/ConfigurationTest.php @@ -11,12 +11,14 @@ namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup; use Symfony\Component\ErrorHandler\DebugClassLoader; +#[RequiresPhpunit('<10')] class ConfigurationTest extends TestCase { private $files; @@ -463,9 +465,6 @@ public function testExistingBaselineAndGeneration() $this->assertEquals(json_encode($expected, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES), file_get_contents($filename)); } - /** - * @requires PHPUnit < 10 - */ public function testBaselineGenerationWithDeprecationTriggeredByDebugClassLoader() { $filename = $this->createFile(); diff --git a/Tests/ExpectDeprecationTraitTest.php b/Tests/ExpectDeprecationTraitTest.php index 9adeca4..142d3f8 100644 --- a/Tests/ExpectDeprecationTraitTest.php +++ b/Tests/ExpectDeprecationTraitTest.php @@ -11,12 +11,11 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; -/** - * @requires PHPUnit < 10 - */ +#[RequiresPhpunit('<10')] final class ExpectDeprecationTraitTest extends TestCase { use ExpectDeprecationTrait; diff --git a/Tests/ExpectedDeprecationAnnotationTest.php b/Tests/ExpectedDeprecationAnnotationTest.php index 1db5448..6e7ba0b 100644 --- a/Tests/ExpectedDeprecationAnnotationTest.php +++ b/Tests/ExpectedDeprecationAnnotationTest.php @@ -11,11 +11,10 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; -/** - * @requires PHPUnit < 10 - */ +#[RequiresPhpunit('<10')] final class ExpectedDeprecationAnnotationTest extends TestCase { /** diff --git a/Tests/FailTests/ExpectDeprecationTraitTestFail.php b/Tests/FailTests/ExpectDeprecationTraitTestFail.php index 7bf40df..a43fe30 100644 --- a/Tests/FailTests/ExpectDeprecationTraitTestFail.php +++ b/Tests/FailTests/ExpectDeprecationTraitTestFail.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\FailTests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -19,9 +20,8 @@ * * This class is deliberately suffixed with *TestFail.php so that it is ignored * by PHPUnit. This test is designed to fail. See ../expectdeprecationfail.phpt. - * - * @requires PHPUnit < 10 */ +#[RequiresPhpunit('<10')] final class ExpectDeprecationTraitTestFail extends TestCase { use ExpectDeprecationTrait; diff --git a/Tests/FailTests/NoAssertionsTestNotRisky.php b/Tests/FailTests/NoAssertionsTestNotRisky.php index 8008287..bd259a5 100644 --- a/Tests/FailTests/NoAssertionsTestNotRisky.php +++ b/Tests/FailTests/NoAssertionsTestNotRisky.php @@ -11,15 +11,15 @@ namespace Symfony\Bridge\PhpUnit\Tests\FailTests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; /** * This class is deliberately suffixed with *TestRisky.php so that it is ignored * by PHPUnit. This test is designed to fail. See ../expectnotrisky.phpt. - * - * @requires PHPUnit < 10 */ +#[RequiresPhpunit('<10')] final class NoAssertionsTestNotRisky extends TestCase { use ExpectDeprecationTrait; diff --git a/Tests/FailTests/NoAssertionsTestRisky.php b/Tests/FailTests/NoAssertionsTestRisky.php index 5ec1375..601506a 100644 --- a/Tests/FailTests/NoAssertionsTestRisky.php +++ b/Tests/FailTests/NoAssertionsTestRisky.php @@ -11,15 +11,15 @@ namespace Symfony\Bridge\PhpUnit\Tests\FailTests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; /** * This class is deliberately suffixed with *TestRisky.php so that it is ignored * by PHPUnit. This test is designed to fail. See ../expectrisky.phpt. - * - * @requires PHPUnit < 10 */ +#[RequiresPhpunit('<10')] final class NoAssertionsTestRisky extends TestCase { use ExpectDeprecationTrait; diff --git a/Tests/ProcessIsolationTest.php b/Tests/ProcessIsolationTest.php index 07fb9a2..b517fe5 100644 --- a/Tests/ProcessIsolationTest.php +++ b/Tests/ProcessIsolationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; /** @@ -19,9 +20,8 @@ * @group legacy * * @runTestsInSeparateProcesses - * - * @requires PHPUnit < 10 */ +#[RequiresPhpunit('<10')] class ProcessIsolationTest extends TestCase { /** diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cde576e..7e31059 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,11 @@ @@ -19,7 +20,7 @@ - + ./ @@ -27,5 +28,5 @@ ./Tests ./vendor - + From 1bd1a50b2cd9e5dd9e445363e3847b25770066dd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 31 Jul 2025 14:36:46 +0200 Subject: [PATCH 05/18] replace PHPUnit annotations with attributes --- Tests/ClockMockTest.php | 2 ++ Tests/DeprecationErrorHandler/ConfigurationTest.php | 3 +++ Tests/DeprecationErrorHandler/DeprecationTest.php | 4 ++++ Tests/ExpectDeprecationTraitTest.php | 8 ++++++++ Tests/ExpectedDeprecationAnnotationTest.php | 3 +++ Tests/FailTests/NoAssertionsTestRisky.php | 2 ++ Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php | 2 ++ Tests/Fixtures/coverage/tests/CoversNothingTest.php | 2 ++ Tests/Fixtures/coverage/tests/CoversTest.php | 8 +++++--- Tests/Metadata/AttributeReaderTest.php | 2 ++ Tests/OnlyExpectingDeprecationSkippedTest.php | 4 ++++ Tests/ProcessIsolationTest.php | 2 ++ 12 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Tests/ClockMockTest.php b/Tests/ClockMockTest.php index 8424108..95c354e 100644 --- a/Tests/ClockMockTest.php +++ b/Tests/ClockMockTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ClockMock; @@ -19,6 +20,7 @@ * * @covers \Symfony\Bridge\PhpUnit\ClockMock */ +#[CoversClass(ClockMock::class)] class ClockMockTest extends TestCase { public static function setUpBeforeClass(): void diff --git a/Tests/DeprecationErrorHandler/ConfigurationTest.php b/Tests/DeprecationErrorHandler/ConfigurationTest.php index 741c1a5..3faadf3 100644 --- a/Tests/DeprecationErrorHandler/ConfigurationTest.php +++ b/Tests/DeprecationErrorHandler/ConfigurationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration; @@ -194,6 +195,7 @@ public static function provideItCanBeDisabled(): array /** * @dataProvider provideItCanBeDisabled */ + #[DataProvider('provideItCanBeDisabled')] public function testItCanBeDisabled(string $encodedString, bool $expectedEnabled) { $configuration = Configuration::fromUrlEncodedString($encodedString); @@ -240,6 +242,7 @@ public function testOutputIsNotVerboseInWeakMode() /** * @dataProvider provideDataForToleratesForGroup */ + #[DataProvider('provideDataForToleratesForGroup')] public function testToleratesForIndividualGroups(string $deprecationsHelper, array $deprecationsPerType, array $expected) { $configuration = Configuration::fromUrlEncodedString($deprecationsHelper); diff --git a/Tests/DeprecationErrorHandler/DeprecationTest.php b/Tests/DeprecationErrorHandler/DeprecationTest.php index 1519b83..337fbd1 100644 --- a/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; @@ -88,6 +89,7 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect() /** * @dataProvider mutedProvider */ + #[DataProvider('mutedProvider')] public function testItMutesOnlySpecificErrorMessagesWhenTheCallingCodeIsInPhpunit($muted, $callingClass, $message) { $trace = $this->debugBacktrace(); @@ -170,6 +172,7 @@ public static function providerGetTypeDetectsSelf(): array /** * @dataProvider providerGetTypeDetectsSelf */ + #[DataProvider('providerGetTypeDetectsSelf')] public function testGetTypeDetectsSelf(string $expectedType, string $message, string $traceClass, string $file) { $trace = [ @@ -233,6 +236,7 @@ public static function providerGetTypeUsesRightTrace(): array /** * @dataProvider providerGetTypeUsesRightTrace */ + #[DataProvider('providerGetTypeUsesRightTrace')] public function testGetTypeUsesRightTrace(string $expectedType, string $message, array $trace) { $deprecation = new Deprecation( diff --git a/Tests/ExpectDeprecationTraitTest.php b/Tests/ExpectDeprecationTraitTest.php index 142d3f8..0a4854d 100644 --- a/Tests/ExpectDeprecationTraitTest.php +++ b/Tests/ExpectDeprecationTraitTest.php @@ -11,7 +11,9 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -25,6 +27,7 @@ final class ExpectDeprecationTraitTest extends TestCase * * @group legacy */ + #[Group('legacy')] public function testOne() { $this->expectDeprecation('foo'); @@ -38,6 +41,8 @@ public function testOne() * * @runInSeparateProcess */ + #[Group('legacy')] + #[RunInSeparateProcess] public function testOneInIsolation() { $this->expectDeprecation('foo'); @@ -49,6 +54,7 @@ public function testOneInIsolation() * * @group legacy */ + #[Group('legacy')] public function testMany() { $this->expectDeprecation('foo'); @@ -64,6 +70,7 @@ public function testMany() * * @expectedDeprecation foo */ + #[Group('legacy')] public function testOneWithAnnotation() { $this->expectDeprecation('bar'); @@ -79,6 +86,7 @@ public function testOneWithAnnotation() * @expectedDeprecation foo * @expectedDeprecation bar */ + #[Group('legacy')] public function testManyWithAnnotation() { $this->expectDeprecation('ccc'); diff --git a/Tests/ExpectedDeprecationAnnotationTest.php b/Tests/ExpectedDeprecationAnnotationTest.php index 6e7ba0b..a3112cf 100644 --- a/Tests/ExpectedDeprecationAnnotationTest.php +++ b/Tests/ExpectedDeprecationAnnotationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; @@ -24,6 +25,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase * * @expectedDeprecation foo */ + #[Group('legacy')] public function testOne() { @trigger_error('foo', \E_USER_DEPRECATED); @@ -37,6 +39,7 @@ public function testOne() * @expectedDeprecation foo * @expectedDeprecation bar */ + #[Group('legacy')] public function testMany() { @trigger_error('foo', \E_USER_DEPRECATED); diff --git a/Tests/FailTests/NoAssertionsTestRisky.php b/Tests/FailTests/NoAssertionsTestRisky.php index 601506a..559b86b 100644 --- a/Tests/FailTests/NoAssertionsTestRisky.php +++ b/Tests/FailTests/NoAssertionsTestRisky.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\FailTests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -29,6 +30,7 @@ final class NoAssertionsTestRisky extends TestCase * * @group legacy */ + #[Group('legacy')] public function testOne() { $this->expectNotToPerformAssertions(); diff --git a/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php b/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php index d764638..503d675 100644 --- a/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php +++ b/Tests/Fixtures/coverage/tests/CoversDefaultClassTest.php @@ -9,11 +9,13 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \DateTime */ +#[CoversClass(DateTime::class)] class CoversDefaultClassTest extends TestCase { public function test() diff --git a/Tests/Fixtures/coverage/tests/CoversNothingTest.php b/Tests/Fixtures/coverage/tests/CoversNothingTest.php index e60ea97..8e3cb0a 100644 --- a/Tests/Fixtures/coverage/tests/CoversNothingTest.php +++ b/Tests/Fixtures/coverage/tests/CoversNothingTest.php @@ -9,11 +9,13 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\TestCase; /** * @coversNothing */ +#[CoversNothing] class CoversNothingTest extends TestCase { public function test() diff --git a/Tests/Fixtures/coverage/tests/CoversTest.php b/Tests/Fixtures/coverage/tests/CoversTest.php index f6d3406..67ac74d 100644 --- a/Tests/Fixtures/coverage/tests/CoversTest.php +++ b/Tests/Fixtures/coverage/tests/CoversTest.php @@ -9,13 +9,15 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @covers \DateTime + */ +#[CoversClass(DateTime::class)] class CoversTest extends TestCase { - /** - * @covers \DateTime - */ public function test() { $this->assertTrue(true); diff --git a/Tests/Metadata/AttributeReaderTest.php b/Tests/Metadata/AttributeReaderTest.php index d34208d..eb3a776 100644 --- a/Tests/Metadata/AttributeReaderTest.php +++ b/Tests/Metadata/AttributeReaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests\Metadata; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\Attribute\DnsSensitive; use Symfony\Bridge\PhpUnit\Attribute\TimeSensitive; @@ -22,6 +23,7 @@ class AttributeReaderTest extends TestCase /** * @dataProvider provideReadCases */ + #[DataProvider('provideReadCases')] public function testAttributesAreRead(string $method, string $attributeClass, array $expected) { $reader = new AttributeReader(); diff --git a/Tests/OnlyExpectingDeprecationSkippedTest.php b/Tests/OnlyExpectingDeprecationSkippedTest.php index 593e0b4..aede756 100644 --- a/Tests/OnlyExpectingDeprecationSkippedTest.php +++ b/Tests/OnlyExpectingDeprecationSkippedTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; /** @@ -18,6 +20,7 @@ * * @requires extension ext-dummy */ +#[RequiresPhpExtension('ext-dummy')] final class OnlyExpectingDeprecationSkippedTest extends TestCase { /** @@ -27,6 +30,7 @@ final class OnlyExpectingDeprecationSkippedTest extends TestCase * * @expectedDeprecation unreachable */ + #[Group('legacy')] public function testExpectingOnlyDeprecations() { $this->fail('should never be ran.'); diff --git a/Tests/ProcessIsolationTest.php b/Tests/ProcessIsolationTest.php index b517fe5..9e043d0 100644 --- a/Tests/ProcessIsolationTest.php +++ b/Tests/ProcessIsolationTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\TestCase; @@ -22,6 +23,7 @@ * @runTestsInSeparateProcesses */ #[RequiresPhpunit('<10')] +#[Group('legacy')] class ProcessIsolationTest extends TestCase { /** From 7d3233ff7f91585f519b3d538fca5475984ae47b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 4 Aug 2025 10:15:34 +0200 Subject: [PATCH 06/18] CS --- Tests/FailTests/ExpectDeprecationTraitTestFail.php | 5 +++++ Tests/ProcessIsolationTest.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/FailTests/ExpectDeprecationTraitTestFail.php b/Tests/FailTests/ExpectDeprecationTraitTestFail.php index a43fe30..10da25f 100644 --- a/Tests/FailTests/ExpectDeprecationTraitTestFail.php +++ b/Tests/FailTests/ExpectDeprecationTraitTestFail.php @@ -11,7 +11,9 @@ namespace Symfony\Bridge\PhpUnit\Tests\FailTests; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -31,6 +33,7 @@ final class ExpectDeprecationTraitTestFail extends TestCase * * @group legacy */ + #[Group('legacy')] public function testOne() { $this->expectDeprecation('foo'); @@ -44,6 +47,8 @@ public function testOne() * * @runInSeparateProcess */ + #[Group('legacy')] + #[RunInSeparateProcess] public function testOneInIsolation() { $this->expectDeprecation('foo'); diff --git a/Tests/ProcessIsolationTest.php b/Tests/ProcessIsolationTest.php index 9e043d0..d86e2db 100644 --- a/Tests/ProcessIsolationTest.php +++ b/Tests/ProcessIsolationTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Exception; use PHPUnit\Framework\TestCase; /** @@ -37,7 +38,7 @@ public function testIsolation() public function testCallingOtherErrorHandler() { - $this->expectException(\PHPUnit\Framework\Exception::class); + $this->expectException(Exception::class); $this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.'); trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING); From d30926f3b246cfb469984cd46c18bb1f7e93f3f7 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sun, 10 Aug 2025 00:28:14 +0200 Subject: [PATCH 07/18] chore: heredoc indentation as of PHP 7.3 https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc --- bin/simple-phpunit.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index 8a018c4..e56ceb8 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -285,30 +285,30 @@ file_put_contents($alteredFile, $alteredCode); file_put_contents('phpunit', <<<'EOPHP' -getExcludedDirectories(); - PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName())); - class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName())); -} elseif (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) { - (new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); - PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName())); - class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName())); -} else { - PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1; - PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1; -} + if (!class_exists(\SymfonyExcludeListPhpunit::class, false)) { + class SymfonyExcludeListPhpunit {} + } + if (method_exists(\PHPUnit\Util\ExcludeList::class, 'addDirectory')) { + (new PHPUnit\Util\Excludelist())->getExcludedDirectories(); + PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName())); + class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName())); + } elseif (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) { + (new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName())); + class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName())); + } else { + PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1; + PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1; + } -Symfony\Bridge\PhpUnit\TextUI\Command::main(); + Symfony\Bridge\PhpUnit\TextUI\Command::main(); -EOPHP + EOPHP ); } From 0235d5a69c96b4122cc442441ac11ece8ba795f6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 1 Aug 2025 14:58:41 +0200 Subject: [PATCH 08/18] run tests with PHPUnit 12.3 --- Tests/symfonyextensionnotregistered.phpt | 150 +++++++++++------------ 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/Tests/symfonyextensionnotregistered.phpt b/Tests/symfonyextensionnotregistered.phpt index e66b677..0a14077 100644 --- a/Tests/symfonyextensionnotregistered.phpt +++ b/Tests/symfonyextensionnotregistered.phpt @@ -23,451 +23,451 @@ Expected deprecation with message "The "Symfony\Bridge\PhpUnit\Tests\Fixtures\sy %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testTimeMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testMicrotimeMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testSleepMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testUsleepMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDateMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGmdateMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testHrtimeMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testCheckdnsrrMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsCheckRecordMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGetmxrrMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetMxMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbyaddrMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynameMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testGethostbynamelMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered with data set "test class namespace" ('Symfony\Bridge\PhpUnit\Tests') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered%stest class namespace%s ('Symfony\Bridge\PhpUnit\Tests') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered with data set "namespace derived from test namespace" ('Symfony\Bridge\PhpUnit') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered%snamespace derived from test namespace%s ('Symfony\Bridge\PhpUnit') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered with data set "explicitly configured namespace" ('App') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered%sexplicitly configured namespace%s ('App') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered with data set "explicitly configured namespace through attribute on class" ('App\Foo') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered%sexplicitly configured namespace through attribute on class%s ('App\Foo') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d %s/.phpunit/phpunit-%s/phpunit:%d -%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered with data set "explicitly configured namespace through attribute on method" ('App\Bar') +%d) Symfony\Bridge\PhpUnit\Tests\SymfonyExtension::testDnsGetRecordMockIsRegistered%sexplicitly configured namespace through attribute on method%s ('App\Bar') Failed asserting that false is true. %s/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtension.php:%d From 404547d2b4741b002a5646a80225598c21238f22 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sat, 9 Aug 2025 23:58:04 +0200 Subject: [PATCH 09/18] chore: PHP CS Fixer - restore PHP / PHPUnit rulesets --- bin/simple-phpunit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index 8a018c4..ee8a053 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -165,7 +165,7 @@ $prevCacheDir = getenv('COMPOSER_CACHE_DIR'); if ($prevCacheDir) { if (false === $absoluteCacheDir = realpath($prevCacheDir)) { - @mkdir($prevCacheDir, 0777, true); + @mkdir($prevCacheDir, 0o777, true); $absoluteCacheDir = realpath($prevCacheDir); } if ($absoluteCacheDir) { @@ -181,7 +181,7 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) { // Build a standalone phpunit without symfony/yaml nor prophecy by default - @mkdir($PHPUNIT_DIR, 0777, true); + @mkdir($PHPUNIT_DIR, 0o777, true); chdir($PHPUNIT_DIR); if (file_exists("$PHPUNIT_VERSION_DIR")) { passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s 2> NUL' : 'rm -rf %s', escapeshellarg("$PHPUNIT_VERSION_DIR.old"))); From 1bda29e68efe64c16d19338cd465d79bfb3dac4f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 14 Aug 2025 09:36:33 +0200 Subject: [PATCH 10/18] Replace __sleep/wakeup() by __(un)serialize() when BC isn't a concern --- Legacy/SymfonyTestsListenerTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index c7156c9..5547a91 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -93,12 +93,12 @@ public function __construct(array $mockedNamespaces = []) } } - public function __sleep() + public function __serialize(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } - public function __wakeup() + public function __unserialize(array $data): void { throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); } From bcc204fed472aaead478a1158447d2292caec0d4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 14 Aug 2025 16:45:04 +0200 Subject: [PATCH 11/18] [Mime] Deprecate implementing `__sleep/wakeup()` on `AbstractPart` implementations --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b9dda6b..d1e6c3b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": ">=8.1.0" }, "require-dev": { - "symfony/deprecation-contracts": "^2.5|^3.0", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^6.4.3|^7.0.3|^8.0" }, "autoload": { From 88a4dfe6551c9e18a18e3d074c6f3bc1bd6effe0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Aug 2025 09:54:15 +0200 Subject: [PATCH 12/18] [PhpUnitBridge] Patch phpunit to clear php8.5 deprecation --- bin/simple-phpunit.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index fb6286a..6c6bed1 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -270,6 +270,12 @@ exit($exit); } + $alteredCode = file_get_contents($alteredFile = './src/Runner/PhptTestCase.php'); + if (str_contains($alteredCode, " 'report_memleaks=0',\n")) { + $alteredCode = str_replace(" 'report_memleaks=0',\n", '', $alteredCode); + file_put_contents($alteredFile, $alteredCode); + } + // Mutate TestCase code if (version_compare($PHPUNIT_VERSION, '11.0', '<')) { $alteredCode = file_get_contents($alteredFile = './src/Framework/TestCase.php'); From c36f7dcb211a7824df6fd9b202ba8b80de3b9bf5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Aug 2025 10:50:15 +0200 Subject: [PATCH 13/18] [PhpUnitBridge] Code cleanup --- Legacy/PolyfillTestCaseTrait.php | 116 ------------------------------- bin/simple-phpunit.php | 5 +- 2 files changed, 2 insertions(+), 119 deletions(-) delete mode 100644 Legacy/PolyfillTestCaseTrait.php diff --git a/Legacy/PolyfillTestCaseTrait.php b/Legacy/PolyfillTestCaseTrait.php deleted file mode 100644 index 8673bdc..0000000 --- a/Legacy/PolyfillTestCaseTrait.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -use PHPUnit\Framework\Error\Error; -use PHPUnit\Framework\Error\Notice; -use PHPUnit\Framework\Error\Warning; - -/** - * This trait is @internal. - */ -trait PolyfillTestCaseTrait -{ - /** - * @param string $messageRegExp - * - * @return void - */ - public function expectExceptionMessageMatches($messageRegExp) - { - $this->expectExceptionMessageRegExp($messageRegExp); - } - - /** - * @return void - */ - public function expectNotice() - { - $this->expectException(Notice::class); - } - - /** - * @param string $message - * - * @return void - */ - public function expectNoticeMessage($message) - { - $this->expectExceptionMessage($message); - } - - /** - * @param string $regularExpression - * - * @return void - */ - public function expectNoticeMessageMatches($regularExpression) - { - $this->expectExceptionMessageMatches($regularExpression); - } - - /** - * @return void - */ - public function expectWarning() - { - $this->expectException(Warning::class); - } - - /** - * @param string $message - * - * @return void - */ - public function expectWarningMessage($message) - { - $this->expectExceptionMessage($message); - } - - /** - * @param string $regularExpression - * - * @return void - */ - public function expectWarningMessageMatches($regularExpression) - { - $this->expectExceptionMessageMatches($regularExpression); - } - - /** - * @return void - */ - public function expectError() - { - $this->expectException(Error::class); - } - - /** - * @param string $message - * - * @return void - */ - public function expectErrorMessage($message) - { - $this->expectExceptionMessage($message); - } - - /** - * @param string $regularExpression - * - * @return void - */ - public function expectErrorMessageMatches($regularExpression) - { - $this->expectExceptionMessageMatches($regularExpression); - } -} diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index 6c6bed1..cf37fac 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -270,7 +270,8 @@ exit($exit); } - $alteredCode = file_get_contents($alteredFile = './src/Runner/PhptTestCase.php'); + // Mutate PhptTestCase code + $alteredCode = file_get_contents($alteredFile = is_file('./src/Runner/PHPT/PhptTestCase.php') ? './src/Runner/PHPT/PhptTestCase.php' : './src/Runner/PhptTestCase.php'); if (str_contains($alteredCode, " 'report_memleaks=0',\n")) { $alteredCode = str_replace(" 'report_memleaks=0',\n", '', $alteredCode); file_put_contents($alteredFile, $alteredCode); @@ -282,8 +283,6 @@ if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) { $alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode); } - $alteredCode = preg_replace('/abstract class TestCase[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); - file_put_contents($alteredFile, $alteredCode); // Mutate Assert code $alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php'); From ed8f2e89eb1af209f62ef9d0f65aa9082d02cd5e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Aug 2025 11:07:33 +0200 Subject: [PATCH 14/18] [PhpUnitBridge] Fix detecting TestCase.php for phpt files --- bin/simple-phpunit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index cf37fac..eb4ba10 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -271,8 +271,8 @@ } // Mutate PhptTestCase code - $alteredCode = file_get_contents($alteredFile = is_file('./src/Runner/PHPT/PhptTestCase.php') ? './src/Runner/PHPT/PhptTestCase.php' : './src/Runner/PhptTestCase.php'); - if (str_contains($alteredCode, " 'report_memleaks=0',\n")) { + $alteredFile = defined('GLOB_BRACE') ? glob('./src/Runner/{Phpt/,PHPT/Phpt,Phpt}TestCase.php', GLOB_BRACE) : false; + if ($alteredFile && str_contains($alteredCode = file_get_contents($alteredFile)[0], " 'report_memleaks=0',\n")) { $alteredCode = str_replace(" 'report_memleaks=0',\n", '', $alteredCode); file_put_contents($alteredFile, $alteredCode); } From 6345f0a2fe59a8250dc718c179e224480447a26b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Aug 2025 11:11:25 +0200 Subject: [PATCH 15/18] Fix typo --- bin/simple-phpunit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index eb4ba10..a3363f3 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -272,7 +272,7 @@ // Mutate PhptTestCase code $alteredFile = defined('GLOB_BRACE') ? glob('./src/Runner/{Phpt/,PHPT/Phpt,Phpt}TestCase.php', GLOB_BRACE) : false; - if ($alteredFile && str_contains($alteredCode = file_get_contents($alteredFile)[0], " 'report_memleaks=0',\n")) { + if ($alteredFile && str_contains($alteredCode = file_get_contents($alteredFile[0]), " 'report_memleaks=0',\n")) { $alteredCode = str_replace(" 'report_memleaks=0',\n", '', $alteredCode); file_put_contents($alteredFile, $alteredCode); } From 9f4f26c679107f746c9b71c0e3428eb04da19fa3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Aug 2025 11:14:13 +0200 Subject: [PATCH 16/18] Fix typo (bis) --- bin/simple-phpunit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index a3363f3..de3f847 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -274,7 +274,7 @@ $alteredFile = defined('GLOB_BRACE') ? glob('./src/Runner/{Phpt/,PHPT/Phpt,Phpt}TestCase.php', GLOB_BRACE) : false; if ($alteredFile && str_contains($alteredCode = file_get_contents($alteredFile[0]), " 'report_memleaks=0',\n")) { $alteredCode = str_replace(" 'report_memleaks=0',\n", '', $alteredCode); - file_put_contents($alteredFile, $alteredCode); + file_put_contents($alteredFile[0], $alteredCode); } // Mutate TestCase code From 86465d6494876ed8d3c1f1bc7ecc175b255f88b3 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 20 Aug 2025 22:30:05 +0200 Subject: [PATCH 17/18] revert patching of PHPUnit about memleak reports The corresponding patch has been released for all relevant PHPUnit versions. --- bin/simple-phpunit.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index de3f847..b4b348c 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -270,13 +270,6 @@ exit($exit); } - // Mutate PhptTestCase code - $alteredFile = defined('GLOB_BRACE') ? glob('./src/Runner/{Phpt/,PHPT/Phpt,Phpt}TestCase.php', GLOB_BRACE) : false; - if ($alteredFile && str_contains($alteredCode = file_get_contents($alteredFile[0]), " 'report_memleaks=0',\n")) { - $alteredCode = str_replace(" 'report_memleaks=0',\n", '', $alteredCode); - file_put_contents($alteredFile[0], $alteredCode); - } - // Mutate TestCase code if (version_compare($PHPUNIT_VERSION, '11.0', '<')) { $alteredCode = file_get_contents($alteredFile = './src/Framework/TestCase.php'); From 8988172769ef5219b7cf477f9de7a5e537e04822 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 15 Sep 2025 09:59:31 +0200 Subject: [PATCH 18/18] use a compatible config file when running tests with PHPUnit 9.6 --- .gitattributes | 1 + phpunit-9.6.xml.dist | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 phpunit-9.6.xml.dist diff --git a/.gitattributes b/.gitattributes index 14c3c35..0a9dafc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ /Tests export-ignore /phpunit.xml.dist export-ignore +/phpunit-9.6.xml.dist export-ignore /.git* export-ignore diff --git a/phpunit-9.6.xml.dist b/phpunit-9.6.xml.dist new file mode 100644 index 0000000..6f9542e --- /dev/null +++ b/phpunit-9.6.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + ./Tests/ + ./Tests/DeprecationErrorHandler/ + + + + + + ./ + + + ./Tests + ./vendor + + +