2727use Symfony \Component \DependencyInjection \Reference ;
2828use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
2929use Symfony \Component \Config \Resource \FileResource ;
30+ use Symfony \Component \DependencyInjection \Tests \Fixtures \CustomDefinition ;
3031use Symfony \Component \ExpressionLanguage \Expression ;
3132
3233class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
@@ -236,6 +237,18 @@ public function testSetReplacesAlias()
236237 $ this ->assertSame ($ foo , $ builder ->get ('alias ' ), '->set() replaces an existing alias ' );
237238 }
238239
240+ public function testAliasesKeepInvalidBehavior ()
241+ {
242+ $ builder = new ContainerBuilder ();
243+
244+ $ aliased = new Definition ('stdClass ' );
245+ $ aliased ->addMethodCall ('setBar ' , array (new Reference ('bar ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE )));
246+ $ builder ->setDefinition ('aliased ' , $ aliased );
247+ $ builder ->setAlias ('alias ' , 'aliased ' );
248+
249+ $ this ->assertEquals (new \stdClass (), $ builder ->get ('alias ' ));
250+ }
251+
239252 public function testAddGetCompilerPass ()
240253 {
241254 $ builder = new ContainerBuilder ();
@@ -383,7 +396,7 @@ public function testResolveServices()
383396
384397 /**
385398 * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
386- * @expectedExceptionMessage Constructing service "foo" from a Symfony\Component\DependencyInjection\DefinitionDecorator is not supported at build time.
399+ * @expectedExceptionMessage Constructing service "foo" from a parent definition is not supported at build time.
387400 */
388401 public function testResolveServicesWithDecoratedDefinition ()
389402 {
@@ -395,6 +408,14 @@ public function testResolveServicesWithDecoratedDefinition()
395408 $ builder ->get ('foo ' );
396409 }
397410
411+ public function testResolveServicesWithCustomDefinitionClass ()
412+ {
413+ $ builder = new ContainerBuilder ();
414+ $ builder ->setDefinition ('foo ' , new CustomDefinition ('stdClass ' ));
415+
416+ $ this ->assertInstanceOf ('stdClass ' , $ builder ->get ('foo ' ));
417+ }
418+
398419 public function testMerge ()
399420 {
400421 $ container = new ContainerBuilder (new ParameterBag (array ('bar ' => 'foo ' )));
0 commit comments