function ContainerTest::testResolveServicesAndParametersForOptionalServiceDependencies

Tests that services that are optional work correctly.

@legacy-covers ::get @legacy-covers ::createService @legacy-covers ::resolveServicesAndParameters

File

core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php, line 573

Class

ContainerTest
Tests Drupal\Component\DependencyInjection\Container.

Namespace

Drupal\Tests\Component\DependencyInjection

Code

public function testResolveServicesAndParametersForOptionalServiceDependencies() : void {
  $service = $this->container
    ->get('service_with_optional_dependency');
  $this->assertNull($service->getSomeOtherService(), 'other service was NULL was expected.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.