You are here

public function ContainerTest::testGetForNonExistantServiceWithExceptionOnSecondCall in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetForNonExistantServiceWithExceptionOnSecondCall()

Tests multiple Container::get() calls with exception on the second time.

@covers ::get @covers ::createService @covers ::getAlternatives

@expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException

File

core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php, line 382
Contains \Drupal\Tests\Component\DependencyInjection\ContainerTest.

Class

ContainerTest
@coversDefaultClass \Drupal\Component\DependencyInjection\Container @group DependencyInjection

Namespace

Drupal\Tests\Component\DependencyInjection

Code

public function testGetForNonExistantServiceWithExceptionOnSecondCall() {
  $this
    ->assertNull($this->container
    ->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does nto throw exception.');
  $this->container
    ->get('service_not_exists');
}