function LoggerChannelFactoryTest::testDeprecatedGetContainer

@covers ::__get @group legacy

File

core/tests/Drupal/Tests/Core/Logger/LoggerChannelFactoryTest.php, line 89

Class

LoggerChannelFactoryTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Logger%21LoggerChannelFactory.php/class/LoggerChannelFactory/10" title="Defines a factory for logging channels." class="local">\Drupal\Core\Logger\LoggerChannelFactory</a> @group Logger

Namespace

Drupal\Tests\Core\Logger

Code

public function testDeprecatedGetContainer() : void {
    $factory = new LoggerChannelFactory($this->createMock(RequestStack::class), $this->createMock(AccountInterface::class));
    $container = $this->prophesize(ContainerInterface::class);
    $request_stack = $this->prophesize(RequestStack::class)
        ->reveal();
    $container->get('request_stack')
        ->willReturn($request_stack);
    \Drupal::setContainer($container->reveal());
    $this->expectDeprecation('Accessing the container property in Drupal\\Core\\Logger\\LoggerChannelFactory is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use dependency injection instead. See https://www.drupal.org/node/3416354');
    $this->assertSame($request_stack, $factory->container
        ->get('request_stack'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.