shlink/module/Common/test/Factory/CacheFactoryTest.php

47 lines
1 KiB
PHP
Raw Normal View History

2016-05-01 18:54:56 +03:00
<?php
2016-07-19 18:38:41 +03:00
namespace ShlinkioTest\Shlink\Common\Factory;
2016-05-01 18:54:56 +03:00
use Doctrine\Common\Cache\ApcuCache;
use Doctrine\Common\Cache\ArrayCache;
use PHPUnit_Framework_TestCase as TestCase;
2016-07-19 18:38:41 +03:00
use Shlinkio\Shlink\Common\Factory\CacheFactory;
2016-05-01 18:54:56 +03:00
use Zend\ServiceManager\ServiceManager;
class CacheFactoryTest extends TestCase
{
/**
* @var CacheFactory
*/
protected $factory;
public function setUp()
{
$this->factory = new CacheFactory();
}
public static function tearDownAfterClass()
{
putenv('APP_ENV');
}
/**
* @test
*/
public function productionReturnsApcAdapter()
{
putenv('APP_ENV=pro');
$instance = $this->factory->__invoke(new ServiceManager(), '');
$this->assertInstanceOf(ApcuCache::class, $instance);
}
/**
* @test
*/
public function developmentReturnsArrayAdapter()
{
putenv('APP_ENV=dev');
$instance = $this->factory->__invoke(new ServiceManager(), '');
$this->assertInstanceOf(ArrayCache::class, $instance);
}
}