Loading tests/src/Functional/CKEditorToolbarButtonTest.php +2 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ class CKEditorToolbarButtonTest extends BrowserTestBase { }; /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */ $file_url_generator = \Drupal::service('file_url_generator'); $markup = $json_encode($file_url_generator->generateString('core/modules/ckeditor/js/plugins/drupalimage/icons/drupalimage.png')); $ckeditor_module_path = $this->getModulePath('ckeditor'); $markup = $json_encode($file_url_generator->generateString("$ckeditor_module_path/js/plugins/drupalimage/icons/drupalimage.png")); $this->assertSession()->responseContains($markup); } Loading tests/src/Functional/Update/CKEditorUpdateOmitDisabledPluginSettings.php +21 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\Tests\ckeditor\Functional\Update; use Drupal\Core\Database\Database; use Drupal\editor\Entity\Editor; use Drupal\FunctionalTests\Update\UpdatePathTestBase; Loading @@ -22,10 +23,29 @@ class CKEditorUpdateOmitDisabledPluginSettings extends UpdatePathTestBase { */ protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz', DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz', ]; } /** * {@inheritdoc} */ protected function doInstall() { parent::doInstall(); // TRICKY: ::checkRequirements() runs too early. $existing_updates = Database::getConnection()->select('key_value') ->fields('key_value', ['value']) ->condition('collection', 'post_update') ->condition('name', 'existing_updates') ->execute() ->fetchField(); $existing_updates = unserialize($existing_updates); if (in_array('ckeditor_post_update_omit_settings_for_disabled_plugins', $existing_updates, TRUE)) { $this->markTestSkipped('The ckeditor_post_update_omit_settings_for_disabled_plugins() post-update hook has already been applied to this database fixture.'); } } /** * Ensure settings for disabled CKEditor 4 plugins are omitted on post update. */ Loading tests/src/Kernel/CKEditorTest.php +8 −6 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ class CKEditorTest extends KernelTestBase { $query_string = '?0='; // Default toolbar. $ckeditor_module_path = $this->getModulePath('ckeditor'); $expected_config = $this->getDefaultInternalConfig() + [ 'drupalImage_dialogTitleAdd' => 'Insert Image', 'drupalImage_dialogTitleEdit' => 'Edit Image', Loading @@ -101,8 +102,8 @@ class CKEditorTest extends KernelTestBase { 'language' => 'en', 'stylesSet' => FALSE, 'drupalExternalPlugins' => [ 'drupalimage' => $this->fileUrlGenerator->generateString('core/modules/ckeditor/js/plugins/drupalimage/plugin.js'), 'drupallink' => $this->fileUrlGenerator->generateString('core/modules/ckeditor/js/plugins/drupallink/plugin.js'), 'drupalimage' => $this->fileUrlGenerator->generateString("$ckeditor_module_path/js/plugins/drupalimage/plugin.js"), 'drupallink' => $this->fileUrlGenerator->generateString("$ckeditor_module_path/js/plugins/drupallink/plugin.js"), ], ]; $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for default configuration.'); Loading @@ -122,9 +123,9 @@ class CKEditorTest extends KernelTestBase { $expected_config['toolbar'][0]['items'][] = 'Format'; $expected_config['format_tags'] = 'p;h2;h3;h4;h5;h6'; $expected_config['extraPlugins'] .= ',llama_contextual,llama_contextual_and_button'; $expected_config['drupalExternalPlugins']['llama_contextual'] = $this->fileUrlGenerator->generateString('core/modules/ckeditor/tests/modules/js/llama_contextual.js'); $expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = $this->fileUrlGenerator->generateString('core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js'); $expected_config['contentsCss'][] = $this->fileUrlGenerator->generateString('core/modules/ckeditor/tests/modules/ckeditor_test.css') . $query_string; $expected_config['drupalExternalPlugins']['llama_contextual'] = $this->fileUrlGenerator->generateString("$ckeditor_module_path/tests/modules/js/llama_contextual.js"); $expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = $this->fileUrlGenerator->generateString("$ckeditor_module_path/tests/modules/js/llama_contextual_and_button.js"); $expected_config['contentsCss'][] = $this->fileUrlGenerator->generateString("$ckeditor_module_path/tests/modules/ckeditor_test.css") . $query_string; $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.'); // Change the allowed HTML tags; the "allowedContent" and "format_tags" Loading Loading @@ -552,9 +553,10 @@ class CKEditorTest extends KernelTestBase { } protected function getDefaultContentsCssConfig() { $ckeditor_module_path = $this->getModulePath('ckeditor'); $query_string = '?0='; return [ $this->fileUrlGenerator->generateString('core/modules/ckeditor/css/ckeditor-iframe.css') . $query_string, $this->fileUrlGenerator->generateString("$ckeditor_module_path/css/ckeditor-iframe.css") . $query_string, $this->fileUrlGenerator->generateString('core/modules/system/css/components/align.module.css') . $query_string, ]; } Loading Loading
tests/src/Functional/CKEditorToolbarButtonTest.php +2 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ class CKEditorToolbarButtonTest extends BrowserTestBase { }; /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */ $file_url_generator = \Drupal::service('file_url_generator'); $markup = $json_encode($file_url_generator->generateString('core/modules/ckeditor/js/plugins/drupalimage/icons/drupalimage.png')); $ckeditor_module_path = $this->getModulePath('ckeditor'); $markup = $json_encode($file_url_generator->generateString("$ckeditor_module_path/js/plugins/drupalimage/icons/drupalimage.png")); $this->assertSession()->responseContains($markup); } Loading
tests/src/Functional/Update/CKEditorUpdateOmitDisabledPluginSettings.php +21 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\Tests\ckeditor\Functional\Update; use Drupal\Core\Database\Database; use Drupal\editor\Entity\Editor; use Drupal\FunctionalTests\Update\UpdatePathTestBase; Loading @@ -22,10 +23,29 @@ class CKEditorUpdateOmitDisabledPluginSettings extends UpdatePathTestBase { */ protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz', DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz', ]; } /** * {@inheritdoc} */ protected function doInstall() { parent::doInstall(); // TRICKY: ::checkRequirements() runs too early. $existing_updates = Database::getConnection()->select('key_value') ->fields('key_value', ['value']) ->condition('collection', 'post_update') ->condition('name', 'existing_updates') ->execute() ->fetchField(); $existing_updates = unserialize($existing_updates); if (in_array('ckeditor_post_update_omit_settings_for_disabled_plugins', $existing_updates, TRUE)) { $this->markTestSkipped('The ckeditor_post_update_omit_settings_for_disabled_plugins() post-update hook has already been applied to this database fixture.'); } } /** * Ensure settings for disabled CKEditor 4 plugins are omitted on post update. */ Loading
tests/src/Kernel/CKEditorTest.php +8 −6 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ class CKEditorTest extends KernelTestBase { $query_string = '?0='; // Default toolbar. $ckeditor_module_path = $this->getModulePath('ckeditor'); $expected_config = $this->getDefaultInternalConfig() + [ 'drupalImage_dialogTitleAdd' => 'Insert Image', 'drupalImage_dialogTitleEdit' => 'Edit Image', Loading @@ -101,8 +102,8 @@ class CKEditorTest extends KernelTestBase { 'language' => 'en', 'stylesSet' => FALSE, 'drupalExternalPlugins' => [ 'drupalimage' => $this->fileUrlGenerator->generateString('core/modules/ckeditor/js/plugins/drupalimage/plugin.js'), 'drupallink' => $this->fileUrlGenerator->generateString('core/modules/ckeditor/js/plugins/drupallink/plugin.js'), 'drupalimage' => $this->fileUrlGenerator->generateString("$ckeditor_module_path/js/plugins/drupalimage/plugin.js"), 'drupallink' => $this->fileUrlGenerator->generateString("$ckeditor_module_path/js/plugins/drupallink/plugin.js"), ], ]; $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for default configuration.'); Loading @@ -122,9 +123,9 @@ class CKEditorTest extends KernelTestBase { $expected_config['toolbar'][0]['items'][] = 'Format'; $expected_config['format_tags'] = 'p;h2;h3;h4;h5;h6'; $expected_config['extraPlugins'] .= ',llama_contextual,llama_contextual_and_button'; $expected_config['drupalExternalPlugins']['llama_contextual'] = $this->fileUrlGenerator->generateString('core/modules/ckeditor/tests/modules/js/llama_contextual.js'); $expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = $this->fileUrlGenerator->generateString('core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js'); $expected_config['contentsCss'][] = $this->fileUrlGenerator->generateString('core/modules/ckeditor/tests/modules/ckeditor_test.css') . $query_string; $expected_config['drupalExternalPlugins']['llama_contextual'] = $this->fileUrlGenerator->generateString("$ckeditor_module_path/tests/modules/js/llama_contextual.js"); $expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = $this->fileUrlGenerator->generateString("$ckeditor_module_path/tests/modules/js/llama_contextual_and_button.js"); $expected_config['contentsCss'][] = $this->fileUrlGenerator->generateString("$ckeditor_module_path/tests/modules/ckeditor_test.css") . $query_string; $this->assertEquals($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.'); // Change the allowed HTML tags; the "allowedContent" and "format_tags" Loading Loading @@ -552,9 +553,10 @@ class CKEditorTest extends KernelTestBase { } protected function getDefaultContentsCssConfig() { $ckeditor_module_path = $this->getModulePath('ckeditor'); $query_string = '?0='; return [ $this->fileUrlGenerator->generateString('core/modules/ckeditor/css/ckeditor-iframe.css') . $query_string, $this->fileUrlGenerator->generateString("$ckeditor_module_path/css/ckeditor-iframe.css") . $query_string, $this->fileUrlGenerator->generateString('core/modules/system/css/components/align.module.css') . $query_string, ]; } Loading