You are here

public function ContainerTest::testEnterLeaveCurrentScope in Zircon Profile 8

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

File

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

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testEnterLeaveCurrentScope() {
  $container = new ProjectServiceContainer();
  $container
    ->addScope(new Scope('foo'));
  $container
    ->enterScope('foo');
  $scoped1 = $container
    ->get('scoped');
  $scopedFoo1 = $container
    ->get('scoped_foo');
  $container
    ->enterScope('foo');
  $scoped2 = $container
    ->get('scoped');
  $scoped3 = $container
    ->get('SCOPED');
  $scopedFoo2 = $container
    ->get('scoped_foo');
  $container
    ->leaveScope('foo');
  $scoped4 = $container
    ->get('scoped');
  $scopedFoo3 = $container
    ->get('scoped_foo');
  $this
    ->assertNotSame($scoped1, $scoped2);
  $this
    ->assertSame($scoped2, $scoped3);
  $this
    ->assertSame($scoped1, $scoped4);
  $this
    ->assertNotSame($scopedFoo1, $scopedFoo2);
  $this
    ->assertSame($scopedFoo1, $scopedFoo3);
}