public function ContainerTest::testEnterScopeRecursivelyWithInactiveChildScopes 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::testEnterScopeRecursivelyWithInactiveChildScopes()
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ ContainerTest.php, line 369
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testEnterScopeRecursivelyWithInactiveChildScopes() {
$container = new Container();
$container
->addScope(new Scope('foo'));
$container
->addScope(new Scope('bar', 'foo'));
$this
->assertFalse($container
->isScopeActive('foo'));
$container
->enterScope('foo');
$this
->assertTrue($container
->isScopeActive('foo'));
$this
->assertFalse($container
->isScopeActive('bar'));
$this
->assertFalse($container
->has('a'));
$a = new \stdClass();
$container
->set('a', $a, 'foo');
$scoped = $this
->getField($container, 'scopedServices');
$this
->assertTrue(isset($scoped['foo']['a']));
$this
->assertSame($a, $scoped['foo']['a']);
$this
->assertTrue($container
->has('a'));
$container
->enterScope('foo');
$scoped = $this
->getField($container, 'scopedServices');
$this
->assertFalse(isset($scoped['a']));
$this
->assertTrue($container
->isScopeActive('foo'));
$this
->assertFalse($container
->isScopeActive('bar'));
$this
->assertFalse($container
->has('a'));
$container
->enterScope('bar');
$this
->assertTrue($container
->isScopeActive('bar'));
$container
->leaveScope('foo');
$this
->assertTrue($container
->isScopeActive('foo'));
$this
->assertFalse($container
->isScopeActive('bar'));
$this
->assertTrue($container
->has('a'));
}