-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #994 from msmakouz/feature/monolog-format
[spiral/monolog-bridge] Adding the ability to configure the Monolog messages format
- Loading branch information
Showing
4 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\Tests\Monolog\Config; | ||
|
||
use Monolog\Handler\HandlerInterface; | ||
use Monolog\Logger; | ||
use Monolog\Processor\ProcessorInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use Spiral\Monolog\Config\MonologConfig; | ||
|
||
final class MonologConfigTest extends TestCase | ||
{ | ||
public function testGetDefault(): void | ||
{ | ||
$config = new MonologConfig(); | ||
$this->assertSame(MonologConfig::DEFAULT_CHANNEL, $config->getDefault()); | ||
|
||
$config = new MonologConfig(['default' => 'foo']); | ||
$this->assertSame('foo', $config->getDefault()); | ||
} | ||
|
||
public function testGetEventLevel(): void | ||
{ | ||
$config = new MonologConfig(); | ||
$this->assertSame(Logger::DEBUG, $config->getEventLevel()); | ||
|
||
$config = new MonologConfig(['globalLevel' => Logger::INFO]); | ||
$this->assertSame(Logger::INFO, $config->getEventLevel()); | ||
} | ||
|
||
public function testGetHandlers(): void | ||
{ | ||
$config = new MonologConfig(); | ||
$this->assertEmpty(\iterator_to_array($config->getHandlers('foo'))); | ||
|
||
$config = new MonologConfig([ | ||
'handlers' => [ | ||
'foo' => [ | ||
$this->createMock(HandlerInterface::class) | ||
] | ||
] | ||
]); | ||
$this->assertInstanceOf( | ||
HandlerInterface::class, | ||
\iterator_to_array($config->getHandlers('foo'))[0] | ||
); | ||
} | ||
|
||
public function testGetProcessors(): void | ||
{ | ||
$config = new MonologConfig(); | ||
$this->assertEmpty(\iterator_to_array($config->getProcessors('foo'))); | ||
|
||
$config = new MonologConfig([ | ||
'processors' => [ | ||
'foo' => [ | ||
$this->createMock(ProcessorInterface::class) | ||
] | ||
] | ||
]); | ||
$this->assertInstanceOf( | ||
ProcessorInterface::class, | ||
\iterator_to_array($config->getProcessors('foo'))[0] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters