SchemaCheckTraitTest.php in Zircon Profile 8
File
core/modules/config/src/Tests/SchemaCheckTraitTest.php
View source
<?php
namespace Drupal\config\Tests;
use Drupal\Core\Config\Schema\SchemaCheckTrait;
use Drupal\simpletest\KernelTestBase;
class SchemaCheckTraitTest extends KernelTestBase {
use SchemaCheckTrait;
protected $typedConfig;
public static $modules = array(
'config_test',
'config_schema_test',
);
protected function setUp() {
parent::setUp();
$this
->installConfig(array(
'config_test',
'config_schema_test',
));
$this->typedConfig = \Drupal::service('config.typed');
}
public function testTrait() {
$ret = $this
->checkConfigSchema($this->typedConfig, 'config_schema_test.noschema', $this
->config('config_schema_test.noschema')
->get());
$this
->assertIdentical($ret, FALSE);
$config_data = $this
->config('config_test.types')
->get();
$ret = $this
->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data);
$this
->assertIdentical($ret, TRUE);
$config_data = array(
'new_key' => 'new_value',
'new_array' => array(),
) + $config_data;
$config_data['boolean'] = array();
$ret = $this
->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data);
$expected = array(
'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);
}
}