You are here

public function ContainerTest::testEnterScopeRecursivelyWithInactiveChildScopes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testEnterScopeRecursivelyWithInactiveChildScopes()

File

vendor/symfony/dependency-injection/Tests/ContainerTest.php, line 369

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

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'));
}