- <?php
- * @file
- * Tests for ckeditor5.module.
- */
-
- * Functional tests for CKEditor5 module.
- */
- class CKEditor5TestCase extends BackdropWebTestCase {
-
- * @var User
- */
- protected $adminUser;
-
-
- * @var string
- */
- protected $profile = 'testing';
-
-
- * {@inheritdoc}
- */
- protected function setUp() {
- parent::setUp(array('ckeditor5'));
-
-
- $content_type = $this->backdropCreateContentType(array(
- 'type' => 'article',
- 'name' => 'Article',
- ));
- node_add_body_field($content_type);
-
-
- $this->adminUser = $this->backdropCreateUser(array(
- 'administer filters',
- 'access administration pages',
- 'access content',
- 'administer nodes',
- 'create article content',
- ));
- $this->backdropLogin($this->adminUser);
- }
-
-
- * 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.
- */
- protected function testLibrary() {
- $this->backdropGet('admin/config/content/formats');
- $this->clickLink(t('Add text format'));
-
-
- $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');
-
-
- $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');
- }
- }