Commit 348a681b authored by alexpott's avatar alexpott

Issue #2391245 by Gábor Hojtsy, Wim Leers: Resolve remaining misc issues with...

Issue #2391245 by Gábor Hojtsy, Wim Leers: Resolve remaining misc issues with configuration schema fails
parent 0a4aeec2
......@@ -12,6 +12,7 @@
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\Schema\SchemaCheckTrait;
use Drupal\Core\Config\Schema\SchemaIncompleteException;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......@@ -62,7 +63,14 @@ public function __construct(TypedConfigManagerInterface $typed_manager) {
* Exception thrown when configuration does not match its schema.
*/
public function onConfigSave(ConfigCrudEvent $event) {
// Only validate configuration if in the default collection. Other
// collections may have incomplete configuration (for example language
// overrides only). These are not valid in themselves.
$saved_config = $event->getConfig();
if ($saved_config->getStorage()->getCollectionName() != StorageInterface::DEFAULT_COLLECTION) {
return;
}
$name = $saved_config->getName();
$data = $saved_config->get();
$checksum = crc32(serialize($data));
......
......@@ -18,6 +18,11 @@
*/
class BulkFormTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to install.
*
......
......@@ -7,3 +7,4 @@ core: 8.x
dependencies:
- action
- views
- node
......@@ -16,6 +16,11 @@
*/
class BlockUiTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to install.
*
......
block.settings.test_block_instantiation:
type: block_settings
label: 'Test block instantiation settings'
mapping:
display_message:
type: string
label: 'Message text'
......@@ -18,6 +18,11 @@
*/
class CKEditorAdminTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......@@ -154,8 +159,7 @@ function testExistingFormat() {
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$expected_settings['toolbar']['rows'][0][] = array(
'name' => 'Action history',
'items' => array('Undo', '|', 'Redo'),
array('JustifyCenter')
'items' => array('Undo', '|', 'Redo', 'JustifyCenter'),
);
$edit = array(
'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']),
......@@ -186,7 +190,7 @@ function testExistingFormat() {
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]');
$this->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is checked.');
$expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = 1;
$expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = TRUE;
$editor = entity_load('editor', 'filtered_html');
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
$this->assertIdentical($expected_settings, $editor->getSettings());
......
......@@ -127,7 +127,6 @@ function testLoading() {
// configuration also results in modified CKEditor configuration, so we
// don't test that here.
\Drupal::service('module_installer')->install(array('ckeditor_test'));
$this->resetAll();
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
$editor_settings = $editor->getSettings();
$editor_settings['toolbar']['buttons'][0][] = 'Llama';
......
ckeditor.plugin.llama_contextual_and_button:
type: mapping
label: 'Contextual Llama With Button'
mapping:
ultra_llama_mode:
type: boolean
label: 'Ultra llama mode'
......@@ -60,7 +60,8 @@ function color_form_system_theme_settings_alter(&$form, FormStateInterface $form
);
$form['color'] += color_scheme_form($form, $form_state, $theme);
$form['#validate'][] = 'color_scheme_form_validate';
$form['#submit'][] = 'color_scheme_form_submit';
// Ensure color submission happens first so we can unset extra values.
array_unshift($form['#submit'], 'color_scheme_form_submit');
}
}
......@@ -337,21 +338,26 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
*/
function color_scheme_form_submit($form, FormStateInterface $form_state) {
// Get theme coloring info.
if (!$form_state->hasValue('info')) {
// Avoid color settings spilling over to theme settings.
$color_settings = array('theme', 'palette', 'scheme');
if ($form_state->hasValue('info')) {
$color_settings[] = 'info';
}
foreach ($color_settings as $setting_name) {
${$setting_name} = $form_state->getValue($setting_name);
$form_state->unsetValue($setting_name);
}
if (!isset($info)) {
return;
}
$theme = $form_state->getValue('theme');
$info = $form_state->getValue('info');
$config = \Drupal::config('color.theme.' . $theme);
// Resolve palette.
$palette = $form_state->getValue('palette');
if ($form_state->getValue('scheme') != '') {
if ($scheme != '') {
foreach ($palette as $key => $color) {
if (isset($info['schemes'][$form_state->getValue('scheme')]['colors'][$key])) {
$palette[$key] = $info['schemes'][$form_state->getValue('scheme')]['colors'][$key];
if (isset($info['schemes'][$scheme]['colors'][$key])) {
$palette[$key] = $info['schemes'][$scheme]['colors'][$key];
}
}
$palette += $info['schemes']['default']['colors'];
......
......@@ -7,7 +7,6 @@
namespace Drupal\color\Tests;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\simpletest\WebTestBase;
/**
......@@ -17,7 +16,10 @@
*/
class ColorConfigSchemaTest extends WebTestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to install.
......@@ -53,7 +55,6 @@ function testValidColorConfigSchema() {
$edit['scheme'] = '';
$edit['palette[bg]'] = '#123456';
$this->drupalPostForm($settings_path, $edit, t('Save configuration'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'color.theme.bartik', \Drupal::config('color.theme.bartik')->get());
}
}
......@@ -17,6 +17,11 @@
*/
class ColorTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to install.
*
......
# Schema for the configuration files of the Color test theme.
color_test_theme.settings:
type: theme_settings
label: 'Color test theme settings'
......@@ -24,7 +24,7 @@ action.configuration.comment_unpublish_by_keyword_action:
type: mapping
label: 'Unpublish comment containing keyword(s) configuration'
mapping:
keyword:
keywords:
type: sequence
label: 'Keywords'
sequence:
......
......@@ -16,6 +16,11 @@
*/
class CommentActionsTest extends CommentTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to install.
*
......
......@@ -16,6 +16,11 @@
*/
class EditorAdminTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......@@ -79,9 +84,9 @@ public function testAddEditorToExistingFormat() {
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$edit = $this->selectUnicornEditor();
// Configure Unicorn Editor's setting to another value.
$edit['editor[settings][foo]'] = 'baz';
$edit['editor[settings][ponies_too]'] = FALSE;
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->verifyUnicornEditorConfiguration('filtered_html', 'baz');
$this->verifyUnicornEditorConfiguration('filtered_html', FALSE);
}
/**
......@@ -106,8 +111,6 @@ public function testAddEditorToNewFormat() {
*/
protected function enableUnicornEditor() {
\Drupal::service('module_installer')->install(array('editor_test'));
$this->rebuildContainer();
$this->resetAll();
}
/**
......@@ -135,8 +138,8 @@ protected function selectUnicornEditor() {
'editor[editor]' => 'unicorn',
);
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
$unicorn_setting_foo = $this->xpath('//input[@name="editor[settings][foo]" and @type="text" and @value="bar"]');
$this->assertTrue(count($unicorn_setting_foo), "Unicorn Editor's settings form is present.");
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertTrue(count($unicorn_setting), "Unicorn Editor's settings form is present.");
return $edit;
}
......@@ -146,15 +149,14 @@ protected function selectUnicornEditor() {
*
* @param string $format_id
* The format machine name.
* @param string $foo
* The expected value of the foo setting.
* @param boolean $ponies_too
* The expected value of the ponies_too setting.
*/
protected function verifyUnicornEditorConfiguration($format_id, $foo = 'bar') {
protected function verifyUnicornEditorConfiguration($format_id, $ponies_too = TRUE) {
$editor = editor_load($format_id);
$settings = $editor->getSettings();
$this->assertIdentical($editor->getEditor(), 'unicorn', 'The text editor is configured correctly.');
$this->assertIdentical($settings['foo'], $foo, 'The text editor settings are stored correctly.');
$this->assertIdentical($settings['ponies_too'], true, 'The text editor defaults are retrieved correctly.');
$this->assertIdentical($settings['ponies_too'], $ponies_too, 'The text editor settings are stored correctly.');
$this->drupalGet('admin/config/content/formats/manage/'. $format_id);
$select = $this->xpath('//select[@name="editor[editor]"]');
$select_is_disabled = $this->xpath('//select[@name="editor[editor]" and @disabled="disabled"]');
......
......@@ -5,5 +5,5 @@ editor.settings.unicorn:
label: 'Unicorn settings'
mapping:
ponies_too:
type: string
type: boolean
label: 'Ponies too'
......@@ -35,10 +35,10 @@ function getDefaultSettings() {
* {@inheritdoc}
*/
function settingsForm(array $form, FormStateInterface $form_state, EditorEntity $editor) {
$form['foo'] = array(
'#title' => t('Foo'),
'#type' => 'textfield',
'#default_value' => 'bar',
$form['ponies_too'] = array(
'#title' => t('Pony mode'),
'#type' => 'checkbox',
'#default_value' => TRUE,
);
return $form;
}
......
......@@ -28,6 +28,10 @@ image.style.*:
sequence:
- type: image_style.third_party.[%key]
image.effect.*:
type: mapping
label: 'Effect settings'
image.effect.image_crop:
type: image_size
label: 'Image crop'
......
......@@ -16,6 +16,11 @@
*/
class ImageDimensionsTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......
......@@ -14,6 +14,12 @@
* @group search
*/
class SearchTokenizerTest extends SearchTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Verifies that strings of CJK characters are tokenized.
*
......@@ -114,8 +120,8 @@ function testNoTokenizer() {
// Set the minimum word size to 1 (to split all CJK characters) and make
// sure CJK tokenizing is turned on.
\Drupal::config('search.settings')
->set('minimum_word_size', 1)
->set('overlap_cjk', TRUE)
->set('index.minimum_word_size', 1)
->set('index.overlap_cjk', TRUE)
->save();
$this->refreshVariables();
......
......@@ -34,3 +34,17 @@ statistics.settings:
top_recent_limit:
type: integer
label: 'Number of most recent views to display'
block.settings.statistics_popular_block:
type: block_settings
label: 'Popular content block settings'
mapping:
top_day_num:
type: integer
label: 'Number of day\s top views to display'
top_all_num:
type: integer
label: 'Number of all time views to display'
top_last_num:
type: integer
label: 'Number of most recent views to display'
......@@ -14,6 +14,11 @@
*/
class StatisticsReportsTest extends StatisticsTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Tests the "popular content" block.
*/
......
......@@ -17,6 +17,11 @@
*/
class VocabularyCrudTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......@@ -193,6 +198,11 @@ function testUninstallReinstall() {
);
entity_create('field_config', $field_definition)->save();
// Remove the third party setting from the memory copy of the vocabulary.
// We keep this invalid copy around while the taxonomy module is not even
// installed for testing below.
$this->vocabulary->unsetThirdPartySetting('taxonomy_crud', 'foo');
require_once \Drupal::root() . '/core/includes/install.inc';
$this->container->get('module_installer')->uninstall(array('taxonomy'));
$this->container->get('module_installer')->install(array('taxonomy'));
......
......@@ -16,6 +16,11 @@
*/
class TourTest extends TourTestBasic {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......
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