diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTestBase.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTestBase.php index 61eee7e..1495f07 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTestBase.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTestBase.php @@ -2,12 +2,14 @@ /** * @file - * Contains Drupal\config\Tests\DefaultConfigTest. + * Contains Drupal\config\Tests\ConfigSchemaTestBase. */ namespace Drupal\config\Tests; +use Drupal\Core\Config\Schema\Mapping; use Drupal\Core\Config\Schema\Property; +use Drupal\Core\Config\Schema\Sequence; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\TypedData\Type\BooleanInterface; use Drupal\Core\TypedData\Type\StringInterface; @@ -38,6 +40,8 @@ protected $configName; /** + * Global state for whether the config passed for a name. + * * @var boolean */ protected $configPass; @@ -110,17 +114,13 @@ protected function checkValue($key, $value) { if ($type == 'string' && ($element instanceof StringInterface || $element instanceof Property)) { $success = TRUE; } - // Null values are allowed for all types. + // Null values are allowed for all scalar types. if ($value === NULL) { $success = TRUE; } } - else { - // @todo throw an exception due to an incomplete schema. Only possible - // once https://drupal.org/node/1910624 is complete. - } - $class = get_class($element); if (!$success) { + $class = get_class($element); $this->fail("{$this->configName}:$key has the wrong schema. Variable type is $type and schema class is $class."); } } @@ -129,7 +129,18 @@ protected function checkValue($key, $value) { } } else { - // Any non-scalar value must be an array. + try { + $element = $this->schema->get($key); + if (!($element instanceof Mapping) && !($element instanceof Sequence)) { + $this->fail("{$this->configName}:$key is not defined as a mapping or sequence but is not a scalar value."); + } + } + catch (SchemaIncompleteException $e) { + $this->fail("{$this->configName}:$key has no schema."); + } + + // Go on processing so we can get errors on all levels. Any non-scalar + // value must be an array so cast to an array. if (!is_array($value)) { $value = (array) $value; }