Skip to content

Commit d397e1e

Browse files
[TwigComponent]: Fix silently failing tests
1 parent 38998c1 commit d397e1e

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/TwigComponent/tests/Integration/ComponentFactoryTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,28 +139,34 @@ public function testLegacyAnonymous(): void
139139
{
140140
self::bootKernel(['environment' => 'legacy_anonymous']);
141141

142-
$this->expectException(\InvalidArgumentException::class);
143-
$this->factory()->metadataFor('anonymous:AButton');
142+
// Named templates should be found
143+
$metadata = $this->factory()->metadataFor('foo:bar:baz');
144+
$this->assertSame('components/foo/bar/baz.html.twig', $metadata->getTemplate());
144145

146+
// Prefixed nonymous templates should be found
147+
$metadata = $this->factory()->metadataFor('anonymous:AButton');
148+
$this->assertSame('anonymous/AButton.html.twig', $metadata->getTemplate());
149+
150+
// Unprefixed anonymous templates should not be found
145151
$this->expectException(\InvalidArgumentException::class);
146152
$this->factory()->metadataFor('AButton');
147-
148-
$metadata = $this->factory()->metadataFor('foo:bar:baz');
149-
$this->assertSame('components/components/foo:bar:baz.html.twig', $metadata->getTemplate());
150153
}
151154

152155
public function testAnonymous(): void
153156
{
154157
self::bootKernel(['environment' => 'anonymous_directory']);
155158

156-
$this->expectException(\InvalidArgumentException::class);
157-
$this->factory()->metadataFor('anonymous:AButton');
159+
// Named templates should be found
160+
$metadata = $this->factory()->metadataFor('foo:bar:baz');
161+
$this->assertSame('components/foo/bar/baz.html.twig', $metadata->getTemplate());
158162

163+
// Unprefix anonymous templates should be found
159164
$metadata = $this->factory()->metadataFor('AButton');
160-
$this->assertSame('components/anonymous/AButton.html.twig', $metadata->getTemplate());
165+
$this->assertSame('anonymous/AButton.html.twig', $metadata->getTemplate());
161166

167+
// Prefixed anonymous templates should not be found
162168
$this->expectException(\InvalidArgumentException::class);
163-
$this->factory()->metadataFor('foo:bar:baz');
169+
$this->factory()->metadataFor('anonymous:AButton');
164170
}
165171

166172
public function testAutoNamingInSubDirectory(): void

0 commit comments

Comments
 (0)