1
0
Fork 0
mirror of https://github.com/shlinkio/shlink.git synced 2025-03-29 13:03:52 +03:00
shlink/module/Common/test/Logger/LoggerFactoryTest.php
2019-08-07 13:50:38 +02:00

48 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Logger;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Common\Logger\LoggerFactory;
use Zend\ServiceManager\ServiceManager;
class LoggerFactoryTest extends TestCase
{
/** @var LoggerFactory */
private $factory;
public function setUp(): void
{
$this->factory = new LoggerFactory();
}
/** @test */
public function serviceIsCreated()
{
/** @var Logger $instance */
$instance = $this->factory->__invoke(new ServiceManager(), '');
$this->assertInstanceOf(LoggerInterface::class, $instance);
$this->assertEquals('Logger', $instance->getName());
}
/** @test */
public function nameIsSetFromOptions()
{
/** @var Logger $instance */
$instance = $this->factory->__invoke(new ServiceManager(), '', ['logger_name' => 'Foo']);
$this->assertInstanceOf(LoggerInterface::class, $instance);
$this->assertEquals('Foo', $instance->getName());
}
/** @test */
public function serviceNameOverwritesOptionsLoggerName()
{
/** @var Logger $instance */
$instance = $this->factory->__invoke(new ServiceManager(), 'Logger_Shlink', ['logger_name' => 'Foo']);
$this->assertInstanceOf(LoggerInterface::class, $instance);
$this->assertEquals('Shlink', $instance->getName());
}
}