public function ContainerTest::testEnterChildScopeRecursively in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testEnterChildScopeRecursively()
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ ContainerTest.php, line 410
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testEnterChildScopeRecursively() {
$container = new Container();
$container
->addScope(new Scope('foo'));
$container
->addScope(new Scope('bar', 'foo'));
$container
->enterScope('foo');
$container
->enterScope('bar');
$this
->assertTrue($container
->isScopeActive('bar'));
$this
->assertFalse($container
->has('a'));
$a = new \stdClass();
$container
->set('a', $a, 'bar');
$scoped = $this
->getField($container, 'scopedServices');
$this
->assertTrue(isset($scoped['bar']['a']));
$this
->assertSame($a, $scoped['bar']['a']);
$this
->assertTrue($container
->has('a'));
$container
->enterScope('bar');
$scoped = $this
->getField($container, 'scopedServices');
$this
->assertFalse(isset($scoped['a']));
$this
->assertTrue($container
->isScopeActive('foo'));
$this
->assertTrue($container
->isScopeActive('bar'));
$this
->assertFalse($container
->has('a'));
$container
->leaveScope('bar');
$this
->assertTrue($container
->isScopeActive('foo'));
$this
->assertTrue($container
->isScopeActive('bar'));
$this
->assertTrue($container
->has('a'));
}