[Cache] Fix NullAdapter must set taggable

This commit is contained in:
a.dmitryuk
2025-12-02 09:33:06 +07:00
committed by Nicolas Grekas
parent 8b9948a828
commit 8f9fdb4254
2 changed files with 10 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ class NullAdapter implements AdapterInterface, CacheInterface, NamespacedPoolInt
self::$createCacheItem ??= \Closure::bind(
static function ($key) {
$item = new CacheItem();
$item->isTaggable = true;
$item->key = $key;
$item->isHit = false;

View File

@@ -138,6 +138,15 @@ class NullAdapterTest extends TestCase
$this->assertTrue($this->createCachePool()->commit());
}
public function testTaggable()
{
$this->expectNotToPerformAssertions();
$adapter = $this->createCachePool();
$item = $adapter->getItem('any_item');
// No error triggered 'Cache item "%s" comes from a non tag-aware pool: you cannot tag it.'
$item->tag(['tag1']);
}
public function testInvalidateTags()
{
$adapter = $this->createCachePool();