function SourceEditingTest::testAllowingExtraAttributes
Same name in other branches
- 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\SourceEditingTest::testAllowingExtraAttributes()
- 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\SourceEditingTest::testAllowingExtraAttributes()
Tests allowing extra attributes on already supported tags using GHS.
@dataProvider providerAllowingExtraAttributes
File
-
core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ SourceEditingTest.php, line 177
Class
- SourceEditingTest
- @coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\SourceEditing @covers \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getCKEditor5PluginConfig() @group ckeditor5 @internal
Namespace
Drupal\Tests\ckeditor5\FunctionalJavascriptCode
public function testAllowingExtraAttributes(string $original_markup, string $expected_markup, ?string $allowed_elements_string = NULL) {
$this->host->body->value = $original_markup;
$this->host
->save();
if ($allowed_elements_string) {
// Allow creating additional HTML using SourceEditing.
$text_editor = Editor::load('test_format');
$settings = $text_editor->getSettings();
$settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'][] = $allowed_elements_string;
$text_editor->setSettings($settings);
// Keep the allowed HTML tags in sync.
$text_format = FilterFormat::load('test_format');
$allowed_elements = HTMLRestrictions::fromTextFormat($text_format);
$updated_allowed_tags = $allowed_elements->merge(HTMLRestrictions::fromString($allowed_elements_string));
$filter_html_config = $text_format->filters('filter_html')
->getConfiguration();
$filter_html_config['settings']['allowed_html'] = $updated_allowed_tags->toFilterHtmlAllowedTagsString();
$text_format->setFilterConfig('filter_html', $filter_html_config);
// Verify the text format and editor are still a valid pair.
$this->assertSame([], array_map(function (ConstraintViolation $v) {
return (string) $v->getMessage();
}, iterator_to_array(CKEditor5::validatePair($text_editor, $text_format))));
// If valid, save both.
$text_format->save();
$text_editor->save();
}
$this->drupalGet($this->host
->toUrl('edit-form'));
$this->waitForEditor();
$this->assertSame($expected_markup, $this->getEditorDataAsHtmlString());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.