1
0
mirror of synced 2025-02-03 13:59:27 +03:00
doctrine2/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php

86 lines
2.2 KiB
PHP
Raw Normal View History

2013-10-03 13:55:55 -04:00
<?php
namespace Doctrine\Tests\ORM\Cache;
use Doctrine\ORM\Cache\CacheConfiguration;
use Doctrine\ORM\Cache\CacheFactory;
use Doctrine\ORM\Cache\QueryCacheValidator;
use Doctrine\ORM\Cache\Logging\CacheLogger;
use Doctrine\ORM\Cache\TimestampQueryCacheValidator;
use Doctrine\ORM\Cache\TimestampRegion;
use Doctrine\Tests\DoctrineTestCase;
2013-10-03 13:55:55 -04:00
/**
* @group DDC-2183
*
* @covers \Doctrine\ORM\Cache\CacheConfiguration
2013-10-03 13:55:55 -04:00
*/
class CacheConfigTest extends DoctrineTestCase
{
/**
* @var \Doctrine\ORM\Cache\CacheConfiguration
*/
private $config;
/**
* {@inheritDoc}
*/
2013-10-03 13:55:55 -04:00
protected function setUp()
{
parent::setUp();
$this->config = new CacheConfiguration();
}
public function testSetGetRegionLifetime()
{
$config = $this->config->getRegionsConfiguration();
$config->setDefaultLifetime(111);
$this->assertEquals($config->getDefaultLifetime(), $config->getLifetime('foo_region'));
$config->setLifetime('foo_region', 222);
$this->assertEquals(222, $config->getLifetime('foo_region'));
}
public function testSetGetCacheLogger()
{
$logger = $this->createMock(CacheLogger::class);
2013-10-03 13:55:55 -04:00
$this->assertNull($this->config->getCacheLogger());
$this->config->setCacheLogger($logger);
$this->assertEquals($logger, $this->config->getCacheLogger());
}
public function testSetGetCacheFactory()
{
$factory = $this->createMock(CacheFactory::class);
2013-10-03 13:55:55 -04:00
$this->assertNull($this->config->getCacheFactory());
$this->config->setCacheFactory($factory);
$this->assertEquals($factory, $this->config->getCacheFactory());
}
public function testSetGetQueryValidator()
{
$factory = $this->createMock(CacheFactory::class);
$factory->method('getTimestampRegion')->willReturn($this->createMock(TimestampRegion::class));
$this->config->setCacheFactory($factory);
$validator = $this->createMock(QueryCacheValidator::class);
2013-10-03 13:55:55 -04:00
$this->assertInstanceOf(TimestampQueryCacheValidator::class, $this->config->getQueryValidator());
2013-10-03 13:55:55 -04:00
$this->config->setQueryValidator($validator);
$this->assertEquals($validator, $this->config->getQueryValidator());
}
}