Remove outdated doctrine/cache package and change configuration

This commit is contained in:
2026-05-26 15:38:15 +00:00
parent 9f339953fe
commit 23f00b2374
7 changed files with 295 additions and 518 deletions

View File

@@ -0,0 +1,47 @@
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace CloudObjects\SDK;
use ML\IRI\IRI;
use Kevinrob\GuzzleCache\Storage\VolatileRuntimeStorage;
use CloudObjects\SDK\TestHelpers\InMemoryLogger;
class ObjectRetrieverCacheTest extends \PHPUnit\Framework\TestCase {
public function testCacheInRuntimeStorage() {
$cacheStorage = new VolatileRuntimeStorage;
$logger = new InMemoryLogger;
$coid = new IRI('coid://cloudobjects.io');
$retriever = new ObjectRetriever([
'cache_storage' => $cacheStorage,
'logger' => $logger
]);
$object1 = $retriever->getCloudObject($coid);
$this->assertNotNull($object1);
$this->assertNotNull($cacheStorage->fetch($retriever->getCacheKey((string)$coid)));
$this->assertStringContainsString('from Core API', $logger->getLastLogMessage());
// Reinitialize retriever with same cache storage to verify that cache is used
$retriever = new ObjectRetriever([
'cache_storage' => $cacheStorage,
'logger' => $logger
]);
$object2 = $retriever->getCloudObject($coid);
$this->assertNotNull($object2);
$this->assertNotNull($cacheStorage->fetch($retriever->getCacheKey((string)$coid)));
$this->assertStringContainsString('from object cache', $logger->getLastLogMessage());
$this->assertEquals($object1->getRevision(), $object2->getRevision());
}
}