3 namespace Drupal\Tests\config\Functional;
5 use Drupal\Core\Config\Schema\SchemaIncompleteException;
6 use Drupal\Tests\BrowserTestBase;
9 * Tests the functionality of ConfigSchemaChecker in WebTestBase tests.
13 class SchemaConfigListenerWebTest extends BrowserTestBase {
18 public static $modules = ['config_test'];
21 * Tests \Drupal\Core\Config\Development\ConfigSchemaChecker.
23 public function testConfigSchemaChecker() {
24 $this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
26 // Test a non-existing schema.
27 $msg = 'Expected SchemaIncompleteException thrown';
29 $this->config('config_schema_test.schemaless')->set('foo', 'bar')->save();
32 catch (SchemaIncompleteException $e) {
34 $this->assertEqual('No schema for config_schema_test.schemaless', $e->getMessage());
37 // Test a valid schema.
38 $msg = 'Unexpected SchemaIncompleteException thrown';
39 $config = $this->config('config_test.types')->set('int', 10);
44 catch (SchemaIncompleteException $e) {
48 // Test an invalid schema.
49 $msg = 'Expected SchemaIncompleteException thrown';
50 $config = $this->config('config_test.types')
57 catch (SchemaIncompleteException $e) {
59 $this->assertEqual('Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema', $e->getMessage());
62 // Test that the config event listener is working in the child site.
63 $this->drupalGet('config_test/schema_listener');
64 $this->assertText('No schema for config_schema_test.schemaless');