function ConfigSchemaTest::testSchemaFallback

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testSchemaFallback()
  2. 10 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 493

Class

ConfigSchemaTest
Tests schema for configuration objects.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testSchemaFallback() {
    $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'] = 'string';
    $expected['mapping']['langcode']['label'] = 'Language code';
    $expected['mapping']['_core']['type'] = '_core_config_info';
    $expected['mapping']['testid']['type'] = 'string';
    $expected['mapping']['testid']['label'] = 'ID';
    $expected['mapping']['testdescription']['type'] = 'text';
    $expected['mapping']['testdescription']['label'] = 'Description';
    $expected['type'] = 'config_schema_test.wildcard_fallback.*';
    $this->assertEqual($definition, $expected, '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.