DoctrineCacheAdapterTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Metadata\Tests\Cache;
  3. use Metadata\ClassMetadata;
  4. use Metadata\Cache\DoctrineCacheAdapter;
  5. use Doctrine\Common\Cache\ArrayCache;
  6. /**
  7. * @requires PHP 5.4
  8. */
  9. class DoctrineCacheAdapterTest extends \PHPUnit_Framework_TestCase
  10. {
  11. public function setUp()
  12. {
  13. if (!interface_exists('Doctrine\Common\Cache\Cache')) {
  14. $this->markTestSkipped('Doctrine\Common is not installed.');
  15. }
  16. }
  17. public function testLoadEvictPutClassMetadataFromInCache()
  18. {
  19. $cache = new DoctrineCacheAdapter('metadata-test', new ArrayCache());
  20. $this->assertNull($cache->loadClassMetadataFromCache($refl = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')));
  21. $cache->putClassMetadataInCache($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'));
  22. $this->assertEquals($metadata, $cache->loadClassMetadataFromCache($refl));
  23. $cache->evictClassMetadataFromCache($refl);
  24. $this->assertNull($cache->loadClassMetadataFromCache($refl));
  25. }
  26. }