From a3b2d4d66c364aa67836b528d9e80f4f480800a1 Mon Sep 17 00:00:00 2001 From: kenjis <kenji.uui@gmail.com> Date: Sun, 24 Sep 2023 18:01:37 +0900 Subject: [PATCH] test: update test code --- tests/system/Log/LoggerTest.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/system/Log/LoggerTest.php b/tests/system/Log/LoggerTest.php index 317ad9c14bf4..8087ff645845 100644 --- a/tests/system/Log/LoggerTest.php +++ b/tests/system/Log/LoggerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Exception; use Tests\Support\Log\Handlers\TestHandler; +use TypeError; /** * @internal @@ -48,14 +49,14 @@ public function testLogThrowsExceptionOnInvalidLevel(): void $logger->log('foo', ''); } - public function testLogReturnsFalseWhenLogNotHandled(): void + public function testLogAlwaysReturnsVoid(): void { $config = new LoggerConfig(); $config->threshold = 3; $logger = new Logger($config); - $this->assertFalse($logger->log('debug', '')); + $this->assertNull($logger->log('debug', '')); } public function testLogActuallyLogs(): void @@ -361,16 +362,12 @@ public function testLogLevels(): void public function testNonStringMessage(): void { + $this->expectException(TypeError::class); + $config = new LoggerConfig(); $logger = new Logger($config); - $expected = '[Tests\Support\Log\Handlers\TestHandler]'; $logger->log(5, $config); - - $logs = TestHandler::getLogs(); - - $this->assertCount(1, $logs); - $this->assertStringContainsString($expected, $logs[0]); } public function testDetermineFileNoStackTrace(): void