Issue #3405353 by mondrake, neclimdul, smustgrave: Convert use of TestCase::getName() to forward compatible TestCase::name()
parent
54a8e1befa
commit
4c6cd6e343
|
@ -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 @@ abstract class MigrateSourceTestBase extends KernelTestBase {
|
|||
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 @@ 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();
|
||||
|
|
|
@ -9,4 +9,11 @@ namespace Drupal\TestTools\PhpUnitCompatibility\PhpUnit9;
|
|||
*/
|
||||
trait TestCompatibilityTrait {
|
||||
|
||||
/**
|
||||
* Get test name.
|
||||
*/
|
||||
public function name(): string {
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue