function ConfigTest::assertOverriddenKeys
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::assertOverriddenKeys()
- 10 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::assertOverriddenKeys()
- 11.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::assertOverriddenKeys()
Asserts that the correct keys are overridden.
Parameters
array $data: The original data.
array $overridden_data: The overridden data.
1 call to ConfigTest::assertOverriddenKeys()
- ConfigTest::testOverrideData in core/
tests/ Drupal/ Tests/ Core/ Config/ ConfigTest.php - @covers ::setModuleOverride @covers ::setSettingsOverride @covers ::getOriginal @covers ::hasOverrides @dataProvider overrideDataProvider
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ ConfigTest.php, line 632
Class
- ConfigTest
- Tests the Config.
Namespace
Drupal\Tests\Core\ConfigCode
protected function assertOverriddenKeys(array $data, array $overridden_data) {
if (empty($overridden_data)) {
$this->assertFalse($this->config
->hasOverrides());
}
else {
$this->assertTrue($this->config
->hasOverrides());
foreach ($overridden_data as $key => $value) {
// If there are nested overrides test a keys at every level.
if (is_array($value)) {
$nested_key = $key;
$nested_value = $overridden_data[$key];
while (is_array($nested_value)) {
$nested_key .= '.' . key($nested_value);
$this->assertTrue($this->config
->hasOverrides($nested_key));
$nested_value = array_pop($nested_value);
}
}
$this->assertTrue($this->config
->hasOverrides($key));
}
}
$non_overridden_keys = array_diff(array_keys($data), array_keys($overridden_data));
foreach ($non_overridden_keys as $non_overridden_key) {
$this->assertFalse($this->config
->hasOverrides($non_overridden_key));
// If there are nested overrides test keys at every level.
if (is_array($data[$non_overridden_key])) {
$nested_key = $non_overridden_key;
$nested_value = $data[$non_overridden_key];
while (is_array($nested_value)) {
$nested_key .= '.' . key($nested_value);
$this->assertFalse($this->config
->hasOverrides($nested_key));
$nested_value = array_pop($nested_value);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.