Skip to content

Commit

Permalink
DDC-3078 - cache configuration tests for the newly introduced API for…
Browse files Browse the repository at this point in the history
… cache instantiators
  • Loading branch information
Ocramius authored and fabios committed Apr 17, 2014
1 parent e5f79d1 commit 68f489e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* @group DDC-2183
*
* @covers \Doctrine\ORM\Cache\CacheConfiguration
*/
class CacheConfigTest extends DoctrineTestCase
{
Expand All @@ -15,6 +17,9 @@ class CacheConfigTest extends DoctrineTestCase
*/
private $config;

/**
* {@inheritDoc}
*/
protected function setUp()
{
parent::setUp();
Expand All @@ -34,6 +39,40 @@ public function testSetGetCacheClassName()
$this->config->setCacheClassName(__CLASS__);
}

/**
* @covers \Doctrine\ORM\Cache\CacheConfiguration::getCacheInstantiator
*/
public function testGetDefaultCacheIstantiator()
{
$entityManager = $this->getMock('Doctrine\ORM\EntityManagerInterface');
$config = $this->getMock('Doctrine\ORM\Configuration');

$entityManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($config));
$config
->expects($this->any())
->method('getSecondLevelCacheConfiguration')
->will($this->returnValue($this->config));

$defaultIstantiator = $this->config->getCacheInstantiator();

$this->assertInstanceOf('Doctrine\ORM\Cache\DefaultCache', $defaultIstantiator($entityManager));
}

/**
* @covers \Doctrine\ORM\Cache\CacheConfiguration::getCacheInstantiator
*/
public function testSetGetCacheIstantiator()
{
$istantiator = function () {};

$this->config->setCacheInstantiator($istantiator);
$this->assertSame($istantiator, $this->config->getCacheInstantiator());

$this->setExpectedException('Doctrine\ORM\ORMException');

$this->config->setCacheInstantiator(null);
}

public function testSetGetRegionLifetime()
{
$config = $this->config->getRegionsConfiguration();
Expand Down

0 comments on commit 68f489e

Please sign in to comment.