44
55use Aymdev \CommonmarkBundle \Twig \CommonMarkExtension ;
66use League \CommonMark \MarkdownConverter ;
7+ use League \CommonMark \Node \Block \Document ;
8+ use League \CommonMark \Output \RenderedContent ;
79use PHPUnit \Framework \TestCase ;
810use Symfony \Component \DependencyInjection \ServiceLocator ;
911
@@ -16,20 +18,25 @@ public function testFilterBasicUsage()
1618 $ converterMockA = $ this ->getMockBuilder (MarkdownConverter::class)
1719 ->disableOriginalConstructor ()
1820 ->getMock ();
19- $ converterMockA ->method ('convertToHtml ' )->willReturn ('a ' );
21+ $ converterMockA ->method ('convertToHtml ' )
22+ ->willReturn (new RenderedContent (new Document (), 'a ' ));
2023 return $ converterMockA ;
2124 },
2225 'b_conv ' => function () {
2326 $ converterMockB = $ this ->getMockBuilder (MarkdownConverter::class)
2427 ->disableOriginalConstructor ()
2528 ->getMock ();
26- $ converterMockB ->method ('convertToHtml ' )->willReturn ('b ' );
29+ $ converterMockB ->method ('convertToHtml ' )
30+ ->willReturn (new RenderedContent (new Document (), 'b ' ));
2731 return $ converterMockB ;
2832 },
2933 ]);
3034
3135 $ extension = new CommonMarkExtension ($ serviceLocator );
3236
37+ $ output = $ extension ->convertMarkdown ('' , 'a_conv ' );
38+ self ::assertSame ('a ' , $ output );
39+
3340 $ output = $ extension ->convertMarkdown ('' , 'b_conv ' );
3441 self ::assertSame ('b ' , $ output );
3542 }
@@ -44,16 +51,15 @@ public function testFilterConverterNameIsOptional()
4451 $ converterMock = $ this ->getMockBuilder (MarkdownConverter::class)
4552 ->disableOriginalConstructor ()
4653 ->getMock ();
47- $ converterMock ->expects (self ::once ())->method ('convertToHtml ' )->willReturnArgument (0 );
54+ $ converterMock ->expects (self ::once ())->method ('convertToHtml ' )
55+ ->willReturn (new RenderedContent (new Document (), 'some markdown content ' ));
4856 return $ converterMock ;
4957 },
5058 ]);
5159 $ extension = new CommonMarkExtension ($ serviceLocator );
5260
53- $ expectedOutput = 'some markdown content ' ;
54- $ actualOutput = $ extension ->convertMarkdown ($ expectedOutput );
55-
56- self ::assertSame ($ expectedOutput , $ actualOutput );
61+ $ actualOutput = $ extension ->convertMarkdown ('' );
62+ self ::assertSame ('some markdown content ' , $ actualOutput );
5763 }
5864
5965 /**
0 commit comments