Remove outdated doctrine/cache package and change configuration
This commit is contained in:
47
tests/OnlineTests/ObjectRetrieverCacheTest.php
Normal file
47
tests/OnlineTests/ObjectRetrieverCacheTest.php
Normal 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());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user