You are here

public function ContainerTest::test_resolveServicesAndParameters_optional in Service Container 7.2

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

Tests that services that are optional work correctly. @covers ::get() @covers ::resolveServicesAndParameters()

File

tests/src/DependencyInjection/ContainerTest.php, line 343
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_resolveServicesAndParameters_optional() {
  $service = $this->container
    ->get('service_with_optional_dependency');
  $this
    ->assertNull($service
    ->getSomeOtherService(), 'other service was NULL was expected.');
}