diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 42dae7ffe324b69f5ff1573151bb8b423ad4cbe5..248968fa05fdb17a5c92e4c64fe3542b349ff975 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -2933,3 +2933,48 @@ parameters: """ count: 1 path: tests/Drupal/Tests/Listeners/DrupalListener.php + + - + message: """ + #^Class Drupal\\\\Tests\\\\TestSuites\\\\BuildTestSuite extends deprecated class Drupal\\\\Tests\\\\TestSuites\\\\TestSuiteBase\\: + in drupal\\:10\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no + replacement and test discovery will be handled differently in PHPUnit 10\\.$# + """ + count: 1 + path: tests/TestSuites/BuildTestSuite.php + + - + message: """ + #^Class Drupal\\\\Tests\\\\TestSuites\\\\FunctionalJavascriptTestSuite extends deprecated class Drupal\\\\Tests\\\\TestSuites\\\\TestSuiteBase\\: + in drupal\\:10\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no + replacement and test discovery will be handled differently in PHPUnit 10\\.$# + """ + count: 1 + path: tests/TestSuites/FunctionalJavascriptTestSuite.php + + - + message: """ + #^Class Drupal\\\\Tests\\\\TestSuites\\\\FunctionalTestSuite extends deprecated class Drupal\\\\Tests\\\\TestSuites\\\\TestSuiteBase\\: + in drupal\\:10\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no + replacement and test discovery will be handled differently in PHPUnit 10\\.$# + """ + count: 1 + path: tests/TestSuites/FunctionalTestSuite.php + + - + message: """ + #^Class Drupal\\\\Tests\\\\TestSuites\\\\KernelTestSuite extends deprecated class Drupal\\\\Tests\\\\TestSuites\\\\TestSuiteBase\\: + in drupal\\:10\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no + replacement and test discovery will be handled differently in PHPUnit 10\\.$# + """ + count: 1 + path: tests/TestSuites/KernelTestSuite.php + + - + message: """ + #^Class Drupal\\\\Tests\\\\TestSuites\\\\UnitTestSuite extends deprecated class Drupal\\\\Tests\\\\TestSuites\\\\TestSuiteBase\\: + in drupal\\:10\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no + replacement and test discovery will be handled differently in PHPUnit 10\\.$# + """ + count: 1 + path: tests/TestSuites/UnitTestSuite.php diff --git a/core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php b/core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php index 0931f20e02799680977bb2456517c987f3390a0d..a240af9d4cbb7089ad26b31bfb1b2a46b8c42e4a 100644 --- a/core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php +++ b/core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\Core\Test; use Drupal\Tests\UnitTestCase; +use Drupal\TestTools\PhpUnitCompatibility\RunnerVersion; use Symfony\Component\Process\Process; /** @@ -15,18 +16,31 @@ class PhpUnitCliTest extends UnitTestCase { /** * Ensure that the test suites are able to discover tests without incident. + * + * Generate the list of tests for all the tests that PHPUnit can discover. + * The goal here is to successfully generate the list, without any + * duplicate namespace errors, deprecation errors or so forth. This keeps + * us from committing tests which don't break under run-tests.sh, but do + * break under the PHPUnit CLI test runner tool. */ public function testPhpUnitListTests() { - // Generate the list of tests for all the tests the suites can discover. - // The goal here is to successfully generate the list, without any - // duplicate namespace errors or so forth. This keeps us from committing - // tests which don't break under run-tests.sh, but do break under the - // phpunit test runner tool. - $process = Process::fromShellCommandline('vendor/bin/phpunit --configuration core --verbose --list-tests'); - $process->setWorkingDirectory($this->root) + $command = [ + 'vendor/bin/phpunit', + '--configuration', + 'core', + '--list-tests', + ]; + + // PHPUnit 10 dropped the --verbose command line option. + if (RunnerVersion::getMajor() < 10) { + $command[] = '--verbose'; + } + + $process = new Process($command, $this->root); + $process ->setTimeout(300) - ->setIdleTimeout(300); - $process->run(); + ->setIdleTimeout(300) + ->run(); $this->assertEquals(0, $process->getExitCode(), 'COMMAND: ' . $process->getCommandLine() . "\n" . 'OUTPUT: ' . $process->getOutput() . "\n" . diff --git a/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php b/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php index 2589132ca2f8eef89fb6e558b50fbb95ad0aae2f..1f53f981775e562bed4f5a4073bd641a569403b8 100644 --- a/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php @@ -7,6 +7,7 @@ use Drupal\Tests\TestSuites\TestSuiteBase; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; // The test suite class is not part of the autoloader, we need to include it // manually. @@ -19,6 +20,8 @@ */ class TestSuiteBaseTest extends TestCase { + use ExpectDeprecationTrait; + /** * Helper method to set up the file system. * @@ -81,11 +84,16 @@ public function provideCoreTests() { /** * Tests for special case behavior of unit test suite namespaces in core. * + * @group legacy + * * @covers ::addTestsBySuiteNamespace * * @dataProvider provideCoreTests */ public function testAddTestsBySuiteNamespaceCore($filesystem, $suite_namespace, $expected_tests) { + + $this->expectDeprecation('Drupal\\Tests\\Core\\Test\\StubTestSuiteBase is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement and test discovery will be handled differently in PHPUnit 10. See https://www.drupal.org/node/3405829'); + // Set up the file system. $vfs = vfsStream::setup('root'); vfsStream::create($filesystem, $vfs); @@ -118,6 +126,8 @@ public function testLocalTimeZone() { * * We use this class to alter the behavior of TestSuiteBase so it can be * testable. + * + * @phpstan-ignore-next-line */ class StubTestSuiteBase extends TestSuiteBase { @@ -128,6 +138,12 @@ class StubTestSuiteBase extends TestSuiteBase { */ public $testFiles = []; + public function __construct(string $name) { + @trigger_error(__CLASS__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement and test discovery will be handled differently in PHPUnit 10. See https://www.drupal.org/node/3405829', E_USER_DEPRECATED); + // @phpstan-ignore-next-line + parent::__construct($name); + } + /** * {@inheritdoc} */ diff --git a/core/tests/TestSuites/BuildTestSuite.php b/core/tests/TestSuites/BuildTestSuite.php index 39c4660c7aae42832af5614363d5499287259f65..c26bf44e59f1b28d51804543bdb1cf0b0f2afbaa 100644 --- a/core/tests/TestSuites/BuildTestSuite.php +++ b/core/tests/TestSuites/BuildTestSuite.php @@ -8,6 +8,11 @@ /** * Discovers tests for the build test suite. + * + * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no + * replacement and test discovery will be handled differently in PHPUnit 10. + * + * @see https://www.drupal.org/node/3405829 */ class BuildTestSuite extends TestSuiteBase { diff --git a/core/tests/TestSuites/FunctionalJavascriptTestSuite.php b/core/tests/TestSuites/FunctionalJavascriptTestSuite.php index d026e725e82accd649bb0a7392c0e9fca71078ea..5ae2325121b9e8d865b00ac58340bd6862697b3d 100644 --- a/core/tests/TestSuites/FunctionalJavascriptTestSuite.php +++ b/core/tests/TestSuites/FunctionalJavascriptTestSuite.php @@ -8,6 +8,11 @@ /** * Discovers tests for the functional-javascript test suite. + * + * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no + * replacement and test discovery will be handled differently in PHPUnit 10. + * + * @see https://www.drupal.org/node/3405829 */ class FunctionalJavascriptTestSuite extends TestSuiteBase { diff --git a/core/tests/TestSuites/FunctionalTestSuite.php b/core/tests/TestSuites/FunctionalTestSuite.php index 1ddbde2b32e4dd61fb9aae68d59e665f4e026c02..20aed98deec65ed359b18248ef0f867bd635a272 100644 --- a/core/tests/TestSuites/FunctionalTestSuite.php +++ b/core/tests/TestSuites/FunctionalTestSuite.php @@ -8,6 +8,11 @@ /** * Discovers tests for the functional test suite. + * + * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no + * replacement and test discovery will be handled differently in PHPUnit 10. + * + * @see https://www.drupal.org/node/3405829 */ class FunctionalTestSuite extends TestSuiteBase { diff --git a/core/tests/TestSuites/KernelTestSuite.php b/core/tests/TestSuites/KernelTestSuite.php index 1fb4be33f4c3ad72e44e044223c118fe4560349d..0916c8528facb8d4b89dcadeca3835e4888a7c2b 100644 --- a/core/tests/TestSuites/KernelTestSuite.php +++ b/core/tests/TestSuites/KernelTestSuite.php @@ -8,6 +8,11 @@ /** * Discovers tests for the kernel test suite. + * + * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no + * replacement and test discovery will be handled differently in PHPUnit 10. + * + * @see https://www.drupal.org/node/3405829 */ class KernelTestSuite extends TestSuiteBase { diff --git a/core/tests/TestSuites/TestSuiteBase.php b/core/tests/TestSuites/TestSuiteBase.php index 70ee9f7c5a1fa4b79960094083b94c5b5ac1aaad..435116d86584fc5f5616589d5a94bde4c2fcea21 100644 --- a/core/tests/TestSuites/TestSuiteBase.php +++ b/core/tests/TestSuites/TestSuiteBase.php @@ -9,6 +9,11 @@ /** * Base class for Drupal test suites. + * + * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no + * replacement and test discovery will be handled differently in PHPUnit 10. + * + * @see https://www.drupal.org/node/3405829 */ abstract class TestSuiteBase extends TestSuite { diff --git a/core/tests/TestSuites/UnitTestSuite.php b/core/tests/TestSuites/UnitTestSuite.php index c24d8f85b94f8898b0968d9d13c18d680a390e84..db779652db46c86ab6a67e016affc936e12b4961 100644 --- a/core/tests/TestSuites/UnitTestSuite.php +++ b/core/tests/TestSuites/UnitTestSuite.php @@ -8,6 +8,11 @@ /** * Discovers tests for the unit test suite. + * + * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no + * replacement and test discovery will be handled differently in PHPUnit 10. + * + * @see https://www.drupal.org/node/3405829 */ class UnitTestSuite extends TestSuiteBase {