function ConfigTest::testDelete
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::testDelete()
- 8.9.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::testDelete()
- 10 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::testDelete()
@covers ::delete @dataProvider overrideDataProvider
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ ConfigTest.php, line 343
Class
- ConfigTest
- Tests the Config.
Namespace
Drupal\Tests\Core\ConfigCode
public function testDelete($data, $module_data) : void {
$this->cacheTagsInvalidator
->expects($this->once())
->method('invalidateTags')
->with([
'config:config.test',
]);
// Set initial data.
foreach ($data as $key => $value) {
$this->config
->set($key, $value);
}
// Set overrides.
$this->config
->setModuleOverride($module_data);
// Save.
$this->config
->save();
// Check that original data is still correct.
$this->assertOriginalConfigDataEquals($data, FALSE);
// Check overrides have been set.
$this->assertConfigDataEquals($module_data);
$this->assertOriginalConfigDataEquals($module_data, TRUE);
// Check that config is new.
$this->assertFalse($this->config
->isNew());
// Delete.
$this->config
->delete();
// Check object properties have been reset.
$this->assertTrue($this->config
->isNew());
foreach ($data as $key => $value) {
$this->assertEmpty($this->config
->getOriginal($key, FALSE));
}
// Check that overrides have persisted.
foreach ($module_data as $key => $value) {
$this->assertConfigDataEquals($module_data);
$this->assertOriginalConfigDataEquals($module_data, TRUE);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.