function LoggerChannelFactoryTest::testWithoutConstructor

@covers ::get @group legacy

File

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

Class

LoggerChannelFactoryTest
@coversDefaultClass \Drupal\Core\Logger\LoggerChannelFactory @group Logger

Namespace

Drupal\Tests\Core\Logger

Code

public function testWithoutConstructor() : void {
    $container = $this->prophesize(ContainerInterface::class);
    $container->get('request_stack')
        ->willReturn($this->prophesize(RequestStack::class)
        ->reveal());
    $container->get('current_user')
        ->willReturn($this->prophesize(AccountProxy::class)
        ->reveal());
    \Drupal::setContainer($container->reveal());
    $factory = new LoggerChannelWithoutConstructor();
    $this->expectDeprecation('Calling Drupal\\Core\\Logger\\LoggerChannelFactory::get without calling the constructor is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3416354');
    $this->assertSame($factory->get('test'), $factory->get('test'));
}

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