function ContainerTest::testResolveServicesAndParametersForServiceReferencedViaServiceClosure

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

Tests that services wrapped in a closure work correctly.

@covers ::get @covers ::createService @covers ::resolveServicesAndParameters

File

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

Class

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

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.