Skip to content

Commit 173db46

Browse files
committed
[TwigComponent] Prove #3195 occurs (by unit test)
1 parent 27bf7f8 commit 173db46

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/TwigComponent/tests/Unit/ComponentFactoryTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)