10000 minor #10558 [DependencyInjection] added missing unit test (fabpot) · symfony/symfony@ea4b8bf · GitHub
[go: up one dir, main page]

Skip to content

Commit ea4b8bf

Browse files
committed
minor #10558 [DependencyInjection] added missing unit test (fabpot)
This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] added missing unit test | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Added a unit test to ensure that #10536 won't break BC. Commits ------- 47d1592 added missing unit test
2 parents 0380d14 + 47d1592 commit ea4b8bf

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\DependencyInjection\ContainerInterface;
2222
use Symfony\Component\DependencyInjection\Definition;
2323
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
24+
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
2425
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
2526
use Symfony\Component\DependencyInjection\Reference;
2627
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -151,6 +152,16 @@ public function testGetReturnsNullOnInactiveScope()
151152
$this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
152153
}
153154

155+
/**
156+
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::get
157+
*/
158+
public function testGetReturnsNullOnInactiveScopeWhenServiceIsCreatedByAMethod()
159+
{
160+
$builder = new ProjectContainer();
161+
162+
$this->assertNull($builder->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
163+
}
164+
154165
/**
155166
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
156167
*/
@@ -805,8 +816,16 @@ public function testLazyLoadedService()
805816
}
806817
}
807818

808-
$this->assertEquals(true, $classInList);
819+
$this->assertTrue($classInList);
809820
}
810821
}
811822

812823
class FooClass {}
824+
825+
class ProjectContainer extends ContainerBuilder
826+
{
827+
public function getFoobazService()
828+
{
829+
throw new InactiveScopeException('foo', 'request');
830+
}
831+
}

0 commit comments

Comments
 (0)
0