Skip to content

Commit 3daf1ed

Browse files
committed
add unit tests
1 parent aa8e293 commit 3daf1ed

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,33 @@ public function testSyntheticServiceWithBind()
150150

151151
$this->assertSame([1 => 'bar'], $container->getDefinition(NamedArgumentsDummy::class)->getArguments());
152152
}
153+
154+
public function testEmptyBindingTypehint()
155+
{
156+
$this->expectException(InvalidArgumentException::class);
157+
$this->expectExceptionMessage('Invalid constructor argument $apiKey for service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": string expected but found mixed. Check your service definition.');
158+
159+
$container = new ContainerBuilder();
160+
$bindings = [
161+
'string $apiKey' => new BoundArgument('foo'),
162+
];
163+
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
164+
$definition->setBindings($bindings);
165+
$pass = new ResolveBindingsPass();
166+
$pass->process($container);
167+
}
168+
169+
public function testWrongBindingTypeHint()
170+
{
171+
$this->expectException(InvalidArgumentException::class);
172+
$this->expectExceptionMessage('Invalid constructor argument $c for service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": string expected but found \Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass. Check your service definition.');
173+
$container = new ContainerBuilder();
174+
$bindings = [
175+
'string $c' => new BoundArgument('bar'),
176+
];
177+
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
178+
$definition->setBindings($bindings);
179+
$pass = new ResolveBindingsPass();
180+
$pass->process($container);
181+
}
153182
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy