function ContainerTest::testGetForFactoryClass
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetForFactoryClass()
- 10 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetForFactoryClass()
- 11.x core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testGetForFactoryClass()
Tests that Container::get() for factories via class works (Symfony 2.7.0).
@covers ::get @covers ::createService
File
-
core/
tests/ Drupal/ Tests/ Component/ DependencyInjection/ ContainerTest.php, line 490
Class
- ContainerTest
- @coversDefaultClass \Drupal\Component\DependencyInjection\Container @group DependencyInjection
Namespace
Drupal\Tests\Component\DependencyInjectionCode
public function testGetForFactoryClass() {
$service = $this->container
->get('service.provider');
$factory_service = $this->container
->get('factory_class');
$this->assertInstanceOf(get_class($service), $factory_service);
$this->assertEquals('bar', $factory_service->getSomeParameter(), 'Correct parameter was passed via the factory class instantiation.');
$this->assertEquals($this->container, $factory_service->getContainer(), 'Container was injected via setter injection.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.