function ContainerTest::testResolveServicesAndParametersForServiceReferencedViaServiceClosure

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testResolveServicesAndParametersForServiceReferencedViaServiceClosure()
  2. 10 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testResolveServicesAndParametersForServiceReferencedViaServiceClosure()

Tests that services wrapped in a closure work correctly.

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

File

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

Class

ContainerTest
Tests Drupal\Component\DependencyInjection\Container.

Namespace

Drupal\Tests\Component\DependencyInjection

Code

public function testResolveServicesAndParametersForServiceReferencedViaServiceClosure() : void {
  $service = $this->container
    ->get('service_within_service_closure');
  $other_service = $this->container
    ->get('other.service');
  $factory_function = $service->getSomeOtherService();
  $this->assertInstanceOf(\Closure::class, $factory_function);
  $this->assertEquals($other_service, call_user_func($factory_function));
}

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