class CKEditorToolbarButtonTest
Same name and namespace in other branches
- 8.9.x core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php \Drupal\Tests\ckeditor\Functional\CKEditorToolbarButtonTest
Tests CKEditor toolbar buttons when the language direction is RTL.
@group ckeditor @group legacy
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\ckeditor\Functional\CKEditorToolbarButtonTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of CKEditorToolbarButtonTest
File
-
core/
modules/ ckeditor/ tests/ src/ Functional/ CKEditorToolbarButtonTest.php, line 16
Namespace
Drupal\Tests\ckeditor\FunctionalView source
class CKEditorToolbarButtonTest extends BrowserTestBase {
/**
* Modules to enable for this test.
*
* @var array
*/
protected static $modules = [
'filter',
'editor',
'ckeditor',
'locale',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* The admin user.
*
* @var \Drupal\user\Entity\User
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Create a text format and associate this with CKEditor.
FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => [],
])->save();
Editor::create([
'format' => 'full_html',
'editor' => 'ckeditor',
])->save();
// Create a new user with admin rights.
$this->adminUser = $this->drupalCreateUser([
'administer languages',
'access administration pages',
'administer site configuration',
'administer filters',
]);
}
/**
* Method tests CKEditor image buttons.
*/
public function testImageButtonDisplay() {
$this->drupalLogin($this->adminUser);
// Install the Arabic language (which is RTL) and configure as the default.
$edit = [];
$edit['predefined_langcode'] = 'ar';
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add language');
$edit = [
'site_default_language' => 'ar',
];
$this->drupalGet('admin/config/regional/language');
$this->submitForm($edit, 'Save configuration');
// Once the default language is changed, go to the tested text format
// configuration page.
$this->drupalGet('admin/config/content/formats/manage/full_html');
// Check if any image button is loaded in CKEditor json.
$json_encode = function ($html) {
return trim(Json::encode($html), '"');
};
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$markup = $json_encode($file_url_generator->generateString('core/modules/ckeditor/js/plugins/drupalimage/icons/drupalimage.png'));
$this->assertSession()
->responseContains($markup);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.