summaryrefslogtreecommitdiffstatshomepage
path: root/core
diff options
context:
space:
mode:
authorcatch <catch@35733.no-reply.drupal.org>2024-02-14 11:05:15 +0000
committercatch <catch@35733.no-reply.drupal.org>2024-02-14 11:05:15 +0000
commit4c6cd6e343bc18830b306e89b287b1a2c20d0ecd (patch)
tree2329c7d687df3a07d1265c43ae103c6e590cf4d2 /core
parent54a8e1befad89d141ebc183579dc16f9aecc056b (diff)
downloaddrupal-4c6cd6e343bc18830b306e89b287b1a2c20d0ecd.tar.gz
drupal-4c6cd6e343bc18830b306e89b287b1a2c20d0ecd.zip
Issue #3405353 by mondrake, neclimdul, smustgrave: Convert use of TestCase::getName() to forward compatible TestCase::name()
Diffstat (limited to 'core')
-rw-r--r--core/modules/jsonapi/tests/src/Functional/ConfigEntityResourceTestBase.php2
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php2
-rw-r--r--core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php2
-rw-r--r--core/tests/Drupal/BuildTests/Framework/BuildTestBase.php2
-rw-r--r--core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php7
-rw-r--r--core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php2
-rw-r--r--core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php4
-rw-r--r--core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php4
-rw-r--r--core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php4
-rw-r--r--core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php8
10 files changed, 28 insertions, 9 deletions
diff --git a/core/modules/jsonapi/tests/src/Functional/ConfigEntityResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ConfigEntityResourceTestBase.php
index e80a96d4051..f1bad7ce340 100644
--- a/core/modules/jsonapi/tests/src/Functional/ConfigEntityResourceTestBase.php
+++ b/core/modules/jsonapi/tests/src/Functional/ConfigEntityResourceTestBase.php
@@ -27,7 +27,7 @@ abstract class ConfigEntityResourceTestBase extends ResourceTestBase {
* {@inheritdoc}
*/
public function setUp(): void {
- if (in_array($this->getName(), static::SKIP_METHODS, TRUE)) {
+ if (in_array($this->name(), static::SKIP_METHODS, TRUE)) {
// Skip before installing Drupal to prevent unnecessary use of resources.
$this->markTestSkipped("Not yet supported for config entities.");
}
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php
index 0c351aac4be..56f6db4bdf0 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php
@@ -80,7 +80,7 @@ abstract class MigrateSourceTestBase extends KernelTestBase {
protected function getPluginClass() {
$annotations = Test::parseTestMethodAnnotations(
static::class,
- $this->getName()
+ $this->name()
);
if (isset($annotations['class']['covers'])) {
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php
index 152b781de8c..05609db738d 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ConfigEntityResourceTestBase.php
@@ -20,7 +20,7 @@ abstract class ConfigEntityResourceTestBase extends EntityResourceTestBase {
* {@inheritdoc}
*/
protected function setUp(): void {
- if (in_array($this->getName(), static::SKIP_METHODS, TRUE)) {
+ if (in_array($this->name(), static::SKIP_METHODS, TRUE)) {
// Skip before installing Drupal to prevent unnecessary use of resources.
$this->markTestSkipped("Not yet supported for config entities.");
}
diff --git a/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php b/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php
index 408143aeaa5..37551736982 100644
--- a/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php
+++ b/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php
@@ -160,7 +160,7 @@ abstract class BuildTestBase extends TestCase {
// Set up the workspace directory.
// @todo Glean working directory from env vars, etc.
$fs = new SymfonyFilesystem();
- $this->workspaceDir = $fs->tempnam(DrupalFilesystem::getOsTemporaryDirectory(), '/build_workspace_' . md5($this->getName() . microtime(TRUE)));
+ $this->workspaceDir = $fs->tempnam(DrupalFilesystem::getOsTemporaryDirectory(), '/build_workspace_' . md5($this->name() . microtime(TRUE)));
$fs->remove($this->workspaceDir);
$fs->mkdir($this->workspaceDir);
$this->initMink();
diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php
index 4bb8b01e194..8d647a5c748 100644
--- a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php
+++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php
@@ -9,4 +9,11 @@ namespace Drupal\TestTools\PhpUnitCompatibility\PhpUnit9;
*/
trait TestCompatibilityTrait {
+ /**
+ * Get test name.
+ */
+ public function name(): string {
+ return $this->getName();
+ }
+
}
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php
index 24fcdfce298..1b2099f2e3a 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php
@@ -59,7 +59,7 @@ class ComposerHookTest extends BuildTestBase {
$this->fileSystem = new Filesystem();
$this->fixtures = new Fixtures();
$this->fixtures->createIsolatedComposerCacheDir();
- $this->fixturesDir = $this->fixtures->tmpDir($this->getName());
+ $this->fixturesDir = $this->fixtures->tmpDir($this->name());
$replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->fixtures->projectRoot()];
$this->fixtures->cloneFixtureProjects($this->fixturesDir, $replacements);
}
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
index 9e50d3c92bf..c23631c7b54 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
@@ -8,6 +8,7 @@ use Composer\Util\Filesystem;
use Drupal\Tests\Composer\Plugin\Scaffold\Fixtures;
use Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait;
use Drupal\Tests\Composer\Plugin\Scaffold\ExecTrait;
+use Drupal\Tests\PhpUnitCompatibilityTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -22,6 +23,7 @@ use PHPUnit\Framework\TestCase;
class ManageGitIgnoreTest extends TestCase {
use ExecTrait;
use AssertUtilsTrait;
+ use PhpUnitCompatibilityTrait;
/**
* The root of this project.
@@ -83,7 +85,7 @@ class ManageGitIgnoreTest extends TestCase {
* The path to the fixture directory.
*/
protected function createSutWithGit($fixture_name) {
- $this->fixturesDir = $this->fixtures->tmpDir($this->getName());
+ $this->fixturesDir = $this->fixtures->tmpDir($this->name());
$sut = $this->fixturesDir . '/' . $fixture_name;
$replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->projectRoot];
$this->fixtures->cloneFixtureProjects($this->fixturesDir, $replacements);
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
index 8f3055f7ce2..55ecf23c99c 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
@@ -8,6 +8,7 @@ use Composer\Util\Filesystem;
use Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait;
use Drupal\Tests\Composer\Plugin\Scaffold\Fixtures;
use Drupal\Tests\Composer\Plugin\Scaffold\ScaffoldTestResult;
+use Drupal\Tests\PhpUnitCompatibilityTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -20,6 +21,7 @@ use PHPUnit\Framework\TestCase;
*/
class ScaffoldTest extends TestCase {
use AssertUtilsTrait;
+ use PhpUnitCompatibilityTrait;
/**
* The root of this project.
@@ -65,7 +67,7 @@ class ScaffoldTest extends TestCase {
// a directory will be created in the system's temporary directory.
$this->fixturesDir = getenv('SCAFFOLD_FIXTURE_DIR');
if (!$this->fixturesDir) {
- $this->fixturesDir = $this->fixtures->tmpDir($this->getName());
+ $this->fixturesDir = $this->fixtures->tmpDir($this->name());
}
}
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php
index 20eb6d1e5a1..f28ec78ca51 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php
@@ -8,6 +8,7 @@ use Composer\Util\Filesystem;
use Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait;
use Drupal\Tests\Composer\Plugin\Scaffold\ExecTrait;
use Drupal\Tests\Composer\Plugin\Scaffold\Fixtures;
+use Drupal\Tests\PhpUnitCompatibilityTrait;
use PHPUnit\Framework\TestCase;
/**
@@ -27,6 +28,7 @@ class ScaffoldUpgradeTest extends TestCase {
use AssertUtilsTrait;
use ExecTrait;
+ use PhpUnitCompatibilityTrait;
/**
* The Fixtures object.
@@ -58,7 +60,7 @@ class ScaffoldUpgradeTest extends TestCase {
if (str_contains($composerVersionLine, 'Composer version 2')) {
$this->markTestSkipped('We cannot run the scaffold upgrade test with Composer 2 until we have a stable version of drupal/core-composer-scaffold to start from that we can install with Composer 2.x.');
}
- $this->fixturesDir = $this->fixtures->tmpDir($this->getName());
+ $this->fixturesDir = $this->fixtures->tmpDir($this->name());
$replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->fixtures->projectRoot()];
$this->fixtures->cloneFixtureProjects($this->fixturesDir, $replacements);
$topLevelProjectDir = 'drupal-drupal';
diff --git a/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php b/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php
index 3bba95e3a76..932bd03a3e8 100644
--- a/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php
+++ b/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php
@@ -15,9 +15,15 @@ class_alias("Drupal\TestTools\PhpUnitCompatibility\PhpUnit" . RunnerVersion::get
if (FALSE) {
/**
- * Makes Drupal's test API forward compatible with multiple versions of PHPUnit.
+ * Makes Drupal's test API forward compatible with future PHPUnit releases.
+ *
+ * This stub is present here to allow PHPStan identify the methods present
+ * in the version-bound trait.
*/
trait PhpUnitCompatibilityTrait {
+
+ use \Drupal\TestTools\PhpUnitCompatibility\PhpUnit9\TestCompatibilityTrait;
+
}
}