PsrCacheAdapterTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Metadata\Tests\Cache;
  3. use Metadata\ClassMetadata;
  4. use Metadata\Cache\PsrCacheAdapter;
  5. use Symfony\Component\Cache\Adapter\ArrayAdapter;
  6. /**
  7. * @requires PHP 5.5
  8. */
  9. class PsrCacheAdapterTest extends \PHPUnit_Framework_TestCase
  10. {
  11. public function setUp()
  12. {
  13. if (!class_exists('Symfony\Component\Cache\CacheItem')) {
  14. $this->markTestSkipped('symfony/cache is not installed.');
  15. }
  16. }
  17. public function testLoadEvictPutClassMetadataFromInCache()
  18. {
  19. $cache = new PsrCacheAdapter('metadata-test', new ArrayAdapter());
  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. }