public function ContainerTest::testLeaveScopeNotActive

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php, line 330

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testLeaveScopeNotActive() {
  $container = new Container();
  $container
    ->addScope(new Scope('foo'));
  try {
    $container
      ->leaveScope('foo');
    $this
      ->fail('->leaveScope() throws a \\LogicException if the scope is not active yet');
  } catch (\Exception $e) {
    $this
      ->assertInstanceOf('\\LogicException', $e, '->leaveScope() throws a \\LogicException if the scope is not active yet');
    $this
      ->assertEquals('The scope "foo" is not active.', $e
      ->getMessage(), '->leaveScope() throws a \\LogicException if the scope is not active yet');
  }
  try {
    $container
      ->leaveScope('bar');
    $this
      ->fail('->leaveScope() throws a \\LogicException if the scope does not exist');
  } catch (\Exception $e) {
    $this
      ->assertInstanceOf('\\LogicException', $e, '->leaveScope() throws a \\LogicException if the scope does not exist');
    $this
      ->assertEquals('The scope "bar" is not active.', $e
      ->getMessage(), '->leaveScope() throws a \\LogicException if the scope does not exist');
  }
}