function ConfigSchemaTest::testSchemaFallback

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

Tests fallback to a greedy wildcard.

File

core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php, line 568

Class

ConfigSchemaTest
Tests schema for configuration objects.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testSchemaFallback() : void {
    $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.wildcard_fallback.something');
    // This should be the schema of config_schema_test.wildcard_fallback.*.
    $expected = [];
    $expected['label'] = 'Schema wildcard fallback test';
    $expected['class'] = Mapping::class;
    $expected['definition_class'] = '\\Drupal\\Core\\TypedData\\MapDataDefinition';
    $expected['unwrap_for_canonical_representation'] = TRUE;
    $expected['mapping']['langcode']['type'] = 'langcode';
    $expected['mapping']['langcode']['requiredKey'] = FALSE;
    $expected['mapping']['_core']['type'] = '_core_config_info';
    $expected['mapping']['_core']['requiredKey'] = FALSE;
    $expected['mapping']['test_id']['type'] = 'string';
    $expected['mapping']['test_id']['label'] = 'ID';
    $expected['mapping']['test_description']['type'] = 'text';
    $expected['mapping']['test_description']['label'] = 'Description';
    $expected['type'] = 'config_schema_test.wildcard_fallback.*';
    $expected['constraints'] = [
        'ValidKeys' => '<infer>',
        'LangcodeRequiredIfTranslatableValues' => NULL,
    ];
    $this->assertEquals($expected, $definition, 'Retrieved the right metadata for config_schema_test.wildcard_fallback.something');
    $definition2 = \Drupal::service('config.typed')->getDefinition('config_schema_test.wildcard_fallback.something.something');
    // This should be the schema of config_schema_test.wildcard_fallback.* as
    // well.
    $this->assertSame($definition, $definition2);
}

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