File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/TwigComponent/tests/Unit Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -93,4 +93,32 @@ public function testMetadataForReuseAnonymousConfig()
9393 $ this ->assertSame ('foo ' , $ metadata ->getName ());
9494 $ this ->assertSame ('foo.html.twig ' , $ metadata ->getTemplate ());
9595 }
96+
97+ /**
98+ * @testWith ["bar"]
99+ * ["Foo\\Bar"]
100+ */
101+ public function testPrefersClassComponentOverAnonymous (string $ name )
102+ {
103+ $ templateFinder = $ this ->createMock (ComponentTemplateFinderInterface::class);
104+ $ templateFinder ->expects ($ this ->never ())
105+ ->method ('findAnonymousComponentTemplate ' );
106+
107+ $ factory = new ComponentFactory (
108+ $ templateFinder ,
109+ $ this ->createMock (ServiceLocator::class),
110+ $ this ->createMock (PropertyAccessorInterface::class),
111+ $ this ->createMock (EventDispatcherInterface::class),
112+ [
113+ 'bar ' => ['key ' => 'bar ' , 'template ' => 'bar.html.twig ' ],
114+ ],
115+ ['Foo \\Bar ' => 'bar ' ],
116+ $ this ->createMock (Environment::class),
117+ );
118+
119+ $ metadata = $ factory ->metadataFor ($ name );
120+
121+ $ this ->assertSame ('bar ' , $ metadata ->getName ());
122+ $ this ->assertSame ('bar.html.twig ' , $ metadata ->getTemplate ());
123+ }
96124}
You can’t perform that action at this time.
0 commit comments