3 namespace Drupal\Tests\ckeditor\Functional;
5 use Drupal\filter\Entity\FilterFormat;
6 use Drupal\editor\Entity\Editor;
7 use Drupal\Tests\BrowserTestBase;
8 use Drupal\Component\Serialization\Json;
11 * Tests CKEditor toolbar buttons when the language direction is RTL.
15 class CKEditorToolbarButtonTest extends BrowserTestBase {
18 * Modules to enable for this test.
22 public static $modules = ['filter', 'editor', 'ckeditor', 'locale'];
27 protected function setUp() {
30 // Create a text format and associate this with CKEditor.
31 FilterFormat::create([
32 'format' => 'full_html',
33 'name' => 'Full HTML',
38 'format' => 'full_html',
39 'editor' => 'ckeditor',
42 // Create a new user with admin rights.
43 $this->admin_user = $this->drupalCreateUser([
44 'administer languages',
45 'access administration pages',
46 'administer site configuration',
52 * Method tests CKEditor image buttons.
54 public function testImageButtonDisplay() {
55 $this->drupalLogin($this->admin_user);
57 // Install the Arabic language (which is RTL) and configure as the default.
59 $edit['predefined_langcode'] = 'ar';
60 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
62 $edit = ['site_default_language' => 'ar'];
63 $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
64 // Once the default language is changed, go to the tested text format
65 // configuration page.
66 $this->drupalGet('admin/config/content/formats/manage/full_html');
68 // Check if any image button is loaded in CKEditor json.
69 $json_encode = function ($html) {
70 return trim(Json::encode($html), '"');
72 $markup = $json_encode(file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupalimage/icons/drupalimage.png')));
73 $this->assertRaw($markup);