class ConfigEntityStatusTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest
Tests configuration entity status functionality.
@group config
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ConfigEntityStatusTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigEntityStatusTest.php, line 12
Namespace
Drupal\KernelTests\Core\ConfigView source
class ConfigEntityStatusTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'config_test',
];
/**
* Tests the enabling/disabling of entities.
*/
public function testCRUD() {
$entity = \Drupal::entityTypeManager()->getStorage('config_test')
->create([
'id' => strtolower($this->randomMachineName()),
]);
$this->assertTrue($entity->status(), 'Default status is enabled.');
$entity->save();
$this->assertTrue($entity->status(), 'Status is enabled after saving.');
$entity->disable()
->save();
$this->assertFalse($entity->status(), 'Entity is disabled after disabling.');
$entity->enable()
->save();
$this->assertTrue($entity->status(), 'Entity is enabled after enabling.');
$entity = \Drupal::entityTypeManager()->getStorage('config_test')
->load($entity->id());
$this->assertTrue($entity->status(), 'Status is enabled after reload.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.