summaryrefslogtreecommitdiffstats
path: root/apps/theming/tests
diff options
context:
space:
mode:
authorJulius Haertl <jus@bitgrid.net>2016-10-14 14:57:58 +0200
committerJulius Haertl <jus@bitgrid.net>2016-11-18 10:23:24 +0100
commit2e8dd218157123cdb7f1741980e12dc22b95f320 (patch)
tree08cc47865cc2b20bc61f07dc2a35e084d0423eb3 /apps/theming/tests
parent492d0b9f9bd72591183ff8bf4e8d5f9b4aecba35 (diff)
downloadnextcloud-server-2e8dd218157123cdb7f1741980e12dc22b95f320.tar.gz
nextcloud-server-2e8dd218157123cdb7f1741980e12dc22b95f320.zip
Improve caching
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php25
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php7
2 files changed, 22 insertions, 10 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index 82a937c3b91..98fa4f1a243 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -103,7 +103,10 @@ class IconControllerTest extends TestCase {
->willReturn($file);
$expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);
$expected->cacheFor(86400);
- $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
+ $expires = new \DateTime();
+ $expires->setTimestamp($this->timeFactory->getTime());
+ $expires->add(new \DateInterval('PT24H'));
+ $expected->addHeader('Expires', $expires->format(\DateTime::RFC2822));
$expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->iconController->getThemedIcon('core', 'filetypes/folder.svg'));
@@ -133,7 +136,10 @@ class IconControllerTest extends TestCase {
$expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
$expected->cacheFor(86400);
- $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
+ $expires = new \DateTime();
+ $expires->setTimestamp($this->timeFactory->getTime());
+ $expires->add(new \DateInterval('PT24H'));
+ $expected->addHeader('Expires', $expires->format(\DateTime::RFC2822));
$expected->addHeader('Pragma', 'cache');
$this->assertEquals($expected, $this->iconController->getFavicon());
}
@@ -143,9 +149,8 @@ class IconControllerTest extends TestCase {
->method('shouldReplaceIcons')
->willReturn(false);
$expected = new DataDisplayResponse(null, Http::STATUS_NOT_FOUND);
- $expected->cacheFor(86400);
- $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
- $expected->addHeader('Pragma', 'cache');
+ $expected->cacheFor(0);
+ $expected->setLastModified(new \DateTime('now', new \DateTimeZone('GMT')));
$this->assertEquals($expected, $this->iconController->getFavicon());
}
@@ -172,7 +177,10 @@ class IconControllerTest extends TestCase {
$expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/png']);
$expected->cacheFor(86400);
- $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
+ $expires = new \DateTime();
+ $expires->setTimestamp($this->timeFactory->getTime());
+ $expires->add(new \DateInterval('PT24H'));
+ $expected->addHeader('Expires', $expires->format(\DateTime::RFC2822));
$expected->addHeader('Pragma', 'cache');
$this->assertEquals($expected, $this->iconController->getTouchIcon());
}
@@ -182,9 +190,8 @@ class IconControllerTest extends TestCase {
->method('shouldReplaceIcons')
->willReturn(false);
$expected = new DataDisplayResponse(null, Http::STATUS_NOT_FOUND);
- $expected->cacheFor(86400);
- $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
- $expected->addHeader('Pragma', 'cache');
+ $expected->cacheFor(0);
+ $expected->setLastModified(new \DateTime('now', new \DateTimeZone('GMT')));
$this->assertEquals($expected, $this->iconController->getTouchIcon());
}
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 204c96d86d5..cd3a90e760a 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -24,6 +24,7 @@
namespace OCA\Theming\Tests;
use OCA\Theming\ThemingDefaults;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -43,6 +44,8 @@ class ThemingDefaultsTest extends TestCase {
private $template;
/** @var IRootFolder */
private $rootFolder;
+ /** @var ICacheFactory */
+ private $cacheFactory;
public function setUp() {
parent::setUp();
@@ -52,6 +55,7 @@ class ThemingDefaultsTest extends TestCase {
$this->rootFolder = $this->getMockBuilder(IRootFolder::class)
->disableOriginalConstructor()
->getMock();
+ $this->cacheFactory = $this->getMockBuilder(ICacheFactory::class)->getMock();
$this->defaults = $this->getMockBuilder(\OC_Defaults::class)
->disableOriginalConstructor()
->getMock();
@@ -76,7 +80,8 @@ class ThemingDefaultsTest extends TestCase {
$this->l10n,
$this->urlGenerator,
$this->defaults,
- $this->rootFolder
+ $this->rootFolder,
+ $this->cacheFactory
);
}