You are here

public function ContainerTest::testGetServiceIds in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testGetServiceIds()
  2. 8 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetServiceIds()
Same name and namespace in other branches
  1. 8.0 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 701
Contains \Drupal\Tests\Component\DependencyInjection\ContainerTest.

Class

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

Namespace

Drupal\Tests\Component\DependencyInjection

Code

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.');
}