|
18 | 18 | use CodeIgniter\Exceptions\RuntimeException; |
19 | 19 | use CodeIgniter\I18n\Time; |
20 | 20 | use CodeIgniter\Log\Exceptions\LogException; |
| 21 | +use CodeIgniter\Log\Handlers\BaseHandler; |
21 | 22 | use CodeIgniter\Test\CIUnitTestCase; |
22 | 23 | use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; |
23 | 24 | use PHPUnit\Framework\Attributes\Group; |
@@ -108,6 +109,39 @@ public function testLogDoesnotLogUnhandledLevels(): void |
108 | 109 | $this->assertCount(0, $logs); |
109 | 110 | } |
110 | 111 |
|
| 112 | + public function testLogRunsRemainingHandlersWhenAnEarlierHandlerReturnsFalse(): void |
| 113 | + { |
| 114 | + $config = new LoggerConfig(); |
| 115 | + |
| 116 | + $failingHandler = new class ([]) extends BaseHandler { |
| 117 | + public static int $timesCalled = 0; |
| 118 | + |
| 119 | + public function handle($level, $message): bool |
| 120 | + { |
| 121 | + self::$timesCalled++; |
| 122 | + |
| 123 | + return false; |
| 124 | + } |
| 125 | + }; |
| 126 | + |
| 127 | + $config->handlers = [ |
| 128 | + $failingHandler::class => [ |
| 129 | + 'handles' => ['debug'], |
| 130 | + ], |
| 131 | + TestHandler::class => [ |
| 132 | + 'handles' => ['debug'], |
| 133 | + 'path' => '', |
| 134 | + ], |
| 135 | + ]; |
| 136 | + |
| 137 | + $logger = new Logger($config); |
| 138 | + |
| 139 | + $logger->log('debug', 'Test message'); |
| 140 | + |
| 141 | + $this->assertSame(1, $failingHandler::$timesCalled); |
| 142 | + $this->assertCount(1, TestHandler::getLogs()); |
| 143 | + } |
| 144 | + |
111 | 145 | public function testLogInterpolatesMessage(): void |
112 | 146 | { |
113 | 147 | $config = new LoggerConfig(); |
|
0 commit comments