mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-07-02 14:25:40 +08:00
add console logger tests (#3)
This commit is contained in:
30
tests/TestCase.php
Normal file
30
tests/TestCase.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
|
||||
class TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected $logs = [];
|
||||
|
||||
protected function getLogger(): LoggerInterface
|
||||
{
|
||||
$logger = new ConsoleLogger(LogLevel::DEBUG);
|
||||
$logger::$format = '%body%';
|
||||
$logger->addLogCallback(function ($level, $output, $message, $context) {
|
||||
$this->logs[] = $output;
|
||||
return false;
|
||||
});
|
||||
return $logger;
|
||||
}
|
||||
|
||||
protected function getLogs(): array
|
||||
{
|
||||
return $this->logs;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user