You are here

public function ConfigSchemaTest::testSchemaFallback in Drupal 9

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

Tests fallback to a greedy wildcard.

File

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

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