You are here

public function ContainerTest::test_get_notFoundMultipleWithExceptionOnSecondCall in Service Container 7

Same name and namespace in other branches
  1. 7.2 tests/src/DependencyInjection/ContainerTest.php \Drupal\Tests\service_container\DependencyInjection\ContainerTest::test_get_notFoundMultipleWithExceptionOnSecondCall()

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

@covers ::get()

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

File

tests/src/DependencyInjection/ContainerTest.php, line 276
Contains \Drupal\Tests\service_container\DependencyInjection\ContainerTest

Class

ContainerTest
@coversDefaultClass \Drupal\service_container\DependencyInjection\Container @group dic

Namespace

Drupal\Tests\service_container\DependencyInjection

Code

public function test_get_notFoundMultipleWithExceptionOnSecondCall() {
  $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');
}