1 ckeditor5_rtl.test public CKEditor5RtlTestCase::testRtlAdminIcons()

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

File

core/modules/ckeditor5/tests/ckeditor5_rtl.test, line 54
Tests for ckeditor.module.

Class

CKEditor5RtlTestCase
CKEditor 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));
  // 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(
    'bulleted-list' => 'ckeditor5\\\/icons\\\/bulleted-list-rtl.svg',
    'numbered-list' => 'ckeditor5\\\/icons\\\/numbered-list-rtl.svg',
    'undo' => 'ckeditor5\\\/icons\\\/undo-rtl.svg',
    'redo' => 'ckeditor5\\\/icons\\\/redo-rtl.svg',
  );

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