public function SchemaCheckTraitTest::testTrait in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php \Drupal\KernelTests\Core\Config\SchemaCheckTraitTest::testTrait()
Tests \Drupal\Core\Config\Schema\SchemaCheckTrait.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Config/ SchemaCheckTraitTest.php, line 43
Class
- SchemaCheckTraitTest
- Tests the functionality of SchemaCheckTrait.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testTrait() {
// Test a non existing schema.
$ret = $this
->checkConfigSchema($this->typedConfig, 'config_schema_test.noschema', $this
->config('config_schema_test.noschema')
->get());
$this
->assertIdentical($ret, FALSE);
// Test an existing schema with valid data.
$config_data = $this
->config('config_test.types')
->get();
$ret = $this
->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data);
$this
->assertIdentical($ret, TRUE);
// Add a new key, a new array and overwrite boolean with array to test the
// error messages.
$config_data = [
'new_key' => 'new_value',
'new_array' => [],
] + $config_data;
$config_data['boolean'] = [];
$ret = $this
->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data);
$expected = [
'config_test.types:new_key' => 'missing schema',
'config_test.types:new_array' => 'missing schema',
'config_test.types:boolean' => 'non-scalar value but not defined as an array (such as mapping or sequence)',
];
$this
->assertEqual($ret, $expected);
}