1 ckeditor_rtl.test public CKEditorRtlTestCase::testRtlAdminIcons()

Test that the CKEditor 4 admin form works correctly with RTL languages.

File

core/modules/ckeditor/tests/ckeditor_rtl.test, line 53
Tests for ckeditor.module.

Class

CKEditorRtlTestCase
CKEditor 4 testing class specific for right-to-left languages.

Code

public function testRtlAdminIcons() {
  $arabic = language_load('ar');
  $notice = '<em class="placeholder">Notice</em>: Undefined index: image_rtl in <em class="placeholder">{closure}()</em>';

  $this->backdropGet('admin/config/content/formats/filtered_html', array('language' => $arabic));
  // Set the editor to CKEditor 4 before checking the source.
  $edit = array(
    'editor' => 'ckeditor',
    'editor_settings[toolbar]' => '[[{"name":"Formatting","items":["Bold","Italic"]}]]',
  );
  $this->backdropPost(NULL, $edit, t('Save configuration'));
  $this->backdropGet('admin/config/content/formats/filtered_html', array('language' => $arabic));

  // Make sure, there's no php notice.
  $this->assertNoRaw($notice, '"Notice: Undefined index: image_rtl in {closure}()" not found');

  // Get the settings script tag.
  $script_tag = $this->xpath('//script[contains(text(), :string)]', array(':string' => 'window.Backdrop'));
  $js_settings = (string) $script_tag[0];
  // If something goes wrong, the icon src is only the base url.
  $icons = array(
    'bold' => 'ckeditor\\\/images\\\/buttons\\\/bold.png',
    'italic' => 'ckeditor\\\/images\\\/buttons\\\/italic.png',
    'blockquote' => 'ckeditor\\\/images\\\/buttons\\\/blockquote.png',
    'cut' => 'ckeditor\\\/images\\\/buttons\\\/cut.png',
    'copy' => 'ckeditor\\\/images\\\/buttons\\\/copy.png',
    'paste' => 'ckeditor\\\/images\\\/buttons\\\/paste.png',
    'justifyblock' => 'ckeditor\\\/images\\\/buttons\\\/justifyblock.png',
  );

  foreach ($icons as $name => $icon) {
    $this->assertTrue(preg_match('#' . $icon . '#', $js_settings, $matches), format_string('Image src found for %icon', array('%icon' => $name)));
  }
}