Skip to content

Commit

Permalink
Merge 90bad54 into d02dae8
Browse files Browse the repository at this point in the history
  • Loading branch information
svycka committed Nov 17, 2017
2 parents d02dae8 + 90bad54 commit 942a0ca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Service/CacheServiceTest.php
Expand Up @@ -156,6 +156,25 @@ public function testSaveContentIsCached()
$this->cacheService->save($this->getMvcEvent());
}

public function testSaveEventHasCacheKey()
{
$response = $this->getMvcEvent()->getResponse();
$response->setContent('mockContent');

$this->cacheService->getEventManager()->attach(CacheEvent::EVENT_SHOULDCACHE, function () { return true; });
$this->cacheService->getEventManager()->attach(CacheEvent::EVENT_SAVE, function (CacheEvent $e) {
$this->assertNotNull($e->getCacheKey());
});

$this->storageMock
->shouldReceive('setItem')
->once()
->with('/foo/bar', $response->getContent());

$this->cacheService->getOptions()->setCacheResponse(false);
$this->cacheService->save($this->getMvcEvent());
}

public function testResponseIsCachedWhenOneListenerReturnsTrue()
{
$this->cacheService->getEventManager()->attach(CacheEvent::EVENT_SHOULDCACHE, function () { return false; });
Expand Down

0 comments on commit 942a0ca

Please sign in to comment.