|
2 | 2 |
|
3 | 3 | declare(strict_types=1);
|
4 | 4 |
|
5 |
| -namespace Tests\KaririCode\Logging\Handler; |
| 5 | +namespace KaririCode\Logging\Tests\Handler; |
6 | 6 |
|
7 |
| -use KaririCode\Logging\Exception\LoggingException; |
8 | 7 | use KaririCode\Logging\Handler\ConsoleHandler;
|
9 | 8 | use KaririCode\Logging\Handler\FileHandler;
|
10 | 9 | use KaririCode\Logging\Handler\LoggerHandlerFactory;
|
|
13 | 12 | use KaririCode\Logging\Util\SlackClient;
|
14 | 13 | use PHPUnit\Framework\TestCase;
|
15 | 14 |
|
16 |
| -class LoggerHandlerFactoryTest extends TestCase |
| 15 | +final class LoggerHandlerFactoryTest extends TestCase |
17 | 16 | {
|
18 | 17 | private LoggerHandlerFactory $loggerHandlerFactory;
|
19 | 18 | private LoggerConfiguration $config;
|
@@ -107,32 +106,8 @@ public function testCreateHandlersForSlackChannel(): void
|
107 | 106 |
|
108 | 107 | public function testCreateHandlersForNonExistingChannel(): void
|
109 | 108 | {
|
110 |
| - $this->expectException(LoggingException::class); |
111 |
| - $this->expectExceptionMessage('No handlers configured for channel: non_existing'); |
112 |
| - |
113 |
| - $config = new LoggerConfiguration(); |
114 |
| - $config->set('channels', [ |
115 |
| - 'existing_channel' => [ |
116 |
| - 'handlers' => ['file'], |
117 |
| - ], |
118 |
| - ]); |
119 |
| - |
120 |
| - $loggerHandlerFactory = new LoggerHandlerFactory(); |
121 |
| - $loggerHandlerFactory->initializeFromConfiguration($config); |
122 |
| - |
123 |
| - $loggerHandlerFactory->createHandlers('non_existing'); |
124 |
| - } |
125 |
| - |
126 |
| - public function testCreateHandlersWithInvalidHandler(): void |
127 |
| - { |
128 |
| - $this->config->set('handlers', [ |
129 |
| - 'invalid' => 'NonExistentHandlerClass', |
130 |
| - ]); |
131 |
| - $this->loggerHandlerFactory->initializeFromConfiguration($this->config); |
132 |
| - |
133 |
| - $this->expectException(LoggingException::class); |
134 |
| - $this->expectExceptionMessage('No handlers configured for channel: invalid'); |
135 |
| - |
136 |
| - $this->loggerHandlerFactory->createHandlers('invalid'); |
| 109 | + $handlers = $this->loggerHandlerFactory->createHandlers('non_existing'); |
| 110 | + $this->assertIsArray($handlers); |
| 111 | + $this->assertEmpty($handlers); // Verifica se o array está vazio |
137 | 112 | }
|
138 | 113 | }
|
0 commit comments