24
24
use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
25
25
use Symfony \Component \DependencyInjection \Reference ;
26
26
use Symfony \Component \ErrorHandler \ErrorRenderer \HtmlErrorRenderer ;
27
+ use Symfony \Component \Mailer \Mailer ;
27
28
28
29
class TwigExtensionTest extends TestCase
29
30
{
@@ -43,6 +44,10 @@ public function testLoadEmptyConfiguration()
43
44
$ this ->assertEquals ('%kernel.cache_dir%/twig ' , $ options ['cache ' ], '->load() sets default value for cache option ' );
44
45
$ this ->assertEquals ('%kernel.charset% ' , $ options ['charset ' ], '->load() sets default value for charset option ' );
45
46
$ this ->assertEquals ('%kernel.debug% ' , $ options ['debug ' ], '->load() sets default value for debug option ' );
47
+
48
+ if (class_exists (Mailer::class)) {
49
+ $ this ->assertCount (1 , $ container ->getDefinition ('twig.mime_body_renderer ' )->getArguments ());
50
+ }
46
51
}
47
52
48
53
/**
@@ -263,6 +268,25 @@ public function testRuntimeLoader()
263
268
$ this ->assertEquals ('foo ' , $ args ['FooClass ' ]->getValues ()[0 ]);
264
269
}
265
270
271
+ /**
272
+ * @dataProvider getFormats
273
+ */
274
+ public function testCustomHtmlToTextConverterService (string $ format )
275
+ {
276
+ if (!class_exists (Mailer::class)) {
277
+ $ this ->markTestSkipped ('The "twig.mime_body_renderer" service requires the Mailer component ' );
278
+ }
279
+
280
+ $ container = $ this ->createContainer ();
281
+ $ container ->registerExtension (new TwigExtension ());
282
+ $ this ->loadFromFile ($ container , 'mailer ' , $ format );
283
+ $ this ->compileContainer ($ container );
284
+
285
+ $ bodyRenderer = $ container ->getDefinition ('twig.mime_body_renderer ' );
286
+ $ this ->assertCount (2 , $ bodyRenderer ->getArguments ());
287
+ $ this ->assertEquals (new Reference ('my_converter ' ), $ bodyRenderer ->getArgument ('$converter ' ));
288
+ }
289
+
266
290
private function createContainer ()
267
291
{
268
292
$ container = new ContainerBuilder (new ParameterBag ([
0 commit comments