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