4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Alias;
16 use Symfony\Component\DependencyInjection\Container;
17 use Symfony\Component\DependencyInjection\ContainerInterface;
18 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
19 use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
21 class ContainerTest extends TestCase
23 public function testConstructor()
25 $sc = new Container();
26 $this->assertSame($sc, $sc->get('service_container'), '__construct() automatically registers itself as a service');
28 $sc = new Container(new ParameterBag(array('foo' => 'bar')));
29 $this->assertEquals(array('foo' => 'bar'), $sc->getParameterBag()->all(), '__construct() takes an array of parameters as its first argument');
33 * @dataProvider dataForTestCamelize
35 public function testCamelize($id, $expected)
37 $this->assertEquals($expected, Container::camelize($id), sprintf('Container::camelize("%s")', $id));
40 public function dataForTestCamelize()
43 array('foo_bar', 'FooBar'),
44 array('foo.bar', 'Foo_Bar'),
45 array('foo.bar_baz', 'Foo_BarBaz'),
46 array('foo._bar', 'Foo_Bar'),
47 array('foo_.bar', 'Foo_Bar'),
49 array('.foo', '_Foo'),
51 array('foo.', 'Foo_'),
52 array('foo\bar', 'Foo_Bar'),
57 * @dataProvider dataForTestUnderscore
59 public function testUnderscore($id, $expected)
61 $this->assertEquals($expected, Container::underscore($id), sprintf('Container::underscore("%s")', $id));
64 public function dataForTestUnderscore()
67 array('FooBar', 'foo_bar'),
68 array('Foo_Bar', 'foo.bar'),
69 array('Foo_BarBaz', 'foo.bar_baz'),
70 array('FooBar_BazQux', 'foo_bar.baz_qux'),
71 array('_Foo', '.foo'),
72 array('Foo_', 'foo.'),
76 public function testCompile()
78 $sc = new Container(new ParameterBag(array('foo' => 'bar')));
79 $this->assertFalse($sc->getParameterBag()->isResolved(), '->compile() resolves the parameter bag');
81 $this->assertTrue($sc->getParameterBag()->isResolved(), '->compile() resolves the parameter bag');
82 $this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag', $sc->getParameterBag(), '->compile() changes the parameter bag to a FrozenParameterBag instance');
83 $this->assertEquals(array('foo' => 'bar'), $sc->getParameterBag()->all(), '->compile() copies the current parameters to the new parameter bag');
88 * @expectedDeprecation The Symfony\Component\DependencyInjection\Container::isFrozen() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the isCompiled() method instead.
89 * @expectedDeprecation The Symfony\Component\DependencyInjection\Container::isFrozen() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the isCompiled() method instead.
91 public function testIsFrozen()
93 $sc = new Container(new ParameterBag(array('foo' => 'bar')));
94 $this->assertFalse($sc->isFrozen(), '->isFrozen() returns false if the parameters are not frozen');
96 $this->assertTrue($sc->isFrozen(), '->isFrozen() returns true if the parameters are frozen');
99 public function testIsCompiled()
101 $sc = new Container(new ParameterBag(array('foo' => 'bar')));
102 $this->assertFalse($sc->isCompiled(), '->isCompiled() returns false if the container is not compiled');
104 $this->assertTrue($sc->isCompiled(), '->isCompiled() returns true if the container is compiled');
107 public function testIsCompiledWithFrozenParameters()
109 $sc = new Container(new FrozenParameterBag(array('foo' => 'bar')));
110 $this->assertFalse($sc->isCompiled(), '->isCompiled() returns false if the container is not compiled but the parameter bag is already frozen');
113 public function testGetParameterBag()
115 $sc = new Container();
116 $this->assertEquals(array(), $sc->getParameterBag()->all(), '->getParameterBag() returns an empty array if no parameter has been defined');
119 public function testGetSetParameter()
121 $sc = new Container(new ParameterBag(array('foo' => 'bar')));
122 $sc->setParameter('bar', 'foo');
123 $this->assertEquals('foo', $sc->getParameter('bar'), '->setParameter() sets the value of a new parameter');
125 $sc->setParameter('foo', 'baz');
126 $this->assertEquals('baz', $sc->getParameter('foo'), '->setParameter() overrides previously set parameter');
129 $sc->getParameter('baba');
130 $this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist');
131 } catch (\Exception $e) {
132 $this->assertInstanceOf('\InvalidArgumentException', $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
133 $this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
139 * @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since Symfony 3.4.
140 * @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "FOO" instead of "foo" is deprecated since Symfony 3.4.
142 public function testGetSetParameterWithMixedCase()
144 $sc = new Container(new ParameterBag(array('foo' => 'bar')));
146 $sc->setParameter('Foo', 'baz1');
147 $this->assertEquals('baz1', $sc->getParameter('foo'), '->setParameter() converts the key to lowercase');
148 $this->assertEquals('baz1', $sc->getParameter('FOO'), '->getParameter() converts the key to lowercase');
151 public function testGetServiceIds()
153 $sc = new Container();
154 $sc->set('foo', $obj = new \stdClass());
155 $sc->set('bar', $obj = new \stdClass());
156 $this->assertEquals(array('service_container', 'foo', 'bar'), $sc->getServiceIds(), '->getServiceIds() returns all defined service ids');
158 $sc = new ProjectServiceContainer();
159 $sc->set('foo', $obj = new \stdClass());
160 $this->assertEquals(array('service_container', 'internal', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'internal_dependency', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by factory methods in the method map, followed by service ids defined by set()');
165 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
167 public function testGetLegacyServiceIds()
169 $sc = new LegacyProjectServiceContainer();
170 $sc->set('foo', $obj = new \stdClass());
172 $this->assertEquals(array('internal', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'throws_exception_on_service_configuration', 'service_container', 'foo'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods, followed by service ids defined by set()');
175 public function testSet()
177 $sc = new Container();
178 $sc->set('._. \\o/', $foo = new \stdClass());
179 $this->assertSame($foo, $sc->get('._. \\o/'), '->set() sets a service');
182 public function testSetWithNullResetTheService()
184 $sc = new Container();
185 $sc->set('foo', null);
186 $this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
189 public function testSetReplacesAlias()
191 $c = new ProjectServiceContainer();
193 $c->set('alias', $foo = new \stdClass());
194 $this->assertSame($foo, $c->get('alias'), '->set() replaces an existing alias');
199 * @expectedDeprecation The "bar" service is already initialized, unsetting it is deprecated since Symfony 3.3 and will fail in 4.0.
201 public function testSetWithNullOnInitializedPredefinedService()
203 $sc = new Container();
204 $sc->set('foo', new \stdClass());
205 $sc->set('foo', null);
206 $this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
208 $sc = new ProjectServiceContainer();
210 $sc->set('bar', null);
211 $this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
214 public function testSetWithNullOnUninitializedPredefinedService()
216 $sc = new Container();
217 $sc->set('foo', new \stdClass());
218 $sc->get('foo', null);
219 $sc->set('foo', null);
220 $this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
222 $sc = new ProjectServiceContainer();
223 $sc->set('bar', null);
224 $this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
227 public function testGet()
229 $sc = new ProjectServiceContainer();
230 $sc->set('foo', $foo = new \stdClass());
231 $this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id');
232 $this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
233 $this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
234 $this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
238 $this->fail('->get() throws a \InvalidArgumentException exception if the service is empty');
239 } catch (\Exception $e) {
240 $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty');
242 $this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service is empty');
247 * @expectedDeprecation Service identifiers will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since Symfony 3.3.
249 public function testGetInsensitivity()
251 $sc = new ProjectServiceContainer();
252 $sc->set('foo', $foo = new \stdClass());
253 $this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
258 * @expectedDeprecation Service identifiers will be made case sensitive in Symfony 4.0. Using "foo" instead of "Foo" is deprecated since Symfony 3.3.
260 public function testNormalizeIdKeepsCase()
262 $sc = new ProjectServiceContainer();
263 $sc->normalizeId('Foo', true);
264 $this->assertSame('Foo', $sc->normalizeId('foo'));
269 * @expectedDeprecation Service identifiers will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since Symfony 3.3.
270 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
271 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
272 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
273 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
275 public function testLegacyGet()
277 $sc = new LegacyProjectServiceContainer();
278 $sc->set('foo', $foo = new \stdClass());
280 $this->assertSame($foo, $sc->get('foo'), '->get() returns the service for the given id');
281 $this->assertSame($foo, $sc->get('Foo'), '->get() returns the service for the given id, and converts id to lowercase');
282 $this->assertSame($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id');
283 $this->assertSame($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined');
284 $this->assertSame($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');
285 $this->assertSame($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined');
287 $sc->set('bar', $bar = new \stdClass());
288 $this->assertSame($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()');
292 $this->fail('->get() throws a \InvalidArgumentException exception if the service is empty');
293 } catch (\Exception $e) {
294 $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty');
296 $this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service is empty');
299 public function testGetThrowServiceNotFoundException()
301 $sc = new ProjectServiceContainer();
302 $sc->set('foo', $foo = new \stdClass());
303 $sc->set('baz', $foo = new \stdClass());
307 $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
308 } catch (\Exception $e) {
309 $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
310 $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');
315 $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
316 } catch (\Exception $e) {
317 $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
318 $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');
322 public function testGetCircularReference()
324 $sc = new ProjectServiceContainer();
326 $sc->get('circular');
327 $this->fail('->get() throws a ServiceCircularReferenceException if it contains circular reference');
328 } catch (\Exception $e) {
329 $this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException', $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
330 $this->assertStringStartsWith('Circular reference detected for service "circular"', $e->getMessage(), '->get() throws a \LogicException if it contains circular reference');
335 * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
336 * @expectedExceptionMessage The "request" service is synthetic, it needs to be set at boot time before it can be used.
338 public function testGetSyntheticServiceThrows()
340 require_once __DIR__.'/Fixtures/php/services9_compiled.php';
342 $container = new \ProjectServiceContainer();
343 $container->get('request');
347 * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
348 * @expectedExceptionMessage The "inlined" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
350 public function testGetRemovedServiceThrows()
352 require_once __DIR__.'/Fixtures/php/services9_compiled.php';
354 $container = new \ProjectServiceContainer();
355 $container->get('inlined');
358 public function testHas()
360 $sc = new ProjectServiceContainer();
361 $sc->set('foo', new \stdClass());
362 $this->assertFalse($sc->has('foo1'), '->has() returns false if the service does not exist');
363 $this->assertTrue($sc->has('foo'), '->has() returns true if the service exists');
364 $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined');
365 $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined');
366 $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined');
371 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
372 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
373 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
374 * @expectedDeprecation Generating a dumped container without populating the method map is deprecated since Symfony 3.2 and will be unsupported in 4.0. Update your dumper to generate the method map.
376 public function testLegacyHas()
378 $sc = new LegacyProjectServiceContainer();
379 $sc->set('foo', new \stdClass());
381 $this->assertFalse($sc->has('foo1'), '->has() returns false if the service does not exist');
382 $this->assertTrue($sc->has('foo'), '->has() returns true if the service exists');
383 $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined');
384 $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined');
385 $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined');
386 $this->assertTrue($sc->has('foo\\baz'), '->has() returns true if a get*Method() is defined');
389 public function testInitialized()
391 $sc = new ProjectServiceContainer();
392 $sc->set('foo', new \stdClass());
393 $this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
394 $this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded');
395 $this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
396 $this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
399 $this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
404 * @expectedDeprecation Checking for the initialization of the "internal" private service is deprecated since Symfony 3.4 and won't be supported anymore in Symfony 4.0.
406 public function testInitializedWithPrivateService()
408 $sc = new ProjectServiceContainer();
409 $sc->get('internal_dependency');
410 $this->assertTrue($sc->initialized('internal'));
413 public function testReset()
415 $c = new Container();
416 $c->set('bar', new \stdClass());
420 $this->assertNull($c->get('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE));
424 * @expectedException \Exception
425 * @expectedExceptionMessage Something went terribly wrong!
427 public function testGetThrowsException()
429 $c = new ProjectServiceContainer();
432 $c->get('throw_exception');
433 } catch (\Exception $e) {
437 // Retry, to make sure that get*Service() will be called.
438 $c->get('throw_exception');
441 public function testGetThrowsExceptionOnServiceConfiguration()
443 $c = new ProjectServiceContainer();
446 $c->get('throws_exception_on_service_configuration');
447 } catch (\Exception $e) {
451 $this->assertFalse($c->initialized('throws_exception_on_service_configuration'));
453 // Retry, to make sure that get*Service() will be called.
455 $c->get('throws_exception_on_service_configuration');
456 } catch (\Exception $e) {
459 $this->assertFalse($c->initialized('throws_exception_on_service_configuration'));
462 protected function getField($obj, $field)
464 $reflection = new \ReflectionProperty($obj, $field);
465 $reflection->setAccessible(true);
467 return $reflection->getValue($obj);
470 public function testAlias()
472 $c = new ProjectServiceContainer();
474 $this->assertTrue($c->has('alias'));
475 $this->assertSame($c->get('alias'), $c->get('bar'));
478 public function testThatCloningIsNotSupported()
480 $class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container');
481 $clone = $class->getMethod('__clone');
482 $this->assertFalse($class->isCloneable());
483 $this->assertTrue($clone->isPrivate());
488 * @expectedDeprecation The "internal" service is private, unsetting it is deprecated since Symfony 3.2 and will fail in 4.0.
490 public function testUnsetInternalPrivateServiceIsDeprecated()
492 $c = new ProjectServiceContainer();
493 $c->set('internal', null);
498 * @expectedDeprecation The "internal" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0.
500 public function testChangeInternalPrivateServiceIsDeprecated()
502 $c = new ProjectServiceContainer();
503 $c->set('internal', $internal = new \stdClass());
504 $this->assertSame($c->get('internal'), $internal);
509 * @expectedDeprecation The "internal" service is private, checking for its existence is deprecated since Symfony 3.2 and will fail in 4.0.
511 public function testCheckExistenceOfAnInternalPrivateServiceIsDeprecated()
513 $c = new ProjectServiceContainer();
514 $c->get('internal_dependency');
515 $this->assertTrue($c->has('internal'));
520 * @expectedDeprecation The "internal" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
522 public function testRequestAnInternalSharedPrivateServiceIsDeprecated()
524 $c = new ProjectServiceContainer();
525 $c->get('internal_dependency');
531 * @expectedDeprecation The "bar" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0.
533 public function testReplacingAPreDefinedServiceIsDeprecated()
535 $c = new ProjectServiceContainer();
536 $c->set('bar', new \stdClass());
537 $c->set('bar', $bar = new \stdClass());
539 $this->assertSame($bar, $c->get('bar'), '->set() replaces a pre-defined service');
544 * @expectedDeprecation The "synthetic" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0.
546 public function testSetWithPrivateSyntheticServiceThrowsDeprecation()
548 $c = new ProjectServiceContainer();
549 $c->set('synthetic', new \stdClass());
553 class ProjectServiceContainer extends Container
560 protected $methodMap = array(
561 'internal' => 'getInternalService',
562 'bar' => 'getBarService',
563 'foo_bar' => 'getFooBarService',
564 'foo.baz' => 'getFoo_BazService',
565 'circular' => 'getCircularService',
566 'throw_exception' => 'getThrowExceptionService',
567 'throws_exception_on_service_configuration' => 'getThrowsExceptionOnServiceConfigurationService',
568 'internal_dependency' => 'getInternalDependencyService',
571 public function __construct()
573 parent::__construct();
575 $this->__bar = new \stdClass();
576 $this->__foo_bar = new \stdClass();
577 $this->__foo_baz = new \stdClass();
578 $this->__internal = new \stdClass();
579 $this->privates = array(
583 $this->aliases = array('alias' => 'bar');
584 $this->syntheticIds['synthetic'] = true;
587 protected function getInternalService()
589 return $this->services['internal'] = $this->__internal;
592 protected function getBarService()
594 return $this->services['bar'] = $this->__bar;
597 protected function getFooBarService()
599 return $this->__foo_bar;
602 protected function getFoo_BazService()
604 return $this->__foo_baz;
607 protected function getCircularService()
609 return $this->get('circular');
612 protected function getThrowExceptionService()
614 throw new \Exception('Something went terribly wrong!');
617 protected function getThrowsExceptionOnServiceConfigurationService()
619 $this->services['throws_exception_on_service_configuration'] = $instance = new \stdClass();
621 throw new \Exception('Something was terribly wrong while trying to configure the service!');
624 protected function getInternalDependencyService()
626 $this->services['internal_dependency'] = $instance = new \stdClass();
628 $instance->internal = isset($this->services['internal']) ? $this->services['internal'] : $this->getInternalService();
634 class LegacyProjectServiceContainer extends Container
641 public function __construct()
643 parent::__construct();
645 $this->__bar = new \stdClass();
646 $this->__foo_bar = new \stdClass();
647 $this->__foo_baz = new \stdClass();
648 $this->__internal = new \stdClass();
649 $this->privates = array('internal' => true);
650 $this->aliases = array('alias' => 'bar');
653 protected function getInternalService()
655 return $this->__internal;
658 protected function getBarService()
663 protected function getFooBarService()
665 return $this->__foo_bar;
668 protected function getFoo_BazService()
670 return $this->__foo_baz;
673 protected function getCircularService()
675 return $this->get('circular');
678 protected function getThrowExceptionService()
680 throw new \Exception('Something went terribly wrong!');
683 protected function getThrowsExceptionOnServiceConfigurationService()
685 $this->services['throws_exception_on_service_configuration'] = $instance = new \stdClass();
687 throw new \Exception('Something was terribly wrong while trying to configure the service!');