function HTMLRestrictionsTest::testConvenienceConstructors
Same name in other branches
- 10 core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php \Drupal\Tests\ckeditor5\Unit\HTMLRestrictionsTest::testConvenienceConstructors()
- 11.x core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php \Drupal\Tests\ckeditor5\Unit\HTMLRestrictionsTest::testConvenienceConstructors()
@covers ::fromString() @covers ::fromTextFormat() @covers ::fromFilterPluginInstance() @dataProvider providerConvenienceConstructors
File
-
core/
modules/ ckeditor5/ tests/ src/ Unit/ HTMLRestrictionsTest.php, line 226
Class
- HTMLRestrictionsTest
- @coversDefaultClass \Drupal\ckeditor5\HTMLRestrictions @group ckeditor5
Namespace
Drupal\Tests\ckeditor5\UnitCode
public function testConvenienceConstructors($input, array $expected, ?array $expected_raw = NULL) : void {
$expected_raw = $expected_raw ?? $expected;
// ::fromString()
$this->assertSame($expected, HTMLRestrictions::fromString($input)->getAllowedElements());
$this->assertSame($expected_raw, HTMLRestrictions::fromString($input)->getAllowedElements(FALSE));
// ::fromTextFormat()
$text_format = $this->prophesize(FilterFormatInterface::class);
$text_format->getHTMLRestrictions()
->willReturn([
'allowed' => $expected_raw,
]);
$this->assertSame($expected, HTMLRestrictions::fromTextFormat($text_format->reveal())
->getAllowedElements());
$this->assertSame($expected_raw, HTMLRestrictions::fromTextFormat($text_format->reveal())
->getAllowedElements(FALSE));
// @see \Drupal\filter\Plugin\Filter\FilterHtml::getHTMLRestrictions()
$filter_html_additional_expectations = [
'*' => [
'style' => FALSE,
'on*' => FALSE,
'lang' => TRUE,
'dir' => [
'ltr' => TRUE,
'rtl' => TRUE,
],
],
];
// ::fromFilterPluginInstance()
$filter_plugin_instance = $this->prophesize(FilterInterface::class);
$filter_plugin_instance->getHTMLRestrictions()
->willReturn([
'allowed' => $expected_raw + $filter_html_additional_expectations,
]);
$this->assertSame($expected + $filter_html_additional_expectations, HTMLRestrictions::fromFilterPluginInstance($filter_plugin_instance->reveal())
->getAllowedElements());
$this->assertSame($expected_raw + $filter_html_additional_expectations, HTMLRestrictions::fromFilterPluginInstance($filter_plugin_instance->reveal())
->getAllowedElements(FALSE));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.