mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-23 07:33:58 -06:00
Created LoggerFactoryTest
This commit is contained in:
parent
b7f3c332e4
commit
fff058f44b
@ -2,6 +2,7 @@
|
|||||||
use Acelaya\ZsmAnnotatedServices\Factory\V3\AnnotatedFactory;
|
use Acelaya\ZsmAnnotatedServices\Factory\V3\AnnotatedFactory;
|
||||||
use Doctrine\Common\Cache\Cache;
|
use Doctrine\Common\Cache\Cache;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Monolog\Logger;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Shlinkio\Shlink\Common\ErrorHandler;
|
use Shlinkio\Shlink\Common\ErrorHandler;
|
||||||
use Shlinkio\Shlink\Common\Factory\CacheFactory;
|
use Shlinkio\Shlink\Common\Factory\CacheFactory;
|
||||||
@ -38,6 +39,7 @@ return [
|
|||||||
'httpClient' => GuzzleHttp\Client::class,
|
'httpClient' => GuzzleHttp\Client::class,
|
||||||
'translator' => Translator::class,
|
'translator' => Translator::class,
|
||||||
'logger' => LoggerInterface::class,
|
'logger' => LoggerInterface::class,
|
||||||
|
Logger::class => LoggerInterface::class,
|
||||||
AnnotatedFactory::CACHE_SERVICE => Cache::class,
|
AnnotatedFactory::CACHE_SERVICE => Cache::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
54
module/Common/test/Factory/LoggerFactoryTest.php
Normal file
54
module/Common/test/Factory/LoggerFactoryTest.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
namespace ShlinkioTest\Shlink\Common\Factory;
|
||||||
|
|
||||||
|
use Monolog\Logger;
|
||||||
|
use PHPUnit_Framework_TestCase as TestCase;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Shlinkio\Shlink\Common\Factory\LoggerFactory;
|
||||||
|
use Zend\ServiceManager\ServiceManager;
|
||||||
|
|
||||||
|
class LoggerFactoryTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var LoggerFactory
|
||||||
|
*/
|
||||||
|
protected $factory;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user