.../ckeditor5/src/Plugin/Editor/CKEditor5.php | 5 --- .../tests/src/Functional/ImageUploadTest.php | 6 +++- .../tests/src/Kernel/SmartDefaultSettingsTest.php | 7 ++++ .../ckeditor5/tests/src/Kernel/ValidatorsTest.php | 39 +++++++++++++++------- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php index ab0d03d2c4..c9326b9752 100644 --- a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php +++ b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php @@ -12,7 +12,6 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Config\Schema\SchemaCheckTrait; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\SubformState; @@ -50,8 +49,6 @@ */ class CKEditor5 extends EditorBase implements ContainerFactoryPluginInterface { - use SchemaCheckTrait; - /** * The CKEditor plugin manager. * @@ -729,8 +726,6 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form // ::getGeneratedAllowedHtmlValue(), to update filter_html's // "allowed_html". $form_state->set('ckeditor5_validated_pair', $eventual_editor_and_format); - - assert(TRUE === $this->checkConfigSchema(\Drupal::getContainer()->get('config.typed'), 'editor.editor.id_does_not_matter', $submitted_editor->toArray()), 'Schema errors: ' . print_r($this->checkConfigSchema(\Drupal::getContainer()->get('config.typed'), 'editor.editor.id_does_not_matter', $submitted_editor->toArray()), TRUE)); } /** diff --git a/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php b/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php index fdd7235e44..4a93a25d58 100644 --- a/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php +++ b/core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php @@ -224,7 +224,11 @@ protected function createEditorWithUpload(array $upload_config) { 'drupalInsertImage', ], ], - 'plugins' => [], + 'plugins' => [ + 'ckeditor5_imageResize' => [ + 'allow_resize' => FALSE, + ] + ], ], 'image_upload' => $upload_config, ]); diff --git a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php index bf294d8375..38defa311c 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php @@ -498,6 +498,13 @@ public function test(string $format_id, array $filters_to_drop, array $expected_ // Ensure that the result of ::computeSmartDefaultSettings() always complies // with the config schema. + // TRICKY: because we're validating using `editor.editor.*` as the config + // name, TextEditorObjectDependentValidatorTrait will load the stored filter + // format. That has not yet been updated at this point, so in order for + // validation to pass, it must first be saved. + // @see \Drupal\ckeditor5\Plugin\Validation\Constraint\TextEditorObjectDependentValidatorTrait::createTextEditorObjectFromContext() + // @todo Remove this work-around in https://www.drupal.org/project/drupal/issues/3231354 + $updated_text_editor->getFilterFormat()->save(); $this->assertConfigSchema( $this->typedConfig, $updated_text_editor->getConfigDependencyName(), diff --git a/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php b/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php index 1f4c8a5327..da7983b645 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php @@ -580,16 +580,29 @@ public function testPair(array $ckeditor5_settings, array $editor_image_upload_s 'label' => 'View Mode 2', ])->save(); assert($text_editor instanceof EditorInterface); - $this->assertConfigSchema( - $this->typedConfig, - $text_editor->getConfigDependencyName(), - $text_editor->toArray() - ); $text_format = FilterFormat::create([ + 'format' => $text_editor->id(), + 'name' => $this->randomString(), 'filters' => $filters, ]); assert($text_format instanceof FilterFormatInterface); - + // TRICKY: only assert the config schema if we expect NO violations: when + // violations are expected, this would just find the very violations that + // the next assertion is checking. + if (empty($expected_violations)) { + // TRICKY: because we're validating using `editor.editor.*` as the config + // name, TextEditorObjectDependentValidatorTrait will load the stored + // filter format. That has not yet been updated at this point, so in order + // for validation to pass, it must first be saved. + // @see \Drupal\ckeditor5\Plugin\Validation\Constraint\TextEditorObjectDependentValidatorTrait::createTextEditorObjectFromContext() + // @todo Remove this work-around in https://www.drupal.org/project/drupal/issues/3231354 + $text_format->save(); + $this->assertConfigSchema( + $this->typedConfig, + $text_editor->getConfigDependencyName(), + $text_editor->toArray() + ); + } $this->assertSame($expected_violations, $this->validatePairToViolationsArray($text_editor, $text_format, TRUE)); } @@ -1062,7 +1075,7 @@ public function providerPair(): array { 'filters' => [], 'violations' => [], ]; - $data['INVALID: drupalMedia toolbar item condition NOT met: media filter enabled'] = [ + $data['INVALID: drupalMedia toolbar item condition NOT met: media filter disabled'] = [ 'settings' => [ 'toolbar' => [ 'items' => [ @@ -1086,13 +1099,17 @@ public function providerPair(): array { 'drupalMedia', ], ], - 'plugins' => [], + 'plugins' => [ + 'media_media' => [ + 'allow_view_mode_override' => FALSE, + ], + ], ], 'image_upload' => [ 'status' => FALSE, ], 'filters' => [ - 'filter_html' => [ + 'media_embed' => [ 'id' => 'media_embed', 'provider' => 'media', 'status' => TRUE, @@ -1104,9 +1121,7 @@ public function providerPair(): array { ], ], ], - 'violations' => [ - 'settings.toolbar.items.0' => 'The Drupal media toolbar item requires the Embed media filter to be enabled.', - ], + 'violations' => [], ]; $data['VALID: HTML format: very minimal toolbar + wildcard in source editing HTML'] = [ 'settings' => [