From 47d1592b56048c3878cd5111c738f0ee07a093b1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 27 Mar 2014 15:19:35 +0100 Subject: [PATCH] added missing unit test --- .../Tests/ContainerBuilderTest.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index a669305019..5890ed84c1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -151,6 +152,16 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE)); } + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::get + */ + public function testGetReturnsNullOnInactiveScopeWhenServiceIsCreatedByAMethod() + { + $builder = new ProjectContainer(); + + $this->assertNull($builder->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds */ @@ -805,8 +816,16 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase } } - $this->assertEquals(true, $classInList); + $this->assertTrue($classInList); } } class FooClass {} + +class ProjectContainer extends ContainerBuilder +{ + public function getFoobazService() + { + throw new InactiveScopeException('foo', 'request'); + } +}