setAccessible(true); $reflectionProperty->setValue(null, null); $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logChannel'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue(null, LogChannel::DEFAULT); } public function testGetLoggerReturnsPsrLogger(): void { $factory = new LoggerManager( $this->createStub(IManageConfigValues::class), $this->createStub(LoggerFactory::class) ); $this->assertInstanceOf(LoggerInterface::class, $factory->getLogger()); } public function testGetLoggerReturnsSameObject(): void { $factory = new LoggerManager( $this->createStub(IManageConfigValues::class), $this->createStub(LoggerFactory::class) ); $this->assertSame($factory->getLogger(), $factory->getLogger()); } public function testGetLoggerWithDebugDisabledReturnsNullLogger(): void { $config = $this->createStub(IManageConfigValues::class); $config->method('get')->willReturnMap([ ['system', 'debugging', null, false], ]); $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) ); $this->assertInstanceOf(NullLogger::class, $factory->getLogger()); } public function testGetLoggerWithProfilerEnabledReturnsProfilerLogger(): void { $config = $this->createStub(IManageConfigValues::class); $config->method('get')->willReturnMap([ ['system', 'debugging', null, false], ['system', 'profiling', null, true], ]); $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) ); $this->assertInstanceOf(ProfilerLogger::class, $factory->getLogger()); } public function testChangeLogChannelReturnsDifferentLogger(): void { $config = $this->createStub(IManageConfigValues::class); $config->method('get')->willReturnMap([ ['system', 'debugging', null, false], ['system', 'profiling', null, true], ]); $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) ); $logger1 = $factory->getLogger(); $factory->changeLogChannel(LogChannel::CONSOLE); $this->assertNotSame($logger1, $factory->getLogger()); } public function testChangeLogChannelToWorkerReturnsWorkerLogger(): void { $config = $this->createStub(IManageConfigValues::class); $config->method('get')->willReturnMap([ ['system', 'debugging', null, false], ['system', 'profiling', null, true], ]); $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) ); $factory->changeLogChannel(LogChannel::WORKER); $this->assertInstanceOf(WorkerLogger::class, $factory->getLogger()); } }