You are here

public function ConfigSchemaTest::testConfigSaveMappingSort in Drupal 10

Test configuration value data type enforcement using schemas.

File

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

Class

ConfigSchemaTest
Tests schema for configuration objects.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testConfigSaveMappingSort() {

  // Top level map sorting.
  $data = [
    'foo' => '1',
    'bar' => '2',
  ];

  // Save config which has a schema that enforces types.
  $this
    ->config('config_schema_test.schema_mapping_sort')
    ->setData($data)
    ->save();
  $this
    ->assertSame([
    'bar' => '2',
    'foo' => '1',
  ], $this
    ->config('config_schema_test.schema_mapping_sort')
    ->get());
  $this
    ->config('config_schema_test.schema_mapping_sort')
    ->set('map', [
    'sub_bar' => '2',
    'sub_foo' => '1',
  ])
    ->save();
  $this
    ->assertSame([
    'sub_foo' => '1',
    'sub_bar' => '2',
  ], $this
    ->config('config_schema_test.schema_mapping_sort')
    ->get('map'));
}