Skip to content

Commit

Permalink
Issue backdrop#101: Adding update message and tests for CKEditor modu…
Browse files Browse the repository at this point in the history
…le and new fitlers.
  • Loading branch information
quicksketch committed Aug 1, 2015
1 parent 7a6f29a commit 339cbbe
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function ckeditor_ckeditor_plugins() {
),
'-' => array(
'label' => t('Separator'),
'image_alternative' => '<span class="ckeditor-separator">&nbsp;</span>',
'image_alternative' => '<span class="ckeditor-separator" title="' . t('Button separator') . '" aria-label="' . t('Button separator') . '">&nbsp;</span>',
'attributes' => array('class' => array('ckeditor-button-separator')),
'multiple' => TRUE,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,12 @@ function theme_ckeditor_settings_toolbar($variables) {
$output .= '</ul>';
$output .= '</div>';

return $output;
// Wrap the whole thing in a fieldset.
$fieldset = array(
'#type' => 'fieldset',
'#children' => $output,
'#title' => t('CKEditor Toolbar'),
);

return backdrop_render($fieldset);
}
95 changes: 95 additions & 0 deletions core/modules/ckeditor5/core/modules/ckeditor/tests/ckeditor.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/**
* @file
* Tests for ckeditor.module.
*/

class CKEditorTestCase extends BackdropWebTestCase {
protected $admin_user;
protected $profile = 'testing';

function setUp() {
parent::setUp('ckeditor');

// Create Article node type.
$content_type = $this->backdropCreateContentType(array(
'type' => 'article',
'name' => 'Article',
));
node_add_body_field($content_type);

// Create and log in as the admin user.
$this->admin_user = $this->backdropCreateUser(array(
'administer filters',
'access administration pages',
'access content',
'administer nodes',
'create article content',
));
$this->backdropLogin($this->admin_user);
}

/**
* 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.
*/
function testLibrary() {
$this->backdropGet('admin/config/content/formats');
$this->clickLink(t('Add text editor'));

// Select CKEditor and refresh the page.
$this->backdropPost(NULL, array(
'name' => 'CKEditor',
'format' => 'ckeditor',
'editor' => 'ckeditor',
'roles[authenticated]' => TRUE,
), t('Configure editor'));

$toolbar = array(
// First row.
array(
array(
'name' => 'Formatting',
'items' => array('Bold', 'Italic', 'Underline', 'Strike'),
),
array(
'name' => 'Alignment',
'items' => array('JustifyLeft', 'JustifyCenter', 'JustifyRight'),
),
array(
'name' => 'Lists',
'items' => array('BulletedList', 'NumberedList'),
),
array(
'name' => 'Media',
'items' => array('Blockquote', 'BackdropImage', 'Styles'),
),
),
);

$this->backdropPost(NULL, array(
'editor_settings[toolbar]' => json_encode($toolbar),
'editor_settings[plugins][style][style_list]' => "h1.title|Title\np.custom-class|Custom class\n",
'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('ckeditor/css/ckeditor.css');
$this->assertRaw('misc/ckeditor/ckeditor.js');
$this->assertRaw('ckeditor/js/ckeditor.js');
$settings = $this->backdropGetSettings();
$format_settings = $settings['filter']['formats']['ckeditor'];
$this->assertEqual($format_settings['editorSettings']['toolbar'], $toolbar[0], 'CKEditor toolbar settings saved and added correctly.');
$this->assertEqual($format_settings['editorSettings']['extraPlugins'], 'backdropimagecaption,backdropimage', 'Added custom plugins include custom image caption support.');
$style_list = array(
array('name' => 'Title', 'element' => 'h1', 'attributes' => array('class' => 'title')),
array('name' => 'Custom class', 'element' => 'p', 'attributes' => array('class' => 'custom-class')),
);
$this->assertEqual($format_settings['editorSettings']['stylesSet'], $style_list, 'Style list settings correct');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[CKEditorTestCase]
name = CKEditor
description = Check the functionality of CKEditor module.
group = CKEditor
file = ckeditor.test

0 comments on commit 339cbbe

Please sign in to comment.