SchemaConfigListenerTest.php in Zircon Profile 8
File
core/modules/config/src/Tests/SchemaConfigListenerTest.php
View source
<?php
namespace Drupal\config\Tests;
use Drupal\Core\Config\Schema\SchemaIncompleteException;
use Drupal\simpletest\KernelTestBase;
class SchemaConfigListenerTest extends KernelTestBase {
public static $modules = array(
'config_test',
);
public function testConfigSchemaChecker() {
$message = 'Expected SchemaIncompleteException thrown';
try {
$this
->config('config_schema_test.schemaless')
->set('foo', 'bar')
->save();
$this
->fail($message);
} catch (SchemaIncompleteException $e) {
$this
->pass($message);
$this
->assertEqual('No schema for config_schema_test.schemaless', $e
->getMessage());
}
$message = 'Unexpected SchemaIncompleteException thrown';
$config = $this
->config('config_test.types')
->set('int', 10);
try {
$config
->save();
$this
->pass($message);
} catch (SchemaIncompleteException $e) {
$this
->fail($message);
}
$message = 'Expected SchemaIncompleteException thrown';
$config = $this
->config('config_test.types')
->set('foo', 'bar')
->set('array', 1);
try {
$config
->save();
$this
->fail($message);
} catch (SchemaIncompleteException $e) {
$this
->pass($message);
$this
->assertEqual('Schema errors for config_test.types with the following errors: config_test.types:foo missing schema, config_test.types:array variable type is integer but applied schema class is Drupal\\Core\\Config\\Schema\\Sequence', $e
->getMessage());
}
}
}