You are here

public function ContainerTest::testGetForClassFromParameter in Zircon Profile 8.0

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

Tests that Container::get() works properly for class from parameters.

@covers ::get @covers ::createService

File

core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php, line 188
Contains \Drupal\Tests\Component\DependencyInjection\ContainerTest.

Class

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

Namespace

Drupal\Tests\Component\DependencyInjection

Code

public function testGetForClassFromParameter() {
  $container_definition = $this->containerDefinition;
  $container_definition['frozen'] = FALSE;
  $container = new $this->containerClass($container_definition);
  $other_service_class = $this->containerDefinition['parameters']['some_parameter_class'];
  $other_service = $container
    ->get('other.service_class_from_parameter');
  $this
    ->assertInstanceOf($other_service_class, $other_service, 'other.service_class_from_parameter has the right class.');
}