|
|
|
@ -1,5 +1,7 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
@ -7,7 +9,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace Test\Template;
|
|
|
|
namespace Test\Template;
|
|
|
|
|
|
|
|
|
|
|
|
use OC\SystemConfig;
|
|
|
|
|
|
|
|
use OC\Template\JSCombiner;
|
|
|
|
use OC\Template\JSCombiner;
|
|
|
|
use OCP\Files\IAppData;
|
|
|
|
use OCP\Files\IAppData;
|
|
|
|
use OCP\Files\NotFoundException;
|
|
|
|
use OCP\Files\NotFoundException;
|
|
|
|
@ -16,33 +17,29 @@ use OCP\Files\SimpleFS\ISimpleFile;
|
|
|
|
use OCP\Files\SimpleFS\ISimpleFolder;
|
|
|
|
use OCP\Files\SimpleFS\ISimpleFolder;
|
|
|
|
use OCP\ICache;
|
|
|
|
use OCP\ICache;
|
|
|
|
use OCP\ICacheFactory;
|
|
|
|
use OCP\ICacheFactory;
|
|
|
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\ITempManager;
|
|
|
|
use OCP\ITempManager;
|
|
|
|
use OCP\IURLGenerator;
|
|
|
|
use OCP\IURLGenerator;
|
|
|
|
use OCP\Server;
|
|
|
|
use OCP\Server;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
|
|
|
|
|
|
|
|
class JSCombinerTest extends \Test\TestCase {
|
|
|
|
class JSCombinerTest extends \Test\TestCase {
|
|
|
|
/** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
private IAppData&MockObject $appData;
|
|
|
|
protected $appData;
|
|
|
|
private IURLGenerator&MockObject $urlGenerator;
|
|
|
|
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
private IConfig&MockObject $config;
|
|
|
|
protected $urlGenerator;
|
|
|
|
private ICache&MockObject $depsCache;
|
|
|
|
/** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
private LoggerInterface&MockObject $logger;
|
|
|
|
protected $config;
|
|
|
|
private ICacheFactory&MockObject $cacheFactory;
|
|
|
|
/** @var ICache|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
|
|
|
|
protected $depsCache;
|
|
|
|
private JSCombiner $jsCombiner;
|
|
|
|
/** @var JSCombiner */
|
|
|
|
|
|
|
|
protected $jsCombiner;
|
|
|
|
|
|
|
|
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
|
|
|
|
protected $logger;
|
|
|
|
|
|
|
|
/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
|
|
|
|
|
|
|
|
protected $cacheFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function setUp(): void {
|
|
|
|
protected function setUp(): void {
|
|
|
|
parent::setUp();
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
|
|
$this->appData = $this->createMock(IAppData::class);
|
|
|
|
$this->appData = $this->createMock(IAppData::class);
|
|
|
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
|
|
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
|
|
|
$this->config = $this->createMock(SystemConfig::class);
|
|
|
|
$this->config = $this->createMock(IConfig::class);
|
|
|
|
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
|
|
|
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
|
|
|
$this->depsCache = $this->createMock(ICache::class);
|
|
|
|
$this->depsCache = $this->createMock(ICache::class);
|
|
|
|
$this->cacheFactory->expects($this->atLeastOnce())
|
|
|
|
$this->cacheFactory->expects($this->atLeastOnce())
|
|
|
|
@ -61,7 +58,7 @@ class JSCombinerTest extends \Test\TestCase {
|
|
|
|
public function testProcessDebugMode(): void {
|
|
|
|
public function testProcessDebugMode(): void {
|
|
|
|
$this->config
|
|
|
|
$this->config
|
|
|
|
->expects($this->once())
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getValue')
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
->with('debug')
|
|
|
|
->with('debug')
|
|
|
|
->willReturn(true);
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,7 +69,7 @@ class JSCombinerTest extends \Test\TestCase {
|
|
|
|
public function testProcessNotInstalled(): void {
|
|
|
|
public function testProcessNotInstalled(): void {
|
|
|
|
$this->config
|
|
|
|
$this->config
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->method('getValue')
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
->willReturnMap([
|
|
|
|
->willReturnMap([
|
|
|
|
['debug', false],
|
|
|
|
['debug', false],
|
|
|
|
['installed', false]
|
|
|
|
['installed', false]
|
|
|
|
@ -85,10 +82,10 @@ class JSCombinerTest extends \Test\TestCase {
|
|
|
|
public function testProcessUncachedFileNoAppDataFolder(): void {
|
|
|
|
public function testProcessUncachedFileNoAppDataFolder(): void {
|
|
|
|
$this->config
|
|
|
|
$this->config
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->method('getValue')
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
->willReturnMap([
|
|
|
|
->willReturnMap([
|
|
|
|
['debug', '', false],
|
|
|
|
['debug', false],
|
|
|
|
['installed', '', true],
|
|
|
|
['installed', true],
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willThrowException(new NotFoundException());
|
|
|
|
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willThrowException(new NotFoundException());
|
|
|
|
@ -121,10 +118,10 @@ class JSCombinerTest extends \Test\TestCase {
|
|
|
|
public function testProcessUncachedFile(): void {
|
|
|
|
public function testProcessUncachedFile(): void {
|
|
|
|
$this->config
|
|
|
|
$this->config
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->method('getValue')
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
->willReturnMap([
|
|
|
|
->willReturnMap([
|
|
|
|
['debug', '', false],
|
|
|
|
['debug', false],
|
|
|
|
['installed', '', true],
|
|
|
|
['installed', true],
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willReturn($folder);
|
|
|
|
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willReturn($folder);
|
|
|
|
@ -155,10 +152,10 @@ class JSCombinerTest extends \Test\TestCase {
|
|
|
|
public function testProcessCachedFile(): void {
|
|
|
|
public function testProcessCachedFile(): void {
|
|
|
|
$this->config
|
|
|
|
$this->config
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->method('getValue')
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
->willReturnMap([
|
|
|
|
->willReturnMap([
|
|
|
|
['debug', '', false],
|
|
|
|
['debug', false],
|
|
|
|
['installed', '', true],
|
|
|
|
['installed', true],
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willReturn($folder);
|
|
|
|
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willReturn($folder);
|
|
|
|
@ -192,10 +189,10 @@ class JSCombinerTest extends \Test\TestCase {
|
|
|
|
public function testProcessCachedFileMemcache(): void {
|
|
|
|
public function testProcessCachedFileMemcache(): void {
|
|
|
|
$this->config
|
|
|
|
$this->config
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->expects($this->exactly(2))
|
|
|
|
->method('getValue')
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
->willReturnMap([
|
|
|
|
->willReturnMap([
|
|
|
|
['debug', '', false],
|
|
|
|
['debug', false],
|
|
|
|
['installed', '', true],
|
|
|
|
['installed', true],
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$folder = $this->createMock(ISimpleFolder::class);
|
|
|
|
$this->appData->expects($this->once())
|
|
|
|
$this->appData->expects($this->once())
|
|
|
|
|