aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-07-19 16:31:29 +0200
committerGitHub <noreply@github.com>2017-07-19 16:31:29 +0200
commit49c622fcbafe039c44d95595edfdda8a0cf7e042 (patch)
tree1848096a37227f92b222faa5ff1428c287549002 /tests/lib
parentd5e3428af54bd85a6008a74dc8a3a9c09204179a (diff)
parent2ebafb06fdef6aad4bc32316ece14faa60f9e9c4 (diff)
downloadnextcloud-server-49c622fcbafe039c44d95595edfdda8a0cf7e042.tar.gz
nextcloud-server-49c622fcbafe039c44d95595edfdda8a0cf7e042.zip
Merge pull request #5719 from nextcloud/improve-jscombiner
Properly handle if the deps file if for some reason empty
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Template/JSCombinerTest.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php
index 89bb13338c8..d6583d4a450 100644
--- a/tests/lib/Template/JSCombinerTest.php
+++ b/tests/lib/Template/JSCombinerTest.php
@@ -31,6 +31,7 @@ use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\ICache;
+use OCP\ILogger;
use OCP\IURLGenerator;
class JSCombinerTest extends \Test\TestCase {
@@ -44,6 +45,8 @@ class JSCombinerTest extends \Test\TestCase {
protected $depsCache;
/** @var JSCombiner */
protected $jsCombiner;
+ /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
+ protected $logger;
protected function setUp() {
parent::setUp();
@@ -52,11 +55,14 @@ class JSCombinerTest extends \Test\TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->config = $this->createMock(SystemConfig::class);
$this->depsCache = $this->createMock(ICache::class);
+ $this->logger = $this->createMock(ILogger::class);
$this->jsCombiner = new JSCombiner(
$this->appData,
$this->urlGenerator,
$this->depsCache,
- $this->config);
+ $this->config,
+ $this->logger
+ );
}
public function testProcessDebugMode() {
@@ -284,6 +290,23 @@ class JSCombinerTest extends \Test\TestCase {
$this->assertFalse($actual);
}
+ public function testIsCachedWithoutContent() {
+ $fileName = 'combine.json';
+ $folder = $this->createMock(ISimpleFolder::class);
+ $file = $this->createMock(ISimpleFile::class);
+ $folder->method('getFile')
+ ->with('combine.js.deps')
+ ->willReturn($file);
+ $file->expects($this->once())
+ ->method('getContent')
+ ->willReturn('');
+ $this->logger->expects($this->once())
+ ->method('info')
+ ->with('JSCombiner: deps file empty: combine.js.deps');
+ $actual = self::invokePrivate($this->jsCombiner, 'isCached', [$fileName, $folder]);
+ $this->assertFalse($actual);
+ }
+
public function testCacheNoFile() {
$fileName = 'combine.js';