You are here

public function ConfigSchemaTest::testConfigSaveWithWrappingSchema 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::testConfigSaveWithWrappingSchema()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testConfigSaveWithWrappingSchema()

Tests saving config when the type is wrapped by a dynamic type.

File

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

Class

ConfigSchemaTest
Tests schema for configuration objects.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testConfigSaveWithWrappingSchema() {
  $untyped_values = [
    'tests' => [
      [
        'wrapper_value' => 'foo',
        'plugin_id' => 'wrapper:foo',
        'internal_value' => 100,
      ],
    ],
  ];
  $typed_values = [
    'tests' => [
      [
        'wrapper_value' => 'foo',
        'plugin_id' => 'wrapper:foo',
        'internal_value' => '100',
      ],
    ],
  ];

  // Save config which has a schema that enforces types.
  \Drupal::configFactory()
    ->getEditable('wrapping.config_schema_test.plugin_types')
    ->setData($untyped_values)
    ->save();
  $this
    ->assertSame($typed_values, \Drupal::config('wrapping.config_schema_test.plugin_types')
    ->get());
}