function ConfigSchemaTest::testConfigSaveMappingSort

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testConfigSaveMappingSort()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php \Drupal\KernelTests\Core\Config\ConfigSchemaTest::testConfigSaveMappingSort()

Test configuration value data type enforcement using schemas.

File

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

Class

ConfigSchemaTest
Tests schema for configuration objects.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testConfigSaveMappingSort() : void {
    // 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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.