X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fckeditor%2Ftests%2Fsrc%2FFunctional%2FCKEditorStylesComboAdminTest.php;fp=web%2Fcore%2Fmodules%2Fckeditor%2Ftests%2Fsrc%2FFunctional%2FCKEditorStylesComboAdminTest.php;h=9f41834de5ba0f1b221f2c267099f4f5ef7be61c;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php b/web/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php new file mode 100644 index 000000000..9f41834de --- /dev/null +++ b/web/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php @@ -0,0 +1,99 @@ +format = strtolower($this->randomMachineName()); + $filter_format = FilterFormat::create([ + 'format' => $this->format, + 'name' => $this->randomString(), + 'filters' => [], + ]); + $filter_format->save(); + $editor = Editor::create([ + 'format' => $this->format, + 'editor' => 'ckeditor', + ]); + $editor->save(); + + $this->adminUser = $this->drupalCreateUser(['administer filters']); + } + + /** + * Tests StylesCombo settings for an existing text format. + */ + public function testExistingFormat() { + $ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor'); + $default_settings = $ckeditor->getDefaultSettings(); + + $this->drupalLogin($this->adminUser); + $this->drupalGet('admin/config/content/formats/manage/' . $this->format); + + // Ensure an Editor config entity exists, with the proper settings. + $expected_settings = $default_settings; + $editor = Editor::load($this->format); + $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.'); + + // Case 1: Configure the Styles plugin with different labels for each style, + // and ensure the updated settings are saved. + $this->drupalGet('admin/config/content/formats/manage/' . $this->format); + $edit = [ + 'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\n\n", + ]; + $this->drupalPostForm(NULL, $edit, t('Save configuration')); + $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n"; + $editor = Editor::load($this->format); + $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.'); + + // Case 2: Configure the Styles plugin with same labels for each style, and + // ensure that an error is displayed and that the updated settings are not + // saved. + $this->drupalGet('admin/config/content/formats/manage/' . $this->format); + $edit = [ + 'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Title\n\n", + ]; + $this->drupalPostForm(NULL, $edit, t('Save configuration')); + $this->assertRaw(t('Each style must have a unique label.')); + $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n"; + $editor = Editor::load($this->format); + $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.'); + } + +}