Skip to content

Commit

Permalink
Remove redundant setAccessible methods (#5811)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia authored Jun 7, 2023
1 parent 80da6ca commit b6ad996
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/LoggerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
* @coversNothing
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Hyperf\Logger\LoggerFactory::class)]
/**
* @internal
* @coversNothing
*/
class LoggerFactoryTest extends TestCase
{
protected function tearDown(): void
Expand Down Expand Up @@ -64,7 +68,6 @@ public function testHandlerConfig()
$this->assertInstanceOf(\Hyperf\Logger\Logger::class, $logger);
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('handlers');
$handlersProperty->setAccessible(true);
$handlers = $handlersProperty->getValue($logger);
$this->assertCount(1, $handlers);
$this->assertInstanceOf(StreamHandler::class, current($handlers));
Expand All @@ -78,7 +81,6 @@ public function testHandlersConfig()
$this->assertInstanceOf(\Hyperf\Logger\Logger::class, $logger);
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('handlers');
$handlersProperty->setAccessible(true);
$handlers = $handlersProperty->getValue($logger);
$this->assertCount(2, $handlers);
$this->assertInstanceOf(StreamHandler::class, $handlers[0]);
Expand All @@ -93,7 +95,6 @@ public function testHandlerGroupNotWorks()
$this->assertInstanceOf(\Hyperf\Logger\Logger::class, $logger);
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('handlers');
$handlersProperty->setAccessible(true);
$handlers = $handlersProperty->getValue($logger);
$this->assertCount(1, $handlers);
$this->assertInstanceOf(StreamHandler::class, $handlers[0]);
Expand All @@ -102,7 +103,6 @@ public function testHandlerGroupNotWorks()
$this->assertInstanceOf(\Hyperf\Logger\Logger::class, $logger);
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('handlers');
$handlersProperty->setAccessible(true);
$handlers = $handlersProperty->getValue($logger);
$this->assertCount(2, $handlers);
$this->assertInstanceOf(StreamHandler::class, $handlers[0]);
Expand All @@ -116,7 +116,6 @@ public function testNotSetProcessor()
$logger = $factory->get('hyperf');
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('processors');
$handlersProperty->setAccessible(true);
$processors = $handlersProperty->getValue($logger);
$this->assertSame([], $processors);
}
Expand All @@ -128,7 +127,6 @@ public function testProcessor()
$logger = $factory->get('hyperf', 'processor-test');
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('processors');
$handlersProperty->setAccessible(true);
$processors = $handlersProperty->getValue($logger);
$this->assertSame(3, count($processors));
$this->assertInstanceOf(FooProcessor::class, $processors[0]);
Expand All @@ -150,7 +148,6 @@ public function testDefaultProcessor()
$logger = $factory->get('hyperf', 'default-processor');
$reflectionClass = new ReflectionClass($logger);
$handlersProperty = $reflectionClass->getProperty('processors');
$handlersProperty->setAccessible(true);
$processors = $handlersProperty->getValue($logger);
$this->assertSame(1, count($processors));
$this->assertInstanceOf(FooProcessor::class, $processors[0]);
Expand Down

0 comments on commit b6ad996

Please sign in to comment.