ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
DefaultConfigLoggerFactoryTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Logging\Logger;
22
23use PHPUnit\Framework\TestCase;
24use ILIAS\Logging\Config\Basic\ConfigInterface as BasicConfigInterface;
27
28class DefaultConfigLoggerFactoryTest extends TestCase
29{
30 public function testGetLazy(): void
31 {
32 $expected_component_id = 'comp_id';
33 $expected_logger = $this->createStub(LoggerInterface::class);
34 $expected_level_fectcher = $this->createStub(LevelFetcherInterface::class);
35
36 $internal_factory = $this->createMock(LazyInternalFactoryInterface::class);
37 $internal_factory
38 ->expects($this->atLeastOnce())
39 ->method('getLazyGhost')
40 ->with($expected_component_id, $expected_level_fectcher)
41 ->willReturn($expected_logger);
42
43 $basic_config = $this->createMock(BasicConfigInterface::class);
44 $basic_config
45 ->expects($this->never())
46 ->method($this->anything());
47
48 $level_fetcher_factory = $this->createMock(LevelFetcherFactoryInterface::class);
49 $level_fetcher_factory
50 ->expects($this->atLeastOnce())
51 ->method('defaultLevelFetcher')
52 ->with($basic_config)
53 ->willReturn($expected_level_fectcher);
54
55 $factory = new DefaultConfigLoggerFactory($internal_factory, $basic_config, $level_fetcher_factory);
56 $actual_logger = $factory->getLazy($expected_component_id);
57
58 $this->assertSame(
59 $expected_logger,
60 $actual_logger,
61 'This should return the logger from LazyInternalFactory'
62 );
63 }
64}
This exists to encapsulate reading the level of a logger from the config, to be able to delay it as m...