Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-05-29 12:10:07 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-06-04 09:48:54 +0300
commita34495933e83c4c850308e3448a16160162eb65a (patch)
treef0996c9fe47219b744a79890506e97238b2a36c1 /tests
parent36d74047f7ead966438ae7958ca7d7f816860515 (diff)
Move caching logic to response
This avoids having to do it at all the places we want cached responses. We can't inject the ITimeFactor without breaking public API. However we can perfectly overwrite the service (resulting in the same testable effect). Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index 9267d862600..5c867388369 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -27,6 +27,7 @@ namespace Test\AppFramework\Http;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Utility\ITimeFactory;
class ResponseTest extends \Test\TestCase {
@@ -222,15 +223,24 @@ class ResponseTest extends \Test\TestCase {
$headers = $this->childResponse->getHeaders();
$this->assertEquals('no-cache, no-store, must-revalidate', $headers['Cache-Control']);
+ $this->assertFalse(isset($headers['Pragma']));
+ $this->assertFalse(isset($headers['Expires']));
}
public function testCacheSeconds() {
+ $time = $this->createMock(ITimeFactory::class);
+ $time->method('getTime')
+ ->willReturn('1234567');
+
+ $this->overwriteService(ITimeFactory::class, $time);
+
$this->childResponse->cacheFor(33);
$headers = $this->childResponse->getHeaders();
- $this->assertEquals('max-age=33, must-revalidate',
- $headers['Cache-Control']);
+ $this->assertEquals('max-age=33, must-revalidate', $headers['Cache-Control']);
+ $this->assertEquals('public', $headers['Pragma']);
+ $this->assertEquals('Thu, 15 Jan 1970 06:56:40 +0000', $headers['Expires']);
}