function ReverseContainerTest::testGetId

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/DependencyInjection/ReverseContainerTest.php \Drupal\Tests\Component\DependencyInjection\ReverseContainerTest::testGetId()
  2. 10 core/tests/Drupal/Tests/Component/DependencyInjection/ReverseContainerTest.php \Drupal\Tests\Component\DependencyInjection\ReverseContainerTest::testGetId()

@covers ::getId

File

core/tests/Drupal/Tests/Component/DependencyInjection/ReverseContainerTest.php, line 26

Class

ReverseContainerTest
Tests the ReverseContainer class.

Namespace

Drupal\Tests\Component\DependencyInjection

Code

public function testGetId() : void {
    $container = new ContainerBuilder();
    $service = new \stdClass();
    $container->set('bar', $service);
    $reverse_container = new ReverseContainer($container);
    $this->assertSame('bar', $reverse_container->getId($service));
    $non_service = new \stdClass();
    $this->assertNull($reverse_container->getId($non_service));
    $this->assertSame('service_container', $reverse_container->getId($container));
}

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