function ContainerTest::testGetServiceIdMappings

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

@covers \Drupal\Component\DependencyInjection\ServiceIdHashTrait::getServiceIdMappings @covers \Drupal\Component\DependencyInjection\ServiceIdHashTrait::generateServiceIdHash

@group legacy

File

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

Class

ContainerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21DependencyInjection%21Container.php/class/Container/9" title="Provides a container optimized for Drupal&#039;s needs." class="local">\Drupal\Component\DependencyInjection\Container</a> @group DependencyInjection

Namespace

Drupal\Tests\Component\DependencyInjection

Code

public function testGetServiceIdMappings() {
    $this->expectDeprecation("Drupal\\Component\\DependencyInjection\\ServiceIdHashTrait::generateServiceIdHash() is deprecated in drupal:9.5.1 and is removed from drupal:11.0.0. Use the 'Drupal\\Component\\DependencyInjection\\ReverseContainer' service instead. See https://www.drupal.org/node/3327942");
    $this->expectDeprecation("Drupal\\Component\\DependencyInjection\\ServiceIdHashTrait::getServiceIdMappings() is deprecated in drupal:9.5.1 and is removed from drupal:11.0.0. Use the 'Drupal\\Component\\DependencyInjection\\ReverseContainer' service instead. See https://www.drupal.org/node/3327942");
    $this->assertEquals([], $this->container
        ->getServiceIdMappings());
    $s1 = $this->container
        ->get('other.service');
    $s2 = $this->container
        ->get('late.service');
    $this->assertEquals([
        $this->container
            ->generateServiceIdHash($s1) => 'other.service',
        $this->container
            ->generateServiceIdHash($s2) => 'late.service',
    ], $this->container
        ->getServiceIdMappings());
}

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