class CKEditorStylesComboTranslationTest
Tests administration of the CKEditor StylesCombo plugin.
@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\CKEditorStylesComboTranslationTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of CKEditorStylesComboTranslationTest
File
-
core/
modules/ ckeditor/ tests/ src/ Functional/ CKEditorStylesComboTranslationTest.php, line 16
Namespace
Drupal\Tests\ckeditor\FunctionalView source
class CKEditorStylesComboTranslationTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'ckeditor',
'config_translation',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A user with the 'administer filters' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* A randomly generated format machine name.
*
* @var string
*/
protected $format;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->format = strtolower($this->randomMachineName());
$filter_format = FilterFormat::create([
'format' => $this->format,
'name' => $this->randomString(),
'filters' => [],
]);
$filter_format->save();
$ckeditor = $this->container
->get('plugin.manager.editor')
->createInstance('ckeditor');
$settings = $ckeditor->getDefaultSettings();
$settings['toolbar']['rows'][0][] = [
'name' => 'Styles dropdown',
'items' => [
'Styles',
],
];
$editor = Editor::create([
'format' => $this->format,
'editor' => 'ckeditor',
'settings' => $settings,
]);
$editor->save();
$this->adminUser = $this->drupalCreateUser([
'administer filters',
'translate configuration',
]);
ConfigurableLanguage::createFromLangcode('de')->save();
}
/**
* Tests translations of CKEditor styles configuration.
*/
public function testExistingFormat() {
$this->drupalLogin($this->adminUser);
$edit = [
'editor[settings][plugins][stylescombo][styles]' => 'h1.title|Title',
];
$this->drupalGet('admin/config/content/formats/manage/' . $this->format);
$this->submitForm($edit, 'Save configuration');
$this->drupalGet('admin/config/content/formats/manage/' . $this->format . '/translate/de/add');
$this->assertEquals('textarea', $this->assertSession()
->fieldExists('List of styles')
->getTagName());
$this->assertSession()
->fieldValueEquals('List of styles', 'h1.title|Title');
$page = $this->getSession()
->getPage();
$page->fillField('List of styles', 'h1.title|Titel');
$page->pressButton('Save translation');
$this->assertSession()
->pageTextContains('Successfully saved German translation.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.