Commit f355ada7 authored by alexpott's avatar alexpott

Issue #2379697 by Gábor Hojtsy: Fix configuration schema issues in block...

Issue #2379697 by Gábor Hojtsy: Fix configuration schema issues in block content (indirectly link and field test) modules
parent e55a223e
......@@ -66,7 +66,9 @@ public function onConfigSave(ConfigCrudEvent $event) {
$name = $saved_config->getName();
$data = $saved_config->get();
$checksum = crc32(serialize($data));
if (!isset($this->checked[$name . ':' . $checksum])) {
// Content translation settings cannot be provided schema yet, see
// https://www.drupal.org/node/2363155
if ($name != 'content_translation.settings' && !isset($this->checked[$name . ':' . $checksum])) {
$this->checked[$name . ':' . $checksum] = TRUE;
$errors = $this->checkConfigSchema($this->typedManager, $name, $data);
if ($errors === FALSE) {
......
......@@ -22,6 +22,15 @@
*/
class DisplayBlockTest extends ViewTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......@@ -131,13 +140,13 @@ public function testBlockCategory() {
protected function testDeleteBlockDisplay() {
// To test all combinations possible we first place create two instances
// of the block display of the first view.
$block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('title' => 'test_view_block-block_1:1'));
$block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('title' => 'test_view_block-block_1:2'));
$block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1'));
$block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:2'));
// Then we add one instance of blocks for each of the two displays of the
// second view.
$block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', array('title' => 'test_view_block2-block_1'));
$block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', array('title' => 'test_view_block2-block_2'));
$block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', array('label' => 'test_view_block2-block_1'));
$block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', array('label' => 'test_view_block2-block_2'));
$this->drupalGet('test-page');
$this->assertBlockAppears($block_1);
......@@ -242,7 +251,7 @@ public function testViewsBlockForm() {
*/
public function testBlockRendering() {
// Create a block and set a custom title.
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('title' => 'test_view_block-block_1:1', 'views_label' => 'Custom title'));
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title'));
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
......
......@@ -46,8 +46,5 @@ display:
display_title: Block
position: null
display_options:
field:
title:
link_to_node: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
......@@ -48,9 +48,6 @@ display:
display_title: Block
position: null
display_options:
field:
title:
link_to_node: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_2:
......@@ -59,9 +56,6 @@ display:
display_title: Block
position: null
display_options:
field:
title:
link_to_node: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_3:
......@@ -70,9 +64,5 @@ display:
display_title: Block
position: null
display_options:
block_caching: 2
field:
title:
link_to_node: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
......@@ -18,6 +18,15 @@
*/
class BlockContentCacheTagsTest extends EntityCacheTagsTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* {@inheritdoc}
*/
......
......@@ -17,6 +17,15 @@
*/
class BlockContentFieldTest extends BlockContentTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......
......@@ -17,6 +17,16 @@
*/
class BlockContentTranslationUITest extends ContentTranslationUITest {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......
......@@ -8,7 +8,6 @@
namespace Drupal\content_translation\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Core\Field\Entity\BaseFieldOverride;
use Drupal\Core\Language\Language;
use Drupal\field\Entity\FieldConfig;
......@@ -21,7 +20,14 @@
*/
class ContentTranslationSettingsTest extends WebTestBase {
use SchemaCheckTestTrait;
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
......@@ -181,8 +187,6 @@ function testSettingsUI() {
$this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.');
$this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.');
}
$this->assertConfigSchemas();
}
/**
......@@ -274,22 +278,4 @@ protected function entityManager() {
return $this->container->get('entity.manager');
}
/**
* Asserts all active configuration matches schemas.
*/
protected function assertConfigSchemas() {
$names = $this->container->get('config.storage')->listAll();
$factory = $this->container->get('config.factory');
/** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
$typed_config = $this->container->get('config.typed');
foreach ($names as $name) {
// It is not possible to provide schema due to https://www.drupal.org/node/2248709
// @todo Refactor settings in https://www.drupal.org/node/2363155
if ($name != 'content_translation.settings') {
$config = $factory->get($name);
$this->assertConfigSchema($typed_config, $name, $config->get());
}
}
}
}
......@@ -16,3 +16,33 @@ field.widget.settings.test_field_widget_multiple:
test_widget_setting_multiple:
type: string
label: 'Test setting'
field.storage_settings.test_field:
type: mapping
label: 'Test field settings'
mapping:
test_field_storage_setting:
type: string
label: 'Test field storage setting'
changeable:
type: string
label: 'A changeable field storage setting'
unchangeable:
type: string
label: 'An unchangeable field storage setting'
field.field_settings.test_field:
type: mapping
label: 'Test field settings'
mapping:
test_field_setting:
type: string
label: 'Test field setting'
field.value.test_field:
type: mapping
label: 'Default value'
mapping:
value:
type: label
label: 'Value'
......@@ -42,7 +42,6 @@ public static function defaultStorageSettings() {
public static function defaultFieldSettings() {
return array(
'test_field_setting' => 'dummy test string',
'test_cached_data' => FALSE,
) + parent::defaultFieldSettings();
}
......
......@@ -44,3 +44,29 @@ field.widget.settings.link_default:
placeholder_title:
type: label
label: 'Placeholder for link text'
field.storage_settings.link:
type: mapping
label: 'Link settings'
field.field_settings.link:
type: mapping
label: 'Link settings'
mapping:
title:
type: integer
label: 'Allow link text'
link_type:
type: integer
label: 'Allowed link type'
field.link.value:
type: mapping
label: 'Default value'
mapping:
title:
type: label
label: 'Link text'
url:
type: string
label: 'URL'
......@@ -146,6 +146,7 @@ display:
expose:
label: ''
granularity: second
plugin_id: date
title: 'Test field filters'
header: { }
footer: { }
......
......@@ -129,6 +129,7 @@ display:
expose:
operator: ''
group: 1
plugin_id: boolean
sorts:
created:
id: created
......@@ -142,6 +143,7 @@ display:
expose:
label: ''
granularity: second
plugin_id: date
title: test_node_view
header: { }
footer: { }
......
......@@ -91,13 +91,14 @@ display:
hide_alter_empty: true
filters:
status:
value: '1'
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
plugin_id: boolean
sorts:
created:
id: created
......@@ -111,6 +112,7 @@ display:
expose:
label: ''
granularity: second
plugin_id: date
title: ''
header: { }
footer: { }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment