SchemaConfigListenerWebTest.php in Zircon Profile 8.0
File
core/modules/config/src/Tests/SchemaConfigListenerWebTest.php
View source
<?php
namespace Drupal\config\Tests;
use Drupal\Core\Config\Schema\SchemaIncompleteException;
use Drupal\simpletest\WebTestBase;
class SchemaConfigListenerWebTest extends WebTestBase {
public static $modules = array(
'config_test',
);
public function testConfigSchemaChecker() {
$this
->drupalLogin($this
->drupalCreateUser([
'administer site configuration',
]));
$msg = 'Expected SchemaIncompleteException thrown';
try {
$this
->config('config_schema_test.schemaless')
->set('foo', 'bar')
->save();
$this
->fail($msg);
} catch (SchemaIncompleteException $e) {
$this
->pass($msg);
$this
->assertEqual('No schema for config_schema_test.schemaless', $e
->getMessage());
}
$msg = 'Unexpected SchemaIncompleteException thrown';
$config = $this
->config('config_test.types')
->set('int', 10);
try {
$config
->save();
$this
->pass($msg);
} catch (SchemaIncompleteException $e) {
$this
->fail($msg);
}
$msg = 'Expected SchemaIncompleteException thrown';
$config = $this
->config('config_test.types')
->set('foo', 'bar')
->set('array', 1);
try {
$config
->save();
$this
->fail($msg);
} catch (SchemaIncompleteException $e) {
$this
->pass($msg);
$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());
}
$this
->drupalGet('config_test/schema_listener');
$this
->assertText('No schema for config_schema_test.schemaless');
}
}