2929use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
3030use Symfony \Component \DependencyInjection \Scope ;
3131use Symfony \Component \Config \Resource \FileResource ;
32+ use Symfony \Component \DependencyInjection \Tests \Fixtures \CustomDefinition ;
3233use Symfony \Component \ExpressionLanguage \Expression ;
3334
3435class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
@@ -257,6 +258,18 @@ public function testSetReplacesAlias()
257258 $ this ->assertSame ($ foo , $ builder ->get ('alias ' ), '->set() replaces an existing alias ' );
258259 }
259260
261+ public function testAliasesKeepInvalidBehavior ()
262+ {
263+ $ builder = new ContainerBuilder ();
264+
265+ $ aliased = new Definition ('stdClass ' );
266+ $ aliased ->addMethodCall ('setBar ' , array (new Reference ('bar ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE )));
267+ $ builder ->setDefinition ('aliased ' , $ aliased );
268+ $ builder ->setAlias ('alias ' , 'aliased ' );
269+
270+ $ this ->assertEquals (new \stdClass (), $ builder ->get ('alias ' ));
271+ }
272+
260273 public function testAddGetCompilerPass ()
261274 {
262275 $ builder = new ContainerBuilder ();
@@ -433,7 +446,7 @@ public function testResolveServices()
433446
434447 /**
435448 * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
436- * @expectedExceptionMessage Constructing service "foo" from a Symfony\Component\DependencyInjection\DefinitionDecorator is not supported at build time.
449+ * @expectedExceptionMessage Constructing service "foo" from a parent definition is not supported at build time.
437450 */
438451 public function testResolveServicesWithDecoratedDefinition ()
439452 {
@@ -445,6 +458,14 @@ public function testResolveServicesWithDecoratedDefinition()
445458 $ builder ->get ('foo ' );
446459 }
447460
461+ public function testResolveServicesWithCustomDefinitionClass ()
462+ {
463+ $ builder = new ContainerBuilder ();
464+ $ builder ->setDefinition ('foo ' , new CustomDefinition ('stdClass ' ));
465+
466+ $ this ->assertInstanceOf ('stdClass ' , $ builder ->get ('foo ' ));
467+ }
468+
448469 public function testMerge ()
449470 {
450471 $ container = new ContainerBuilder (new ParameterBag (array ('bar ' => 'foo ' )));
0 commit comments