public function ContainerTest::testGetThrowServiceNotFoundException in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testGetThrowServiceNotFoundException()
File
- vendor/
symfony/ dependency-injection/ Tests/ ContainerTest.php, line 238
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testGetThrowServiceNotFoundException() {
$sc = new ProjectServiceContainer();
$sc
->set('foo', $foo = new \stdClass());
$sc
->set('bar', $foo = new \stdClass());
$sc
->set('baz', $foo = new \stdClass());
try {
$sc
->get('foo1');
$this
->fail('->get() throws an Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException if the key does not exist');
} catch (\Exception $e) {
$this
->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException', $e, '->get() throws an Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException if the key does not exist');
$this
->assertEquals('You have requested a non-existent service "foo1". Did you mean this: "foo"?', $e
->getMessage(), '->get() throws an Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException with some advices');
}
try {
$sc
->get('bag');
$this
->fail('->get() throws an Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException if the key does not exist');
} catch (\Exception $e) {
$this
->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException', $e, '->get() throws an Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException if the key does not exist');
$this
->assertEquals('You have requested a non-existent service "bag". Did you mean one of these: "bar", "baz"?', $e
->getMessage(), '->get() throws an Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException with some advices');
}
}