function ConfigSchemaTest::testSchemaMappingWithParents
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testSchemaMappingWithParents()
- 8.9.x core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testSchemaMappingWithParents()
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testSchemaMappingWithParents()
Tests metadata retrieval with several levels of %parent indirection.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigSchemaTest.php, line 321
Class
- ConfigSchemaTest
- Tests schema for configuration objects.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testSchemaMappingWithParents() : void {
$config_data = \Drupal::service('config.typed')->get('config_schema_test.some_schema.with_parents');
// Test fetching parent one level up.
$entry = $config_data->get('one_level');
$definition = $entry->get('test_item')
->getDataDefinition()
->toArray();
$expected = [
'type' => 'config_schema_test.some_schema.with_parents.key_1',
'label' => 'Test item nested one level',
'class' => StringData::class,
'definition_class' => '\\Drupal\\Core\\TypedData\\DataDefinition',
'unwrap_for_canonical_representation' => TRUE,
'requiredKey' => TRUE,
];
$this->assertEquals($expected, $definition);
// Test fetching parent two levels up.
$entry = $config_data->get('two_levels');
$definition = $entry->get('wrapper')
->get('test_item')
->getDataDefinition()
->toArray();
$expected = [
'type' => 'config_schema_test.some_schema.with_parents.key_2',
'label' => 'Test item nested two levels',
'class' => StringData::class,
'definition_class' => '\\Drupal\\Core\\TypedData\\DataDefinition',
'unwrap_for_canonical_representation' => TRUE,
'requiredKey' => TRUE,
];
$this->assertEquals($expected, $definition);
// Test fetching parent three levels up.
$entry = $config_data->get('three_levels');
$definition = $entry->get('wrapper_1')
->get('wrapper_2')
->get('test_item')
->getDataDefinition()
->toArray();
$expected = [
'type' => 'config_schema_test.some_schema.with_parents.key_3',
'label' => 'Test item nested three levels',
'class' => StringData::class,
'definition_class' => '\\Drupal\\Core\\TypedData\\DataDefinition',
'unwrap_for_canonical_representation' => TRUE,
'requiredKey' => TRUE,
];
$this->assertEquals($expected, $definition);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.