@@ -2050,16 +2050,14 @@ public function testHtmlSanitizer()
20502050 $ container = $ this ->createContainerFromFile ('html_sanitizer ' );
20512051
20522052 // html_sanitizer service
2053- $ this ->assertTrue ($ container ->hasAlias ('html_sanitizer ' ), '->registerHtmlSanitizerConfiguration() loads html_sanitizer.php ' );
2054- $ this ->assertSame ('html_sanitizer.sanitizer.default ' , (string ) $ container ->getAlias ('html_sanitizer ' ));
2055- $ this ->assertSame (HtmlSanitizer::class, $ container ->getDefinition ('html_sanitizer.sanitizer.default ' )->getClass ());
2056- $ this ->assertCount (1 , $ args = $ container ->getDefinition ('html_sanitizer.sanitizer.default ' )->getArguments ());
2057- $ this ->assertSame ('html_sanitizer.config.default ' , (string ) $ args [0 ]);
2053+ $ this ->assertSame (HtmlSanitizer::class, $ container ->getDefinition ('html_sanitizer.sanitizer.custom ' )->getClass ());
2054+ $ this ->assertCount (1 , $ args = $ container ->getDefinition ('html_sanitizer.sanitizer.custom ' )->getArguments ());
2055+ $ this ->assertSame ('html_sanitizer.config.custom ' , (string ) $ args [0 ]);
20582056
20592057 // config
2060- $ this ->assertTrue ($ container ->hasDefinition ('html_sanitizer.config.default ' ), '->registerHtmlSanitizerConfiguration() loads custom sanitizer ' );
2061- $ this ->assertSame (HtmlSanitizerConfig::class, $ container ->getDefinition ('html_sanitizer.config.default ' )->getClass ());
2062- $ this ->assertCount (23 , $ calls = $ container ->getDefinition ('html_sanitizer.config.default ' )->getMethodCalls ());
2058+ $ this ->assertTrue ($ container ->hasDefinition ('html_sanitizer.config.custom ' ), '->registerHtmlSanitizerConfiguration() loads custom sanitizer ' );
2059+ $ this ->assertSame (HtmlSanitizerConfig::class, $ container ->getDefinition ('html_sanitizer.config.custom ' )->getClass ());
2060+ $ this ->assertCount (23 , $ calls = $ container ->getDefinition ('html_sanitizer.config.custom ' )->getMethodCalls ());
20632061 $ this ->assertSame (
20642062 [
20652063 ['allowSafeElements ' , [], true ],
@@ -2103,6 +2101,30 @@ static function ($call) {
21032101 // Named alias
21042102 $ this ->assertSame ('html_sanitizer.sanitizer.all.sanitizer ' , (string ) $ container ->getAlias (HtmlSanitizerInterface::class.' $allSanitizer ' ));
21052103 $ this ->assertFalse ($ container ->hasAlias (HtmlSanitizerInterface::class.' $default ' ));
2104+ }
2105+
2106+ public function testHtmlSanitizerDefaultConfig ()
2107+ {
2108+ $ container = $ this ->createContainerFromFile ('html_sanitizer_default_config ' );
2109+
2110+ // html_sanitizer service
2111+ $ this ->assertTrue ($ container ->hasAlias ('html_sanitizer ' ), '->registerHtmlSanitizerConfiguration() loads default_config ' );
2112+ $ this ->assertSame ('html_sanitizer.sanitizer.default ' , (string ) $ container ->getAlias ('html_sanitizer ' ));
2113+ $ this ->assertSame (HtmlSanitizer::class, $ container ->getDefinition ('html_sanitizer.sanitizer.default ' )->getClass ());
2114+ $ this ->assertCount (1 , $ args = $ container ->getDefinition ('html_sanitizer.sanitizer.default ' )->getArguments ());
2115+ $ this ->assertSame ('html_sanitizer.config.default ' , (string ) $ args [0 ]);
2116+
2117+ // config
2118+ $ this ->assertTrue ($ container ->hasDefinition ('html_sanitizer.config.default ' ), '->registerHtmlSanitizerConfiguration() loads custom sanitizer ' );
2119+ $ this ->assertSame (HtmlSanitizerConfig::class, $ container ->getDefinition ('html_sanitizer.config.default ' )->getClass ());
2120+ $ this ->assertCount (1 , $ calls = $ container ->getDefinition ('html_sanitizer.config.default ' )->getMethodCalls ());
2121+ $ this ->assertSame (
2122+ ['allowSafeElements ' , [], true ],
2123+ $ calls [0 ]
2124+ );
2125+
2126+ // Named alias
2127+ $ this ->assertFalse ($ container ->hasAlias (HtmlSanitizerInterface::class.' $default ' ));
21062128
21072129 // Default alias
21082130 $ this ->assertSame ('html_sanitizer ' , (string ) $ container ->getAlias (HtmlSanitizerInterface::class));
0 commit comments