class ConfigEntityValidationTestBaseUnsharedTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigEntityValidationTestBaseUnsharedTest.php \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBaseUnsharedTest
Tests a subclass that does not share its environment.
This class carries no ShareEnvironment attribute on purpose, and it assigns ::$entity from ::setUp() after the parent method ran. Subclasses wrote their fixture that way before the shared environment existed, and contrib subclasses still do. Every test method of the base class runs here, against a fixture built once per test method.
Attributes
#[Group('config')]
#[Group('Validation')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBaseUnsharedTest extends \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of ConfigEntityValidationTestBaseUnsharedTest
See also
\Drupal\TestTools\Attribute\ShareEnvironment
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigEntityValidationTestBaseUnsharedTest.php, line 22
Namespace
Drupal\KernelTests\Core\ConfigView source
class ConfigEntityValidationTestBaseUnsharedTest extends ConfigEntityValidationTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->entity = DateFormat::create([
'id' => 'test',
'label' => 'Test',
'pattern' => 'Y-m-d',
]);
$this->entity
->save();
}
/**
* Tests that the entity assigned after ::setUp() is the one under test.
*
* The base class reloads ::$entity only for a shared environment. Reloading
* it here would throw, because nothing recorded which entity to load.
*/
public function testEntityComesFromSetUp() : void {
$this->assertFalse(static::sharesEnvironment());
$this->assertSame('test', $this->entity
->id());
$this->assertFalse($this->entity
->isNew());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.