Skip to content
Snippets Groups Projects
Commit 4c6cd6e3 authored by catch's avatar catch
Browse files

Issue #3405353 by mondrake, neclimdul, smustgrave: Convert use of...

Issue #3405353 by mondrake, neclimdul, smustgrave: Convert use of TestCase::getName() to forward compatible TestCase::name()
parent 54a8e1be
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 9 deletions
......@@ -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.");
}
......
......@@ -80,7 +80,7 @@ protected function setUp(): void {
protected function getPluginClass() {
$annotations = Test::parseTestMethodAnnotations(
static::class,
$this->getName()
$this->name()
);
if (isset($annotations['class']['covers'])) {
......
......@@ -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.");
}
......
......@@ -160,7 +160,7 @@ protected function setUp(): void {
// 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();
......
......@@ -9,4 +9,11 @@
*/
trait TestCompatibilityTrait {
/**
* Get test name.
*/
public function name(): string {
return $this->getName();
}
}
......@@ -59,7 +59,7 @@ protected function setUp(): void {
$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);
}
......
......@@ -8,6 +8,7 @@
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 @@
class ManageGitIgnoreTest extends TestCase {
use ExecTrait;
use AssertUtilsTrait;
use PhpUnitCompatibilityTrait;
/**
* The root of this project.
......@@ -83,7 +85,7 @@ protected function tearDown(): void {
* 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);
......
......@@ -8,6 +8,7 @@
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 @@
*/
class ScaffoldTest extends TestCase {
use AssertUtilsTrait;
use PhpUnitCompatibilityTrait;
/**
* The root of this project.
......@@ -65,7 +67,7 @@ protected function setUp(): void {
// 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());
}
}
......
......@@ -8,6 +8,7 @@
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 @@ public function testScaffoldUpgrade() {
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';
......
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment