function ContainerBuilderTest::testLegacySetDefinition
@covers ::setDefinition
@group legacy
File
-
core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ ContainerBuilderTest.php, line 69
Class
- ContainerBuilderTest
- @coversDefaultClass \Drupal\Core\DependencyInjection\ContainerBuilder @group DependencyInjection
Namespace
Drupal\Tests\Core\DependencyInjectionCode
public function testLegacySetDefinition() {
// Test a service with public set to default.
$container = new ContainerBuilder();
$definition = new Definition();
$this->expectDeprecation('Not marking service definitions as public is deprecated in drupal:9.2.0 and is required in drupal:10.0.0. Call $definition->setPublic(TRUE) before calling ::setDefinition(). See https://www.drupal.org/node/3194517');
$service = $container->setDefinition('foo', $definition);
$this->assertTrue($service->isPublic());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.