Skip to content

Commit

Permalink
fix for --prefer-lowest
Browse files Browse the repository at this point in the history
  • Loading branch information
gam6itko committed Mar 5, 2021
1 parent a75e708 commit 8a08ea2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/Cache/DoctrineCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Metadata\Cache;

use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\ClearableCache;
use Metadata\ClassMetadata;

/**
Expand Down Expand Up @@ -47,8 +46,8 @@ public function evict(string $class): void

public function clear(): bool
{
if ($this->cache instanceof ClearableCache) {
return $this->cache->deleteAll();
if (method_exists($this->cache, 'deleteAll')) { // or $this->cache instanceof ClearableCache
return call_user_func([$this->cache, 'deleteAll']);
}

return false;
Expand Down
6 changes: 4 additions & 2 deletions tests/Cache/PsrCacheAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ public function testClear(): void

$cacheAdapter->put(new ClassMetadata(A::class));
$cacheAdapter->put(new ClassMetadata(B::class));
self::assertCount(2, $pool->getValues());
self::assertTrue($pool->hasItem('metadata-testMetadata-Tests-Driver-Fixture-A-A'));
self::assertTrue($pool->hasItem('metadata-testMetadata-Tests-Driver-Fixture-B-B'));

self::assertTrue($cacheAdapter->clear());
self::assertCount(0, $pool->getValues());
self::assertFalse($pool->hasItem('metadata-testMetadata-Tests-Driver-Fixture-A-A'));
self::assertFalse($pool->hasItem('metadata-testMetadata-Tests-Driver-Fixture-B-B'));
}
}

0 comments on commit 8a08ea2

Please sign in to comment.