You are here

function EditorTestCase::testLibrary in Editor 7

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

./editor.test, line 972
Tests for Editor module.

Class

EditorTestCase
Tests editor functionality.

Code

function testLibrary() {
  $this
    ->drupalGet('admin/config/content/formats');
  $this
    ->clickLink(t('Add text format'));

  // Select CKEditor and refresh the page.
  $this
    ->drupalPost(NULL, array(
    'name' => 'CKEditor',
    'format' => 'ckeditor',
    'editor' => 'ckeditor',
    'roles[' . DRUPAL_AUTHENTICATED_RID . ']' => 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',
          'DrupalImage',
          'Styles',
        ),
      ),
    ),
  );
  $this
    ->drupalPost(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[editor_align][status]' => TRUE,
    'filters[editor_caption][status]' => TRUE,
  ), t('Save configuration'));
  $this
    ->drupalGet('node/add/article');
  $this
    ->assertRaw('editor/modules/editor_ckeditor/css/ckeditor.css');
  $this
    ->assertRaw('editor/modules/editor_ckeditor/lib/ckeditor/ckeditor.js');
  $this
    ->assertRaw('editor/modules/editor_ckeditor/js/ckeditor.js');
  $settings = $this
    ->drupalGetSettings();
  $format_settings = $settings['editor']['formats']['ckeditor'];
  $this
    ->assertEqual($format_settings['editorSettings']['toolbar'], $toolbar[0], 'CKEditor toolbar settings saved and added correctly.');
  $this
    ->assertEqual($format_settings['editorSettings']['extraPlugins'], 'drupalimagecaption,drupalimage', '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');
}