mirror of
https://github.com/friendica/friendica
synced 2025-02-22 11:58:14 +00:00
Clean private static properties of LoggerManager via tearDown method
This commit is contained in:
parent
39088ab003
commit
f9b7b6a413
1 changed files with 17 additions and 24 deletions
|
@ -21,6 +21,23 @@ use Psr\Log\NullLogger;
|
||||||
|
|
||||||
class LoggerManagerTest extends TestCase
|
class LoggerManagerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Clean the private static properties
|
||||||
|
*
|
||||||
|
* @see LoggerManager::$logger
|
||||||
|
* @see LoggerManager::$logChannel
|
||||||
|
*/
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
||||||
|
$reflectionProperty->setAccessible(true);
|
||||||
|
$reflectionProperty->setValue(null, null);
|
||||||
|
|
||||||
|
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logChannel');
|
||||||
|
$reflectionProperty->setAccessible(true);
|
||||||
|
$reflectionProperty->setValue(null, LogChannel::DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetLoggerReturnsPsrLogger(): void
|
public function testGetLoggerReturnsPsrLogger(): void
|
||||||
{
|
{
|
||||||
$factory = new LoggerManager(
|
$factory = new LoggerManager(
|
||||||
|
@ -29,10 +46,6 @@ class LoggerManagerTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(LoggerInterface::class, $factory->getLogger());
|
$this->assertInstanceOf(LoggerInterface::class, $factory->getLogger());
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLoggerReturnsSameObject(): void
|
public function testGetLoggerReturnsSameObject(): void
|
||||||
|
@ -43,10 +56,6 @@ class LoggerManagerTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame($factory->getLogger(), $factory->getLogger());
|
$this->assertSame($factory->getLogger(), $factory->getLogger());
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLoggerWithDebugDisabledReturnsNullLogger(): void
|
public function testGetLoggerWithDebugDisabledReturnsNullLogger(): void
|
||||||
|
@ -62,10 +71,6 @@ class LoggerManagerTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(NullLogger::class, $factory->getLogger());
|
$this->assertInstanceOf(NullLogger::class, $factory->getLogger());
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLoggerWithProfilerEnabledReturnsProfilerLogger(): void
|
public function testGetLoggerWithProfilerEnabledReturnsProfilerLogger(): void
|
||||||
|
@ -82,10 +87,6 @@ class LoggerManagerTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(ProfilerLogger::class, $factory->getLogger());
|
$this->assertInstanceOf(ProfilerLogger::class, $factory->getLogger());
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeLogChannelReturnsDifferentLogger(): void
|
public function testChangeLogChannelReturnsDifferentLogger(): void
|
||||||
|
@ -106,10 +107,6 @@ class LoggerManagerTest extends TestCase
|
||||||
$factory->changeLogChannel(LogChannel::CONSOLE);
|
$factory->changeLogChannel(LogChannel::CONSOLE);
|
||||||
|
|
||||||
$this->assertNotSame($logger1, $factory->getLogger());
|
$this->assertNotSame($logger1, $factory->getLogger());
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeLogChannelToWorkerReturnsWorkerLogger(): void
|
public function testChangeLogChannelToWorkerReturnsWorkerLogger(): void
|
||||||
|
@ -128,9 +125,5 @@ class LoggerManagerTest extends TestCase
|
||||||
$factory->changeLogChannel(LogChannel::WORKER);
|
$factory->changeLogChannel(LogChannel::WORKER);
|
||||||
|
|
||||||
$this->assertInstanceOf(WorkerLogger::class, $factory->getLogger());
|
$this->assertInstanceOf(WorkerLogger::class, $factory->getLogger());
|
||||||
|
|
||||||
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
|
|
||||||
$reflectionProperty->setAccessible(true);
|
|
||||||
$reflectionProperty->setValue(null, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue