class CKEditorStylesComboTranslationTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboTranslationTest.php \Drupal\Tests\ckeditor\Functional\CKEditorStylesComboTranslationTest
- 9 core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboTranslationTest.php \Drupal\Tests\ckeditor\Functional\CKEditorStylesComboTranslationTest
Tests administration of the CKEditor StylesCombo plugin.
@group ckeditor
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\ckeditor\Functional\CKEditorStylesComboTranslationTest
Expanded class hierarchy of CKEditorStylesComboTranslationTest
File
- core/
modules/ ckeditor/ tests/ src/ Functional/ CKEditorStylesComboTranslationTest.php, line 15
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.');
}
}