Issue #3402444 by mondrake, Spokje, neclimdul, longwave: Deprecate Test Suites, no longer available in PHPUnit 10
(cherry picked from commit 79e8ae5df1
)
merge-requests/6829/head
parent
9cd5486566
commit
d176ccd28c
|
@ -2933,3 +2933,48 @@ parameters:
|
||||||
"""
|
"""
|
||||||
count: 1
|
count: 1
|
||||||
path: tests/Drupal/Tests/Listeners/DrupalListener.php
|
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
|
||||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace Drupal\Tests\Core\Test;
|
namespace Drupal\Tests\Core\Test;
|
||||||
|
|
||||||
use Drupal\Tests\UnitTestCase;
|
use Drupal\Tests\UnitTestCase;
|
||||||
|
use Drupal\TestTools\PhpUnitCompatibility\RunnerVersion;
|
||||||
use Symfony\Component\Process\Process;
|
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.
|
* 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() {
|
public function testPhpUnitListTests() {
|
||||||
// Generate the list of tests for all the tests the suites can discover.
|
$command = [
|
||||||
// The goal here is to successfully generate the list, without any
|
'vendor/bin/phpunit',
|
||||||
// duplicate namespace errors or so forth. This keeps us from committing
|
'--configuration',
|
||||||
// tests which don't break under run-tests.sh, but do break under the
|
'core',
|
||||||
// phpunit test runner tool.
|
'--list-tests',
|
||||||
$process = Process::fromShellCommandline('vendor/bin/phpunit --configuration core --verbose --list-tests');
|
];
|
||||||
$process->setWorkingDirectory($this->root)
|
|
||||||
|
// PHPUnit 10 dropped the --verbose command line option.
|
||||||
|
if (RunnerVersion::getMajor() < 10) {
|
||||||
|
$command[] = '--verbose';
|
||||||
|
}
|
||||||
|
|
||||||
|
$process = new Process($command, $this->root);
|
||||||
|
$process
|
||||||
->setTimeout(300)
|
->setTimeout(300)
|
||||||
->setIdleTimeout(300);
|
->setIdleTimeout(300)
|
||||||
$process->run();
|
->run();
|
||||||
$this->assertEquals(0, $process->getExitCode(),
|
$this->assertEquals(0, $process->getExitCode(),
|
||||||
'COMMAND: ' . $process->getCommandLine() . "\n" .
|
'COMMAND: ' . $process->getCommandLine() . "\n" .
|
||||||
'OUTPUT: ' . $process->getOutput() . "\n" .
|
'OUTPUT: ' . $process->getOutput() . "\n" .
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\Test;
|
||||||
use Drupal\Tests\TestSuites\TestSuiteBase;
|
use Drupal\Tests\TestSuites\TestSuiteBase;
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||||
|
|
||||||
// The test suite class is not part of the autoloader, we need to include it
|
// The test suite class is not part of the autoloader, we need to include it
|
||||||
// manually.
|
// manually.
|
||||||
|
@ -19,6 +20,8 @@ require_once __DIR__ . '/../../../../TestSuites/TestSuiteBase.php';
|
||||||
*/
|
*/
|
||||||
class TestSuiteBaseTest extends TestCase {
|
class TestSuiteBaseTest extends TestCase {
|
||||||
|
|
||||||
|
use ExpectDeprecationTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to set up the file system.
|
* Helper method to set up the file system.
|
||||||
*
|
*
|
||||||
|
@ -81,11 +84,16 @@ class TestSuiteBaseTest extends TestCase {
|
||||||
/**
|
/**
|
||||||
* Tests for special case behavior of unit test suite namespaces in core.
|
* Tests for special case behavior of unit test suite namespaces in core.
|
||||||
*
|
*
|
||||||
|
* @group legacy
|
||||||
|
*
|
||||||
* @covers ::addTestsBySuiteNamespace
|
* @covers ::addTestsBySuiteNamespace
|
||||||
*
|
*
|
||||||
* @dataProvider provideCoreTests
|
* @dataProvider provideCoreTests
|
||||||
*/
|
*/
|
||||||
public function testAddTestsBySuiteNamespaceCore($filesystem, $suite_namespace, $expected_tests) {
|
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.
|
// Set up the file system.
|
||||||
$vfs = vfsStream::setup('root');
|
$vfs = vfsStream::setup('root');
|
||||||
vfsStream::create($filesystem, $vfs);
|
vfsStream::create($filesystem, $vfs);
|
||||||
|
@ -118,6 +126,8 @@ class TestSuiteBaseTest extends TestCase {
|
||||||
*
|
*
|
||||||
* We use this class to alter the behavior of TestSuiteBase so it can be
|
* We use this class to alter the behavior of TestSuiteBase so it can be
|
||||||
* testable.
|
* testable.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
*/
|
*/
|
||||||
class StubTestSuiteBase extends TestSuiteBase {
|
class StubTestSuiteBase extends TestSuiteBase {
|
||||||
|
|
||||||
|
@ -128,6 +138,12 @@ class StubTestSuiteBase extends TestSuiteBase {
|
||||||
*/
|
*/
|
||||||
public $testFiles = [];
|
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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,6 +8,11 @@ require_once __DIR__ . '/TestSuiteBase.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discovers tests for the build test suite.
|
* 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 {
|
class BuildTestSuite extends TestSuiteBase {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@ require_once __DIR__ . '/TestSuiteBase.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discovers tests for the functional-javascript test suite.
|
* 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 {
|
class FunctionalJavascriptTestSuite extends TestSuiteBase {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@ require_once __DIR__ . '/TestSuiteBase.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discovers tests for the functional test suite.
|
* 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 {
|
class FunctionalTestSuite extends TestSuiteBase {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@ require_once __DIR__ . '/TestSuiteBase.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discovers tests for the kernel test suite.
|
* 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 {
|
class KernelTestSuite extends TestSuiteBase {
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,11 @@ use PHPUnit\Framework\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Drupal test suites.
|
* 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 {
|
abstract class TestSuiteBase extends TestSuite {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@ require_once __DIR__ . '/TestSuiteBase.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discovers tests for the unit test suite.
|
* 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 {
|
class UnitTestSuite extends TestSuiteBase {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue