94 lines
2.6 KiB
PHP
94 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*
|
|
* https://www.d3data.de
|
|
*
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
* @link https://www.oxidmodule.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace D3\LoggerFactory\tests;
|
|
|
|
use D3\LoggerFactory\LoggerBuilder;
|
|
use D3\LoggerFactory\LoggerFactory;
|
|
use D3\LoggerFactory\Options;
|
|
use D3\LoggerFactory\Options\FileLoggerHandlerOption;
|
|
use D3\LoggerFactory\Options\MailLoggerHandlerOption;
|
|
use D3\LoggerFactory\Options\OtherLoggerHandlerOption;
|
|
use D3\LoggerFactory\Options\OxidLoggerHandlerOption;
|
|
use D3\LoggerFactory\Options\SensitiveFilterProcessorOption;
|
|
use D3\LoggerFactory\Options\UidProcessorOption;
|
|
use D3\LoggerFactory\tests\Helpers\UnknownOption;
|
|
use Monolog\Handler\FirePHPHandler;
|
|
use Monolog\Logger;
|
|
use OxidEsales\Eshop\Core\Registry;
|
|
use ReflectionException;
|
|
use RuntimeException;
|
|
|
|
/**
|
|
* @coversNothing
|
|
*/
|
|
class LoggerBuilderTest extends AbstractTestCase
|
|
{
|
|
/**
|
|
* @test
|
|
* @throws ReflectionException
|
|
* @covers \D3\LoggerFactory\LoggerBuilder::build
|
|
*/
|
|
public function testBuild(): void
|
|
{
|
|
$loggerMock = $this->getMockBuilder(Logger::class)
|
|
->disableOriginalConstructor()
|
|
->onlyMethods(['pushProcessor', 'pushHandler'])
|
|
->getMock();
|
|
$loggerMock->expects($this->once())->method('pushProcessor');
|
|
$loggerMock->expects($this->once())->method('pushHandler');
|
|
|
|
$sut = $this->getMockBuilder(LoggerBuilder::class)
|
|
->onlyMethods(['getLogger'])
|
|
->getMock();
|
|
$sut->method('getLogger')->willReturn($loggerMock);
|
|
|
|
$options = new Options();
|
|
$options->add(new FileLoggerHandlerOption('file/path.log', Logger::INFO, 5));
|
|
$options->add(new UidProcessorOption());
|
|
$options->add(new UnknownOption());
|
|
|
|
$this->assertInstanceOf(
|
|
Logger::class,
|
|
$this->callMethod(
|
|
$sut,
|
|
'build',
|
|
['nameFixture', $options]
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
* @throws ReflectionException
|
|
* @covers \D3\LoggerFactory\LoggerBuilder::getLogger
|
|
*/
|
|
public function testGetLogger(): void
|
|
{
|
|
$sut = new LoggerBuilder();
|
|
|
|
$this->assertInstanceOf(
|
|
Logger::class,
|
|
$this->callMethod(
|
|
$sut,
|
|
'getLogger',
|
|
['nameFixture']
|
|
)
|
|
);
|
|
}
|
|
}
|