public function testGetSetCache() { $registry = new Registry(); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber(new CacheListener($eventDispatcher)); $clientMock = $this->getMockBuilder('Itkg\\Consumer\\Client\\RestClient')->getMock(); $clientMock->expects($this->once())->method('sendRequest'); $cacheableService = new Service($eventDispatcher, $clientMock, array('identifier' => 'cacheable service', 'cache_serializer' => function (Response $response) { $response->setContent('My content'); return serialize($response); }, 'cache_adapter' => $registry)); $this->assertFalse($cacheableService->isLoaded()); $cacheableService->sendRequest(Request::create('/')); $this->assertNotNull($registry->get($cacheableService)); $cacheableService->sendRequest(Request::create('/')); $this->assertTrue($cacheableService->isLoaded()); }
/** * Remove cache * * @return void */ public function removeAll() { parent::removeAll(); $this->adapter->removeAll(); }