aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-07-25 17:33:01 +0200
committerGitHub <noreply@github.com>2018-07-25 17:33:01 +0200
commit8255faada4101b91b342bcf929d9a0e4c759cf34 (patch)
treed2710e53fd3476448e2ae508e648a1b9996cbe83 /tests
parent28b234935d2de6318e730d4f971341cb8b3eab68 (diff)
parent801e5a4523f700fde4d3137d7a0418d99d15b58a (diff)
downloadnextcloud-server-8255faada4101b91b342bcf929d9a0e4c759cf34.tar.gz
nextcloud-server-8255faada4101b91b342bcf929d9a0e4c759cf34.zip
Merge pull request #10377 from nextcloud/sccs-cache-iscached
cache isCached state for scss resources
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Template/CSSResourceLocatorTest.php7
-rw-r--r--tests/lib/Template/SCSSCacherTest.php17
2 files changed, 20 insertions, 4 deletions
diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php
index 3fb7972b211..a928f043ed3 100644
--- a/tests/lib/Template/CSSResourceLocatorTest.php
+++ b/tests/lib/Template/CSSResourceLocatorTest.php
@@ -25,6 +25,7 @@ namespace Test\Template;
use OC\Files\AppData\AppData;
use OC\Files\AppData\Factory;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\ICacheFactory;
use OCP\ILogger;
@@ -50,6 +51,8 @@ class CSSResourceLocatorTest extends \Test\TestCase {
protected $logger;
/** @var IconsCacher|\PHPUnit_Framework_MockObject_MockObject */
protected $iconsCacher;
+ /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $timeFactory;
protected function setUp() {
parent::setUp();
@@ -61,6 +64,7 @@ class CSSResourceLocatorTest extends \Test\TestCase {
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
$this->iconsCacher = $this->createMock(IconsCacher::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
}
private function cssResourceLocator() {
@@ -75,7 +79,8 @@ class CSSResourceLocatorTest extends \Test\TestCase {
$this->themingDefaults,
\OC::$SERVERROOT,
$this->cacheFactory,
- $this->iconsCacher
+ $this->iconsCacher,
+ $this->timeFactory
);
return new CSSResourceLocator(
$this->logger,
diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php
index f32b87edcbb..2389d8ec881 100644
--- a/tests/lib/Template/SCSSCacherTest.php
+++ b/tests/lib/Template/SCSSCacherTest.php
@@ -28,6 +28,7 @@ use OC\Files\AppData\Factory;
use OC\Template\SCSSCacher;
use OC\Template\IconsCacher;
use OCA\Theming\ThemingDefaults;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
@@ -58,12 +59,15 @@ class SCSSCacherTest extends \Test\TestCase {
protected $cacheFactory;
/** @var IconsCacher|\PHPUnit_Framework_MockObject_MockObject */
protected $iconsCacher;
+ /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
+ protected $timeFactory;
protected function setUp() {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
$this->appData = $this->createMock(AppData::class);
$this->iconsCacher = $this->createMock(IconsCacher::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
/** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
$factory = $this->createMock(Factory::class);
@@ -97,7 +101,8 @@ class SCSSCacherTest extends \Test\TestCase {
$this->themingDefaults,
\OC::$SERVERROOT,
$this->cacheFactory,
- $this->iconsCacher
+ $this->iconsCacher,
+ $this->timeFactory
);
}
@@ -254,7 +259,10 @@ class SCSSCacherTest extends \Test\TestCase {
$folder = $this->createMock(ISimpleFolder::class);
$folder->expects($this->at(0))->method('getFile')->with($fileNameCSS)->willThrowException(new NotFoundException());
- $actual = self::invokePrivate($this->scssCacher, 'isCached', [$fileNameCSS, $folder]);
+ $this->appData->expects($this->any())
+ ->method('getFolder')
+ ->willReturn($folder);
+ $actual = self::invokePrivate($this->scssCacher, 'isCached', [$fileNameCSS, 'core']);
$this->assertFalse($actual);
}
@@ -275,7 +283,10 @@ class SCSSCacherTest extends \Test\TestCase {
}
}));
- $actual = self::invokePrivate($this->scssCacher, 'isCached', [$fileNameCSS, $folder]);
+ $this->appData->expects($this->any())
+ ->method('getFolder')
+ ->willReturn($folder);
+ $actual = self::invokePrivate($this->scssCacher, 'isCached', [$fileNameCSS, 'core']);
$this->assertFalse($actual);
}
public function testCacheNoFile() {