diff -u b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php --- b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -248,2 +248,42 @@ + /** + * Test configuration value data type enforcement using schemas. + */ + protected function testConfigSaveWithSchema () { + $untyped_values = array( + 'string' => 1, + 'integer' => '100', + 'boolean' => 1, + // In the config schema this does not have a type so should cast to string. + 'no_type' => 1, + 'array' => array( + 'string' => 1 + ), + // Not in schema and therefore should be left untouched. + 'not_present_in_schema' => TRUE, + ); + + $typed_values = array( + 'string' => '1', + 'integer' => 100, + 'boolean' => TRUE, + 'no_type' => '1', + 'array' => array( + 'string' => '1' + ), + 'not_present_in_schema' => TRUE, + ); + + // Save config which has a schema that enforces types. + \Drupal::config('config_test.schema_data_types') + ->setData($untyped_values) + ->save(); + $this->assertIdentical(\Drupal::config('config_test.schema_data_types')->get(), $typed_values); + + // Save config which does not have a schema that enforces types. + \Drupal::config('config_test.no_schema_data_types') + ->setData($untyped_values) + ->save(); + $this->assertIdentical(\Drupal::config('config_test.no_schema_data_types')->get(), $untyped_values); + } } only in patch2: unchanged: --- a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml +++ b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml @@ -91,3 +91,21 @@ config_test.dynamic.*: protected_property: type: string label: 'Protected property' + +config_test.schema_data_types: + type: mapping + label: 'Config test schema' + mapping: + integer: + type: integer + string: + type: string + boolean: + type: boolean + no_type: + label: 'No label' + array: + type: mapping + mapping: + string: + type: string \ No newline at end of file