1111use Ibexa \Core \MVC \Symfony \Component \Serializer \SerializerTrait ;
1212use Ibexa \Core \MVC \Symfony \SiteAccess ;
1313use Symfony \Component \HttpFoundation \Request ;
14- use Symfony \Component \HttpFoundation \Response ;
1514use Symfony \Component \HttpKernel \Controller \ControllerReference ;
1615use Symfony \Component \HttpKernel \Fragment \FragmentRendererInterface ;
1716use Symfony \Component \Serializer \Normalizer \AbstractNormalizer ;
@@ -23,24 +22,7 @@ class InlineFragmentRendererTest extends DecoratedFragmentRendererTest
2322{
2423 use SerializerTrait;
2524
26- /**
27- * @return iterable<array{0: array<string, string>|null}>
28- */
29- public function rendererControllerReferenceDataProvider (): iterable
30- {
31- yield [[
32- 'my_param1 ' => 'custom_data ' ,
33- 'my_param2 ' => 'foobar ' ,
34- ]];
35-
36- yield [null ];
37- }
38-
39- /**
40- * @param array<string, string>|null $params
41- * @dataProvider rendererControllerReferenceDataProvider
42- */
43- public function testRendererControllerReference (?array $ params = null )
25+ public function testRendererControllerReference ()
4426 {
4527 $ reference = new ControllerReference ('FooBundle:bar:baz ' );
4628 $ matcher = new SiteAccess \Matcher \HostElement (1 );
@@ -54,55 +36,41 @@ public function testRendererControllerReference(?array $params = null)
5436 $ request ->attributes ->set ('semanticPathinfo ' , '/foo/bar ' );
5537 $ request ->attributes ->set ('viewParametersString ' , '/(foo)/bar ' );
5638 $ options = ['foo ' => 'bar ' ];
57-
5839 $ expectedReturn = '/_fragment?foo=bar ' ;
5940 $ this ->innerRenderer
6041 ->expects ($ this ->once ())
6142 ->method ('render ' )
6243 ->with ($ reference , $ request , $ options )
63- ->willReturnCallback (
64- static function (ControllerReference $ url , Request $ request , array $ callBackOptions ) use ($ expectedReturn , $ params , $ options ): Response {
65- if ($ params !== null ) {
66- self ::assertEquals ($ params , $ url ->attributes ['params ' ]);
67- }
68- self ::assertEquals ($ options , $ callBackOptions );
69-
70- return new Response ($ expectedReturn );
71- }
72- );
73-
74- if ($ params !== null ) {
75- $ options ['params ' ] = $ params ;
76- }
44+ ->will ($ this ->returnValue ($ expectedReturn ));
7745
7846 $ renderer = $ this ->getRenderer ();
79- self :: assertEquals ( new Response ( $ expectedReturn) , $ renderer ->render ($ reference , $ request , $ options ));
80- self :: assertTrue (isset ($ reference ->attributes ['serialized_siteaccess ' ]));
47+ $ this -> assertSame ( $ expectedReturn , $ renderer ->render ($ reference , $ request , $ options ));
48+ $ this -> assertTrue (isset ($ reference ->attributes ['serialized_siteaccess ' ]));
8149 $ serializedSiteAccess = json_encode ($ siteAccess );
82- self :: assertSame ($ serializedSiteAccess , $ reference ->attributes ['serialized_siteaccess ' ]);
83- self :: assertTrue (isset ($ reference ->attributes ['serialized_siteaccess_matcher ' ]));
84- self :: assertSame (
50+ $ this -> assertSame ($ serializedSiteAccess , $ reference ->attributes ['serialized_siteaccess ' ]);
51+ $ this -> assertTrue (isset ($ reference ->attributes ['serialized_siteaccess_matcher ' ]));
52+ $ this -> assertSame (
8553 $ this ->getSerializer ()->serialize (
8654 $ siteAccess ->matcher ,
8755 'json ' ,
8856 [AbstractNormalizer::IGNORED_ATTRIBUTES => ['request ' , 'container ' , 'matcherBuilder ' ]]
8957 ),
9058 $ reference ->attributes ['serialized_siteaccess_matcher ' ]
9159 );
92- self :: assertTrue (isset ($ reference ->attributes ['semanticPathinfo ' ]));
93- self :: assertSame ('/foo/bar ' , $ reference ->attributes ['semanticPathinfo ' ]);
94- self :: assertTrue (isset ($ reference ->attributes ['viewParametersString ' ]));
95- self :: assertSame ('/(foo)/bar ' , $ reference ->attributes ['viewParametersString ' ]);
60+ $ this -> assertTrue (isset ($ reference ->attributes ['semanticPathinfo ' ]));
61+ $ this -> assertSame ('/foo/bar ' , $ reference ->attributes ['semanticPathinfo ' ]);
62+ $ this -> assertTrue (isset ($ reference ->attributes ['viewParametersString ' ]));
63+ $ this -> assertSame ('/(foo)/bar ' , $ reference ->attributes ['viewParametersString ' ]);
9664 }
9765
9866 public function testRendererControllerReferenceWithCompoundMatcher (): ControllerReference
9967 {
10068 $ reference = parent ::testRendererControllerReferenceWithCompoundMatcher ();
10169
102- self :: assertArrayHasKey ('semanticPathinfo ' , $ reference ->attributes );
103- self :: assertSame ('/foo/bar ' , $ reference ->attributes ['semanticPathinfo ' ]);
104- self :: assertArrayHasKey ('viewParametersString ' , $ reference ->attributes );
105- self :: assertSame ('/(foo)/bar ' , $ reference ->attributes ['viewParametersString ' ]);
70+ $ this -> assertArrayHasKey ('semanticPathinfo ' , $ reference ->attributes );
71+ $ this -> assertSame ('/foo/bar ' , $ reference ->attributes ['semanticPathinfo ' ]);
72+ $ this -> assertArrayHasKey ('viewParametersString ' , $ reference ->attributes );
73+ $ this -> assertSame ('/(foo)/bar ' , $ reference ->attributes ['viewParametersString ' ]);
10674
10775 return $ reference ;
10876 }
0 commit comments