From 68f489ecbb19402843ea31ecc55021c1c7c3f786 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 10 Apr 2014 03:10:51 +0200 Subject: [PATCH] DDC-3078 - cache configuration tests for the newly introduced API for cache instantiators --- .../Tests/ORM/Cache/CacheConfigTest.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index fff090330..2c599b5bb 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -7,6 +7,8 @@ use Doctrine\ORM\Cache\CacheConfiguration; /** * @group DDC-2183 + * + * @covers \Doctrine\ORM\Cache\CacheConfiguration */ class CacheConfigTest extends DoctrineTestCase { @@ -15,6 +17,9 @@ class CacheConfigTest extends DoctrineTestCase */ private $config; + /** + * {@inheritDoc} + */ protected function setUp() { parent::setUp(); @@ -34,6 +39,40 @@ class CacheConfigTest extends DoctrineTestCase $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();