You are here

public function ConfigTest::overrideDataProvider in Drupal 9

Same name and namespace in other branches
  1. 8 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 466

Class

ConfigTest
Tests the Config.

Namespace

Drupal\Tests\Core\Config

Code

public 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;
}