function ConfigTest::overrideDataProvider

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::overrideDataProvider()
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::overrideDataProvider()
  3. 11.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::overrideDataProvider()

Provides override data.

See also

\Drupal\Tests\Core\Config\ConfigTest::testOverrideData()

\Drupal\Tests\Core\Config\ConfigTest::testDelete()

File

core/tests/Drupal/Tests/Core/Config/ConfigTest.php, line 469

Class

ConfigTest
Tests the Config.

Namespace

Drupal\Tests\Core\Config

Code

public static function overrideDataProvider() {
    $test_cases = [
        [
            // Original data.
[
                'a' => 'originalValue',
            ],
            // Module overrides.
[
                'a' => 'moduleValue',
            ],
            // Setting overrides.
[
                'a' => 'settingValue',
            ],
        ],
        [
            // Original data.
[
                'a' => 'originalValue',
                'b' => 'originalValue',
                'c' => 'originalValue',
            ],
            // Module overrides.
[
                'a' => 'moduleValue',
                'b' => 'moduleValue',
            ],
            // Setting overrides.
[
                'a' => 'settingValue',
            ],
        ],
        [
            // Original data.
[
                'a' => 'allTheSameValue',
            ],
            // Module overrides.
[
                'a' => 'allTheSameValue',
            ],
            // Setting overrides.
[
                'a' => 'allTheSameValue',
            ],
        ],
    ];
    // For each of the above test cases create duplicate test case except with
    // config values nested.
    foreach ($test_cases as $test_key => $test_case) {
        foreach ($test_case as $parameter) {
            $nested_parameter = [];
            foreach ($parameter as $config_key => $value) {
                // Nest config value 5 levels.
                $nested_value = $value;
                for ($i = 5; $i >= 0; $i--) {
                    $nested_value = [
                        $i => $nested_value,
                    ];
                }
                $nested_parameter[$config_key] = $nested_value;
            }
            $test_cases["nested:{$test_key}"][] = $nested_parameter;
        }
    }
    return $test_cases;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.