function ConfigEntityStatusTest::testCRUD
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest::testCRUD()
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest::testCRUD()
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStatusTest::testCRUD()
Tests the enabling/disabling of entities.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigEntityStatusTest.php, line 24
Class
- ConfigEntityStatusTest
- Tests configuration entity status functionality.
Namespace
Drupal\KernelTests\Core\ConfigCode
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.