.../Core/Config/Testing/ConfigSchemaChecker.php | 8 +++++++ core/modules/action/src/Tests/BulkFormTest.php | 5 +++++ .../action_bulk_test/action_bulk_test.info.yml | 1 + core/modules/block/src/Tests/BlockUiTest.php | 5 +++++ .../block_test/config/schema/block_test.schema.yml | 7 ++++++ .../ckeditor/src/Tests/CKEditorAdminTest.php | 10 ++++++--- .../ckeditor/src/Tests/CKEditorLoadingTest.php | 1 - .../modules/config/schema/ckeditor_test.schema.yml | 7 ++++++ core/modules/color/color.module | 24 +++++++++++++-------- .../color/src/Tests/ColorConfigSchemaTest.php | 7 +++--- core/modules/color/src/Tests/ColorTest.php | 5 +++++ .../config/schema/color_test_theme.schema.yml | 5 +++++ .../comment/config/schema/comment.schema.yml | 2 +- .../comment/src/Tests/CommentActionsTest.php | 5 +++++ core/modules/editor/src/Tests/EditorAdminTest.php | 25 ++++++++++++---------- .../modules/config/schema/editor_test.schema.yml | 2 +- .../modules/src/Plugin/Editor/UnicornEditor.php | 8 +++---- core/modules/image/config/schema/image.schema.yml | 4 ++++ .../image/src/Tests/ImageDimensionsTest.php | 5 +++++ .../search/src/Tests/SearchTokenizerTest.php | 10 +++++++-- .../statistics/config/schema/statistics.schema.yml | 14 ++++++++++++ .../statistics/src/Tests/StatisticsReportsTest.php | 5 +++++ .../taxonomy/src/Tests/VocabularyCrudTest.php | 10 +++++++++ core/modules/tour/src/Tests/TourTest.php | 5 +++++ 24 files changed, 145 insertions(+), 35 deletions(-) diff --git a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php index db80944..ba9e048 100644 --- a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php @@ -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)); diff --git a/core/modules/action/src/Tests/BulkFormTest.php b/core/modules/action/src/Tests/BulkFormTest.php index 8fd634b..86c34d0 100644 --- a/core/modules/action/src/Tests/BulkFormTest.php +++ b/core/modules/action/src/Tests/BulkFormTest.php @@ -19,6 +19,11 @@ class BulkFormTest extends WebTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to install. * * @var array diff --git a/core/modules/action/tests/action_bulk_test/action_bulk_test.info.yml b/core/modules/action/tests/action_bulk_test/action_bulk_test.info.yml index 296a33a..37b4285 100644 --- a/core/modules/action/tests/action_bulk_test/action_bulk_test.info.yml +++ b/core/modules/action/tests/action_bulk_test/action_bulk_test.info.yml @@ -7,3 +7,4 @@ core: 8.x dependencies: - action - views + - node diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index e03135f..0313443 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -17,6 +17,11 @@ class BlockUiTest extends WebTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to install. * * @var array diff --git a/core/modules/block/tests/modules/block_test/config/schema/block_test.schema.yml b/core/modules/block/tests/modules/block_test/config/schema/block_test.schema.yml new file mode 100644 index 0000000..e0b13cb --- /dev/null +++ b/core/modules/block/tests/modules/block_test/config/schema/block_test.schema.yml @@ -0,0 +1,7 @@ +block.settings.test_block_instantiation: + type: block_settings + label: 'Test block instantiation settings' + mapping: + display_message: + type: string + label: 'Message text' diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php index d4c1372..2773509 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php @@ -19,6 +19,11 @@ class CKEditorAdminTest extends WebTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array @@ -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()); diff --git a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php index 37e047c..98d73af 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php @@ -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'; diff --git a/core/modules/ckeditor/tests/modules/config/schema/ckeditor_test.schema.yml b/core/modules/ckeditor/tests/modules/config/schema/ckeditor_test.schema.yml new file mode 100644 index 0000000..e6734a7 --- /dev/null +++ b/core/modules/ckeditor/tests/modules/config/schema/ckeditor_test.schema.yml @@ -0,0 +1,7 @@ +ckeditor.plugin.llama_contextual_and_button: + type: mapping + label: 'Contextual Llama With Button' + mapping: + ultra_llama_mode: + type: boolean + label: 'Ultra llama mode' diff --git a/core/modules/color/color.module b/core/modules/color/color.module index e9cc0a6..390af48 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -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']; diff --git a/core/modules/color/src/Tests/ColorConfigSchemaTest.php b/core/modules/color/src/Tests/ColorConfigSchemaTest.php index bb1e03c..01f3646 100644 --- a/core/modules/color/src/Tests/ColorConfigSchemaTest.php +++ b/core/modules/color/src/Tests/ColorConfigSchemaTest.php @@ -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()); } } diff --git a/core/modules/color/src/Tests/ColorTest.php b/core/modules/color/src/Tests/ColorTest.php index 185faae..8adc7f2 100644 --- a/core/modules/color/src/Tests/ColorTest.php +++ b/core/modules/color/src/Tests/ColorTest.php @@ -18,6 +18,11 @@ class ColorTest extends WebTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to install. * * @var array diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/config/schema/color_test_theme.schema.yml b/core/modules/color/tests/modules/color_test/themes/color_test_theme/config/schema/color_test_theme.schema.yml new file mode 100644 index 0000000..33c19d6 --- /dev/null +++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/config/schema/color_test_theme.schema.yml @@ -0,0 +1,5 @@ +# Schema for the configuration files of the Color test theme. + +color_test_theme.settings: + type: theme_settings + label: 'Color test theme settings' diff --git a/core/modules/comment/config/schema/comment.schema.yml b/core/modules/comment/config/schema/comment.schema.yml index afd6570..9dd0aa5 100644 --- a/core/modules/comment/config/schema/comment.schema.yml +++ b/core/modules/comment/config/schema/comment.schema.yml @@ -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: diff --git a/core/modules/comment/src/Tests/CommentActionsTest.php b/core/modules/comment/src/Tests/CommentActionsTest.php index a0b50d6..e5443c1 100644 --- a/core/modules/comment/src/Tests/CommentActionsTest.php +++ b/core/modules/comment/src/Tests/CommentActionsTest.php @@ -17,6 +17,11 @@ class CommentActionsTest extends CommentTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to install. * * @var array diff --git a/core/modules/editor/src/Tests/EditorAdminTest.php b/core/modules/editor/src/Tests/EditorAdminTest.php index ab79287..8e6ebd1 100644 --- a/core/modules/editor/src/Tests/EditorAdminTest.php +++ b/core/modules/editor/src/Tests/EditorAdminTest.php @@ -17,6 +17,11 @@ class EditorAdminTest extends WebTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array @@ -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,15 @@ protected function selectUnicornEditor() { * * @param string $format_id * The format machine name. - * @param string $foo - * The expected value of the foo setting. + * @param string $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.'); + debug($settings); + $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"]'); diff --git a/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml b/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml index 6900e2f..64d94f8 100644 --- a/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml +++ b/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml @@ -5,5 +5,5 @@ editor.settings.unicorn: label: 'Unicorn settings' mapping: ponies_too: - type: string + type: boolean label: 'Ponies too' diff --git a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php index 49644e5..7539021 100644 --- a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php +++ b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php @@ -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; } diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml index 7da7c47..87f38f6 100644 --- a/core/modules/image/config/schema/image.schema.yml +++ b/core/modules/image/config/schema/image.schema.yml @@ -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' diff --git a/core/modules/image/src/Tests/ImageDimensionsTest.php b/core/modules/image/src/Tests/ImageDimensionsTest.php index 4d6c76b..2b05757 100644 --- a/core/modules/image/src/Tests/ImageDimensionsTest.php +++ b/core/modules/image/src/Tests/ImageDimensionsTest.php @@ -17,6 +17,11 @@ class ImageDimensionsTest extends WebTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array diff --git a/core/modules/search/src/Tests/SearchTokenizerTest.php b/core/modules/search/src/Tests/SearchTokenizerTest.php index 66777b3..b3361a9 100644 --- a/core/modules/search/src/Tests/SearchTokenizerTest.php +++ b/core/modules/search/src/Tests/SearchTokenizerTest.php @@ -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(); diff --git a/core/modules/statistics/config/schema/statistics.schema.yml b/core/modules/statistics/config/schema/statistics.schema.yml index 58f262d..51da9ab 100644 --- a/core/modules/statistics/config/schema/statistics.schema.yml +++ b/core/modules/statistics/config/schema/statistics.schema.yml @@ -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' diff --git a/core/modules/statistics/src/Tests/StatisticsReportsTest.php b/core/modules/statistics/src/Tests/StatisticsReportsTest.php index e3218cf..ed8ba14 100644 --- a/core/modules/statistics/src/Tests/StatisticsReportsTest.php +++ b/core/modules/statistics/src/Tests/StatisticsReportsTest.php @@ -15,6 +15,11 @@ class StatisticsReportsTest extends StatisticsTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Tests the "popular content" block. */ function testPopularContentBlock() { diff --git a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php index 6cc1678..f2f7b54 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -18,6 +18,11 @@ class VocabularyCrudTest extends TaxonomyTestBase { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array @@ -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')); diff --git a/core/modules/tour/src/Tests/TourTest.php b/core/modules/tour/src/Tests/TourTest.php index 8ed261c..ee8ea7b 100644 --- a/core/modules/tour/src/Tests/TourTest.php +++ b/core/modules/tour/src/Tests/TourTest.php @@ -17,6 +17,11 @@ class TourTest extends TourTestBasic { /** + * {@inheritdoc} + */ + protected $strictConfigSchema = TRUE; + + /** * Modules to enable. * * @var array