1<?php 2 3declare(strict_types=1); 4 5namespace Metadata\Tests\Cache; 6 7use Metadata\Cache\PsrCacheAdapter; 8use Metadata\ClassMetadata; 9use Metadata\Tests\Fixtures\TestObject; 10use PHPUnit\Framework\TestCase; 11use Symfony\Component\Cache\Adapter\ArrayAdapter; 12 13/** 14 * @requires PHP 5.5 15 */ 16class PsrCacheAdapterTest extends TestCase 17{ 18 public function setUp() 19 { 20 if (!class_exists('Symfony\Component\Cache\CacheItem')) { 21 $this->markTestSkipped('symfony/cache is not installed.'); 22 } 23 } 24 25 public function testLoadEvictPutClassMetadataFromInCache() 26 { 27 $cache = new PsrCacheAdapter('metadata-test', new ArrayAdapter()); 28 29 $this->assertNull($cache->load(TestObject::class)); 30 $cache->put($metadata = new ClassMetadata(TestObject::class)); 31 32 $this->assertEquals($metadata, $cache->load(TestObject::class)); 33 34 $cache->evict(TestObject::class); 35 $this->assertNull($cache->load(TestObject::class)); 36 } 37} 38