Skip to content

Commit

Permalink
Remove old test
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Mar 30, 2024
1 parent 249f6a7 commit 30c19d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/services/CacheRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ public function getCachedResponse(SiteUriModel $siteUri): ?Response

$cacheStorage = Blitz::$plugin->cacheStorage;
$siteUri = $event->siteUri;
$encoded = $this->requestAcceptsEncoding();
$encoded = $this->requestAcceptsEncoding() && $cacheStorage->canCompressCachedValues();
$content = '';

if ($encoded && $cacheStorage->canCompressCachedValues()) {
if ($encoded) {
$content = $cacheStorage->getCompressed($siteUri);
}

Expand Down
1 change: 0 additions & 1 deletion tests/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ _Tests that cached web responses contain the correct headers and comments._
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response does not contain output comments when disabled.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response with mime type has headers and does not contain output comments.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response is encoded when compression is enabled.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response is not encoded when compression is disabled.
15 changes: 1 addition & 14 deletions tests/pest/Interface/WebResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
$siteUri = createSiteUri();
Blitz::$plugin->cacheStorage->compressCachedValues = true;
Blitz::$plugin->cacheStorage->save($output, $siteUri);
Craft::$app->getRequest()->headers->remove(HeaderEnum::ACCEPT_ENCODING);
Craft::$app->getRequest()->headers->set(HeaderEnum::ACCEPT_ENCODING, 'deflate, gzip');
$response = Blitz::$plugin->cacheRequest->getCachedResponse($siteUri);

Expand All @@ -105,17 +106,3 @@
->and(gzdecode($response->content))
->toBe($output);
});

test('Response is not encoded when compression is disabled', function() {
$output = createOutput();
$siteUri = createSiteUri();
Blitz::$plugin->cacheStorage->compressCachedValues = false;
Blitz::$plugin->cacheStorage->save($output, $siteUri);
Craft::$app->getRequest()->headers->set(HeaderEnum::ACCEPT_ENCODING, 'deflate, gzip');
$response = Blitz::$plugin->cacheRequest->getCachedResponse($siteUri);

expect($response->headers->get(HeaderEnum::CONTENT_ENCODING))
->toBeNull()
->and($response->content)
->toContain($output);
});

0 comments on commit 30c19d2

Please sign in to comment.