diff --git a/ChangeLog-9.6.md b/ChangeLog-9.6.md index 9793f193f43..bd6292ae33a 100644 --- a/ChangeLog-9.6.md +++ b/ChangeLog-9.6.md @@ -4,4 +4,8 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil ## [9.6.0] - 2023-02-03 +### Changed + +* [#5132](https://github.com/sebastianbergmann/phpunit/issues/5132): Deprecate `Test` suffix for abstract test case classes + [9.6.0]: https://github.com/sebastianbergmann/phpunit/compare/9.5...9.6 diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index ce738533f05..a51538b18d0 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -456,6 +456,15 @@ public function addTestFile(string $filename): void continue; } + if ($class->isAbstract() && $class->isSubclassOf(TestCase::class)) { + $this->addWarning( + sprintf( + 'Abstract test case classes with "Test" suffix are deprecated (%s)', + $class->getName() + ) + ); + } + if (!$class->isAbstract()) { if ($class->hasMethod(BaseTestRunner::SUITE_METHODNAME)) { try { diff --git a/tests/end-to-end/generic/abstract-test-class/directory-with-concrete-test-class-and-abstract-test-class-with-test-suffix.phpt b/tests/end-to-end/generic/abstract-test-class/directory-with-concrete-test-class-and-abstract-test-class-with-test-suffix.phpt index 35bf84383fb..a97d201bc93 100644 --- a/tests/end-to-end/generic/abstract-test-class/directory-with-concrete-test-class-and-abstract-test-class-with-test-suffix.phpt +++ b/tests/end-to-end/generic/abstract-test-class/directory-with-concrete-test-class-and-abstract-test-class-with-test-suffix.phpt @@ -11,6 +11,8 @@ PHPUnit\TextUI\Command::main(); --EXPECTF-- PHPUnit %s by Sebastian Bergmann and contributors. +Warning: Abstract test case classes with "Test" suffix are deprecated (PHPUnit\TestFixture\AbstractTest) + . 1 / 1 (100%) Time: %s, Memory: %s diff --git a/tests/end-to-end/generic/test-suffix-multiple.phpt b/tests/end-to-end/generic/test-suffix-multiple.phpt index 5302accc6cd..3451cca0498 100644 --- a/tests/end-to-end/generic/test-suffix-multiple.phpt +++ b/tests/end-to-end/generic/test-suffix-multiple.phpt @@ -19,6 +19,7 @@ Warning: Test case class not matching filename is deprecated Warning: Test case class not matching filename is deprecated in %sConcreteTest.my.php Class name was 'ConcreteWithMyCustomExtensionTest', expected 'ConcreteTest' +Warning: Abstract test case classes with "Test" suffix are deprecated (PHPUnit\TestFixture\AbstractTest) ..... 5 / 5 (100%)