@@ -2050,16 +2050,14 @@ public function testHtmlSanitizer()
2050
2050
$ container = $ this ->createContainerFromFile ('html_sanitizer ' );
2051
2051
2052
2052
// 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 ]);
2058
2056
2059
2057
// 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 ());
2063
2061
$ this ->assertSame (
2064
2062
[
2065
2063
['allowSafeElements ' , [], true ],
@@ -2103,6 +2101,30 @@ static function ($call) {
2103
2101
// Named alias
2104
2102
$ this ->assertSame ('html_sanitizer.sanitizer.all.sanitizer ' , (string ) $ container ->getAlias (HtmlSanitizerInterface::class.' $allSanitizer ' ));
2105
2103
$ 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 ' ));
2106
2128
2107
2129
// Default alias
2108
2130
$ this ->assertSame ('html_sanitizer ' , (string ) $ container ->getAlias (HtmlSanitizerInterface::class));
0 commit comments