1 ckeditor5.test | protected CKEditor5TestCase::testLibrary() |
Test the addition of the library to the page when configured.
With no JavaScript level testing, we can only ensure the library is present on the page.
File
- core/
modules/ ckeditor5/ tests/ ckeditor5.test, line 51 - Tests for ckeditor5.module.
Class
- CKEditor5TestCase
- Functional tests for CKEditor5 module.
Code
protected function testLibrary() {
$this->backdropGet('admin/config/content/formats');
$this->clickLink(t('Add text format'));
// Select CKEditor and refresh the page.
$this->backdropPost(NULL, array(
'name' => 'CKEditor5',
'format' => 'ckeditor5',
'editor' => 'ckeditor5',
'roles[authenticated]' => TRUE,
), t('Configure editor'));
$toolbar = array(
'bold',
'italic',
'|',
'alignment:left',
'alignment:center',
'alignment:right',
'|',
'bulletedList',
'numberedList',
'|',
'blockQuote',
'backdropImage',
);
$this->backdropPost(NULL, array(
'editor_settings[toolbar]' => json_encode($toolbar),
'filters[filter_autop][status]' => TRUE,
'filters[filter_image_align][status]' => TRUE,
'filters[filter_image_caption][status]' => TRUE,
), t('Save configuration'));
$this->backdropGet('node/add/article');
$this->assertRaw('modules/ckeditor5/css/ckeditor5.css');
$this->assertRaw('modules/ckeditor5/js/ckeditor5.js');
$this->assertRaw('modules/ckeditor5/lib/ckeditor5/build/ckeditor5-dll.js');
$settings = $this->backdropGetSettings();
$format_settings = $settings['filter']['formats']['ckeditor5'];
$this->assertEqual($format_settings['editorSettings']['toolbar']['items'], $toolbar, 'CKEditor toolbar settings saved and added correctly.');
$expected_plugins = array(
'image.Image',
'image.ImageToolbar',
'image.ImageInsertUI',
'image.ImageUpload',
'image.ImageResize',
'image.ImageCaptionUtils',
'list.List',
'list.ListProperties',
'alignment.Alignment',
'basicStyles.Italic',
'backdropBasicStyles.BackdropBasicStyles',
'basicStyles.Bold',
'image.ImageStyle',
'image.ImageCaption',
'essentials.Essentials',
'autoformat.Autoformat',
'pasteFromOffice.PasteFromOffice',
'paragraph.Paragraph',
'htmlSupport.GeneralHtmlSupport',
'backdropHtmlEngine.BackdropHtmlEngine',
'blockQuote.BlockQuote',
'backdropImage.BackdropImage',
);
$this->assertEqual($format_settings['editorSettings']['pluginList'], $expected_plugins, 'CKEditor5 plugin list saved correctly');
// Turn on the table plugin and check that the JavaScript is adjusted.
$toolbar = array('insertTable');
$this->backdropPost('admin/config/content/formats/ckeditor5', array(
'editor_settings[toolbar]' => json_encode($toolbar),
'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <p> <img> <figure> <figcaption> <table> <thead> <tbody> <tr> <td> <th>',
), t('Save configuration'));
$this->backdropGet('node/add/article');
$settings = $this->backdropGetSettings();
$format_settings = $settings['filter']['formats']['ckeditor5'];
$expected_plugins = array(
'table.TableToolbar',
'table.TableCaption',
'table.PlainTableOutput',
'table.TableCellProperties',
'table.TableColumnResize',
'table.TableProperties',
'image.ImageStyle',
'image.ImageCaption',
'essentials.Essentials',
'autoformat.Autoformat',
'pasteFromOffice.PasteFromOffice',
'paragraph.Paragraph',
'htmlSupport.GeneralHtmlSupport',
'backdropBasicStyles.BackdropBasicStyles',
'backdropHtmlEngine.BackdropHtmlEngine',
'table.Table',
);
$this->assertEqual($format_settings['editorSettings']['pluginList'], $expected_plugins, 'CKEditor5 plugin list saved correctly');
}