function ContainerTest::testGetServiceIds
Same name and namespace in other branches
- 8.9.x core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetServiceIds()
- 10 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetServiceIds()
- 11.x core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetServiceIds()
Tests that Container::getServiceIds() works properly.
@covers ::getServiceIds
File
-
core/
tests/ Drupal/ Tests/ Component/ DependencyInjection/ ContainerTest.php, line 665
Class
- ContainerTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21DependencyInjection%21Container.php/class/Container/9" title="Provides a container optimized for Drupal's needs." class="local">\Drupal\Component\DependencyInjection\Container</a> @group DependencyInjection
Namespace
Drupal\Tests\Component\DependencyInjectionCode
public function testGetServiceIds() {
$service_definition_keys = array_keys($this->containerDefinition['services']);
$this->assertEquals($service_definition_keys, $this->container
->getServiceIds(), 'Retrieved service IDs match definition.');
$mock_service = new MockService();
$this->container
->set('bar', $mock_service);
$this->container
->set('service.provider', $mock_service);
$service_definition_keys[] = 'bar';
$this->assertEquals($service_definition_keys, $this->container
->getServiceIds(), 'Retrieved service IDs match definition after setting new services.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.