2016-06-21 22:21:46 +03:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
|
|
|
|
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
|
2016-07-21 17:49:16 +03:00
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
|
* @author Julius Haertl <jus@bitgrid.net>
|
|
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2016-07-21 17:49:16 +03:00
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2017-11-06 17:56:42 +03:00
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 17:49:16 +03:00
|
|
|
|
*
|
2016-06-21 22:21:46 +03:00
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
|
namespace OCA\Theming\Tests;
|
|
|
|
|
|
2018-03-28 15:56:31 +03:00
|
|
|
|
use OCA\Theming\ImageManager;
|
2016-08-12 16:30:35 +03:00
|
|
|
|
use OCA\Theming\ThemingDefaults;
|
2019-11-22 22:52:10 +03:00
|
|
|
|
use OCA\Theming\Util;
|
2017-09-12 10:09:45 +03:00
|
|
|
|
use OCP\App\IAppManager;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
use OCP\Files\IAppData;
|
2017-02-17 18:42:07 +03:00
|
|
|
|
use OCP\Files\NotFoundException;
|
|
|
|
|
use OCP\Files\SimpleFS\ISimpleFile;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
use OCP\Files\SimpleFS\ISimpleFolder;
|
2017-02-17 18:42:07 +03:00
|
|
|
|
use OCP\ICache;
|
2016-10-14 15:57:58 +03:00
|
|
|
|
use OCP\ICacheFactory;
|
2016-06-21 22:21:46 +03:00
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
use OCP\IL10N;
|
2019-02-18 11:12:11 +03:00
|
|
|
|
use OCP\INavigationManager;
|
2016-06-21 22:21:46 +03:00
|
|
|
|
use OCP\IURLGenerator;
|
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
2016-08-12 16:30:35 +03:00
|
|
|
|
class ThemingDefaultsTest extends TestCase {
|
2017-04-07 15:51:05 +03:00
|
|
|
|
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
2016-06-21 22:21:46 +03:00
|
|
|
|
private $config;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
2016-06-21 22:21:46 +03:00
|
|
|
|
private $l10n;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
|
2016-06-21 22:21:46 +03:00
|
|
|
|
private $urlGenerator;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
/** @var \OC_Defaults|\PHPUnit_Framework_MockObject_MockObject */
|
2016-06-21 22:21:46 +03:00
|
|
|
|
private $defaults;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
/** @var IAppData|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $appData;
|
|
|
|
|
/** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $cacheFactory;
|
2016-08-12 17:58:59 +03:00
|
|
|
|
/** @var ThemingDefaults */
|
2016-06-21 22:21:46 +03:00
|
|
|
|
private $template;
|
2017-02-17 18:42:07 +03:00
|
|
|
|
/** @var Util|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $util;
|
|
|
|
|
/** @var ICache|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $cache;
|
2017-09-12 10:09:45 +03:00
|
|
|
|
/** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $appManager;
|
2018-03-28 15:56:31 +03:00
|
|
|
|
/** @var ImageManager|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $imageManager;
|
2019-02-18 11:12:11 +03:00
|
|
|
|
/** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
|
private $navigationManager;
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
|
protected function setUp(): void {
|
2016-08-23 23:02:28 +03:00
|
|
|
|
parent::setUp();
|
2017-04-25 13:16:07 +03:00
|
|
|
|
$this->config = $this->createMock(IConfig::class);
|
|
|
|
|
$this->l10n = $this->createMock(IL10N::class);
|
|
|
|
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
|
|
|
|
$this->cache = $this->createMock(ICache::class);
|
|
|
|
|
$this->util = $this->createMock(Util::class);
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->imageManager = $this->createMock(ImageManager::class);
|
2017-09-12 10:09:45 +03:00
|
|
|
|
$this->appManager = $this->createMock(IAppManager::class);
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager = $this->createMock(INavigationManager::class);
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->defaults = new \OC_Defaults();
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->urlGenerator
|
2017-02-17 18:42:07 +03:00
|
|
|
|
->expects($this->any())
|
2018-03-28 15:56:31 +03:00
|
|
|
|
->method('getBaseUrl')
|
|
|
|
|
->willReturn('');
|
2016-08-12 16:30:35 +03:00
|
|
|
|
$this->template = new ThemingDefaults(
|
2016-06-21 22:21:46 +03:00
|
|
|
|
$this->config,
|
|
|
|
|
$this->l10n,
|
|
|
|
|
$this->urlGenerator,
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$this->cacheFactory,
|
2017-09-12 10:09:45 +03:00
|
|
|
|
$this->util,
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->imageManager,
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->appManager,
|
|
|
|
|
$this->navigationManager
|
2016-06-21 22:21:46 +03:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetNameWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('Nextcloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Nextcloud', $this->template->getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetNameWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('MyCustomCloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('MyCustomCloud', $this->template->getName());
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-15 12:54:47 +03:00
|
|
|
|
public function testGetHTMLNameWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('Nextcloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Nextcloud', $this->template->getHTMLName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetHTMLNameWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('MyCustomCloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('MyCustomCloud', $this->template->getHTMLName());
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-11 20:36:26 +03:00
|
|
|
|
public function testGetTitleWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('Nextcloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Nextcloud', $this->template->getTitle());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetTitleWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('MyCustomCloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('MyCustomCloud', $this->template->getTitle());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
|
public function testGetEntityWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('Nextcloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Nextcloud', $this->template->getEntity());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetEntityWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('MyCustomCloud');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('MyCustomCloud', $this->template->getEntity());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetBaseUrlWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'url', $this->defaults->getBaseUrl())
|
|
|
|
|
->willReturn($this->defaults->getBaseUrl());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->assertEquals($this->defaults->getBaseUrl(), $this->template->getBaseUrl());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetBaseUrlWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'url', $this->defaults->getBaseUrl())
|
2016-06-21 22:21:46 +03:00
|
|
|
|
->willReturn('https://example.com/');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://example.com/', $this->template->getBaseUrl());
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 15:45:49 +03:00
|
|
|
|
public function legalUrlProvider() {
|
2018-05-09 16:52:41 +03:00
|
|
|
|
return [
|
|
|
|
|
[ '' ],
|
2018-05-24 15:45:49 +03:00
|
|
|
|
[ 'https://example.com/legal.html']
|
2018-05-09 16:52:41 +03:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $imprintUrl
|
2018-05-24 15:45:49 +03:00
|
|
|
|
* @dataProvider legalUrlProvider
|
2018-05-09 16:52:41 +03:00
|
|
|
|
*/
|
|
|
|
|
public function testGetImprintURL($imprintUrl) {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'imprintUrl', '')
|
|
|
|
|
->willReturn($imprintUrl);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($imprintUrl, $this->template->getImprintUrl());
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 15:45:49 +03:00
|
|
|
|
/**
|
|
|
|
|
* @param $privacyUrl
|
|
|
|
|
* @dataProvider legalUrlProvider
|
|
|
|
|
*/
|
|
|
|
|
public function testGetPrivacyURL($privacyUrl) {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'privacyUrl', '')
|
|
|
|
|
->willReturn($privacyUrl);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($privacyUrl, $this->template->getPrivacyUrl());
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
|
public function testGetSloganWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'slogan', $this->defaults->getSlogan())
|
|
|
|
|
->willReturn($this->defaults->getSlogan());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->assertEquals($this->defaults->getSlogan(), $this->template->getSlogan());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetSloganWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'slogan', $this->defaults->getSlogan())
|
2016-06-21 22:21:46 +03:00
|
|
|
|
->willReturn('My custom Slogan');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('My custom Slogan', $this->template->getSlogan());
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-15 12:54:47 +03:00
|
|
|
|
public function testGetShortFooter() {
|
|
|
|
|
$this->config
|
2018-05-24 15:45:49 +03:00
|
|
|
|
->expects($this->exactly(5))
|
2016-07-15 12:54:47 +03:00
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
2017-04-28 19:08:51 +03:00
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
2016-07-15 12:54:47 +03:00
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
2017-04-28 19:08:51 +03:00
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
2018-05-09 16:52:41 +03:00
|
|
|
|
['theming', 'imprintUrl', '', ''],
|
2018-05-24 15:45:49 +03:00
|
|
|
|
['theming', 'privacyUrl', '', ''],
|
2016-07-15 12:54:47 +03:00
|
|
|
|
]);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetShortFooterEmptyUrl() {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->exactly(5))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), ''],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
|
|
|
|
['theming', 'imprintUrl', '', ''],
|
|
|
|
|
['theming', 'privacyUrl', '', ''],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('<span class="entity-name">Name</span> – Slogan', $this->template->getShortFooter());
|
2016-07-15 12:54:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetShortFooterEmptySlogan() {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2016-07-15 12:54:47 +03:00
|
|
|
|
$this->config
|
2018-05-24 15:45:49 +03:00
|
|
|
|
->expects($this->exactly(5))
|
2016-07-15 12:54:47 +03:00
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
2017-04-28 19:08:51 +03:00
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
2016-07-15 12:54:47 +03:00
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
2017-04-28 19:08:51 +03:00
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), ''],
|
2018-05-09 16:52:41 +03:00
|
|
|
|
['theming', 'imprintUrl', '', ''],
|
2018-05-24 15:45:49 +03:00
|
|
|
|
['theming', 'privacyUrl', '', ''],
|
2016-07-15 12:54:47 +03:00
|
|
|
|
]);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a>', $this->template->getShortFooter());
|
2016-07-15 12:54:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 16:52:41 +03:00
|
|
|
|
public function testGetShortFooterImprint() {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2018-05-09 16:52:41 +03:00
|
|
|
|
$this->config
|
2018-05-24 15:45:49 +03:00
|
|
|
|
->expects($this->exactly(5))
|
2018-05-09 16:52:41 +03:00
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
|
|
|
|
['theming', 'imprintUrl', '', 'https://example.com/imprint'],
|
2018-05-24 15:45:49 +03:00
|
|
|
|
['theming', 'privacyUrl', '', ''],
|
2018-05-09 16:52:41 +03:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->l10n
|
|
|
|
|
->expects($this->any())
|
|
|
|
|
->method('t')
|
|
|
|
|
->willReturnArgument(0);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a>', $this->template->getShortFooter());
|
2018-05-09 16:52:41 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 15:45:49 +03:00
|
|
|
|
public function testGetShortFooterPrivacy() {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2018-05-24 15:45:49 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->exactly(5))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
|
|
|
|
['theming', 'imprintUrl', '', ''],
|
|
|
|
|
['theming', 'privacyUrl', '', 'https://example.com/privacy'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->l10n
|
|
|
|
|
->expects($this->any())
|
|
|
|
|
->method('t')
|
|
|
|
|
->willReturnArgument(0);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a>', $this->template->getShortFooter());
|
2018-05-24 15:45:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetShortFooterAllLegalLinks() {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2018-05-24 15:45:49 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->exactly(5))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
|
|
|
|
['theming', 'imprintUrl', '', 'https://example.com/imprint'],
|
|
|
|
|
['theming', 'privacyUrl', '', 'https://example.com/privacy'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->l10n
|
|
|
|
|
->expects($this->any())
|
|
|
|
|
->method('t')
|
|
|
|
|
->willReturnArgument(0);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a> · <a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a>', $this->template->getShortFooter());
|
2018-05-24 15:45:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function invalidLegalUrlProvider() {
|
2018-05-09 16:52:41 +03:00
|
|
|
|
return [
|
2018-05-24 15:45:49 +03:00
|
|
|
|
['example.com/legal'], # missing scheme
|
|
|
|
|
['https:///legal'], # missing host
|
2018-05-09 16:52:41 +03:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $invalidImprintUrl
|
2018-05-24 15:45:49 +03:00
|
|
|
|
* @dataProvider invalidLegalUrlProvider
|
2018-05-09 16:52:41 +03:00
|
|
|
|
*/
|
|
|
|
|
public function testGetShortFooterInvalidImprint($invalidImprintUrl) {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2018-05-09 16:52:41 +03:00
|
|
|
|
$this->config
|
2018-05-24 15:45:49 +03:00
|
|
|
|
->expects($this->exactly(5))
|
2018-05-09 16:52:41 +03:00
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
|
|
|
|
['theming', 'imprintUrl', '', $invalidImprintUrl],
|
2018-05-24 15:45:49 +03:00
|
|
|
|
['theming', 'privacyUrl', '', ''],
|
|
|
|
|
]);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
|
2018-05-24 15:45:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $invalidPrivacyUrl
|
|
|
|
|
* @dataProvider invalidLegalUrlProvider
|
|
|
|
|
*/
|
|
|
|
|
public function testGetShortFooterInvalidPrivacy($invalidPrivacyUrl) {
|
2019-02-18 11:12:11 +03:00
|
|
|
|
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
|
2018-05-24 15:45:49 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->exactly(5))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
|
|
|
|
|
['theming', 'imprintUrl', '', ''],
|
|
|
|
|
['theming', 'privacyUrl', '', $invalidPrivacyUrl],
|
2018-05-09 16:52:41 +03:00
|
|
|
|
]);
|
|
|
|
|
|
2018-08-27 16:22:49 +03:00
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
|
2018-05-09 16:52:41 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 02:37:47 +03:00
|
|
|
|
public function testgetColorPrimaryWithDefault() {
|
2016-06-21 22:21:46 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'color', $this->defaults->getColorPrimary())
|
|
|
|
|
->willReturn($this->defaults->getColorPrimary());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->assertEquals($this->defaults->getColorPrimary(), $this->template->getColorPrimary());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 02:37:47 +03:00
|
|
|
|
public function testgetColorPrimaryWithCustom() {
|
2016-06-21 22:21:46 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'color', $this->defaults->getColorPrimary())
|
2016-06-21 22:21:46 +03:00
|
|
|
|
->willReturn('#fff');
|
|
|
|
|
|
2017-03-28 02:37:47 +03:00
|
|
|
|
$this->assertEquals('#fff', $this->template->getColorPrimary());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSet() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'MySetting', 'MyValue');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('15');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', 16);
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->cacheFactory
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('createDistributed')
|
|
|
|
|
->with('theming-')
|
|
|
|
|
->willReturn($this->cache);
|
|
|
|
|
$this->cacheFactory
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('createDistributed')
|
|
|
|
|
->with('imagePath')
|
|
|
|
|
->willReturn($this->cache);
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$this->cache
|
2018-03-28 15:56:31 +03:00
|
|
|
|
->expects($this->any())
|
2017-02-17 18:42:07 +03:00
|
|
|
|
->method('clear')
|
2018-03-26 15:29:28 +03:00
|
|
|
|
->with('');
|
2016-06-21 22:21:46 +03:00
|
|
|
|
$this->template->set('MySetting', 'MyValue');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUndoName() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('deleteAppValue')
|
|
|
|
|
->with('theming', 'name');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('15');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', 16);
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(3))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'name', 'Nextcloud')
|
|
|
|
|
->willReturn('Nextcloud');
|
|
|
|
|
|
|
|
|
|
$this->assertSame('Nextcloud', $this->template->undo('name'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUndoBaseUrl() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('deleteAppValue')
|
|
|
|
|
->with('theming', 'url');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('15');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', 16);
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(3))
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'url', $this->defaults->getBaseUrl())
|
|
|
|
|
->willReturn($this->defaults->getBaseUrl());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->assertSame($this->defaults->getBaseUrl(), $this->template->undo('url'));
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUndoSlogan() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('deleteAppValue')
|
|
|
|
|
->with('theming', 'slogan');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('15');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', 16);
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(3))
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'slogan', $this->defaults->getSlogan())
|
|
|
|
|
->willReturn($this->defaults->getSlogan());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->assertSame($this->defaults->getSlogan(), $this->template->undo('slogan'));
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUndoColor() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('deleteAppValue')
|
|
|
|
|
->with('theming', 'color');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('15');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', 16);
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(3))
|
|
|
|
|
->method('getAppValue')
|
2017-04-28 19:08:51 +03:00
|
|
|
|
->with('theming', 'color', $this->defaults->getColorPrimary())
|
|
|
|
|
->willReturn($this->defaults->getColorPrimary());
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('color'));
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUndoDefaultAction() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('deleteAppValue')
|
|
|
|
|
->with('theming', 'defaultitem');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('15');
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('setAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', 16);
|
|
|
|
|
|
|
|
|
|
$this->assertSame('', $this->template->undo('defaultitem'));
|
|
|
|
|
}
|
2016-08-23 23:02:28 +03:00
|
|
|
|
|
2018-03-28 15:56:31 +03:00
|
|
|
|
public function testGetBackground() {
|
|
|
|
|
$this->imageManager
|
2018-01-10 01:11:49 +03:00
|
|
|
|
->expects($this->once())
|
2018-03-28 15:56:31 +03:00
|
|
|
|
->method('getImageUrl')
|
|
|
|
|
->with('background')
|
|
|
|
|
->willReturn('custom-background?v=0');
|
2017-05-05 06:32:32 +03:00
|
|
|
|
$this->assertEquals('custom-background?v=0', $this->template->getBackground());
|
2016-08-23 23:02:28 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 15:51:55 +03:00
|
|
|
|
private function getLogoHelper($withName, $useSvg) {
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->imageManager->expects($this->any())
|
|
|
|
|
->method('getImage')
|
|
|
|
|
->with('logo')
|
2017-02-17 18:42:07 +03:00
|
|
|
|
->willThrowException(new NotFoundException());
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$this->config
|
2017-04-09 04:48:57 +03:00
|
|
|
|
->expects($this->at(0))
|
2016-08-23 23:02:28 +03:00
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'logoMime')
|
|
|
|
|
->willReturn('');
|
2017-04-09 04:48:57 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('0');
|
2017-04-25 13:16:07 +03:00
|
|
|
|
$this->urlGenerator->expects($this->once())
|
|
|
|
|
->method('imagePath')
|
2017-05-08 15:51:55 +03:00
|
|
|
|
->with('core', $withName)
|
2017-04-25 13:16:07 +03:00
|
|
|
|
->willReturn('core-logo');
|
2017-05-08 15:51:55 +03:00
|
|
|
|
$this->assertEquals('core-logo?v=0', $this->template->getLogo($useSvg));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetLogoDefaultWithSvg() {
|
2018-08-28 16:58:27 +03:00
|
|
|
|
$this->getLogoHelper('logo/logo.svg', true);
|
2017-05-08 15:51:55 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetLogoDefaultWithoutSvg() {
|
2018-08-28 16:58:27 +03:00
|
|
|
|
$this->getLogoHelper('logo/logo.png', false);
|
2016-08-23 23:02:28 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetLogoCustom() {
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$file = $this->createMock(ISimpleFile::class);
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->imageManager->expects($this->once())
|
|
|
|
|
->method('getImage')
|
|
|
|
|
->with('logo')
|
2017-04-24 11:50:24 +03:00
|
|
|
|
->willReturn($file);
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$this->config
|
2017-04-09 04:48:57 +03:00
|
|
|
|
->expects($this->at(0))
|
2016-08-23 23:02:28 +03:00
|
|
|
|
->method('getAppValue')
|
2017-04-24 11:50:24 +03:00
|
|
|
|
->with('theming', 'logoMime', false)
|
2016-08-23 23:02:28 +03:00
|
|
|
|
->willReturn('image/svg+xml');
|
2017-04-09 04:48:57 +03:00
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('0');
|
2017-04-25 13:16:07 +03:00
|
|
|
|
$this->urlGenerator->expects($this->once())
|
|
|
|
|
->method('linkToRoute')
|
2018-03-28 15:56:31 +03:00
|
|
|
|
->with('theming.Theming.getImage')
|
2018-05-08 14:06:31 +03:00
|
|
|
|
->willReturn('custom-logo?v=0');
|
2017-04-25 13:16:07 +03:00
|
|
|
|
$this->assertEquals('custom-logo' . '?v=0', $this->template->getLogo());
|
2016-08-23 23:02:28 +03:00
|
|
|
|
}
|
2017-02-17 18:42:07 +03:00
|
|
|
|
|
|
|
|
|
public function testGetScssVariablesCached() {
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->cacheFactory->expects($this->once())
|
|
|
|
|
->method('createDistributed')
|
|
|
|
|
->with('theming-')
|
|
|
|
|
->willReturn($this->cache);
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo'=>'bar']);
|
|
|
|
|
$this->assertEquals(['foo'=>'bar'], $this->template->getScssVariables());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetScssVariables() {
|
|
|
|
|
$this->config->expects($this->at(0))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0');
|
|
|
|
|
$this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg');
|
2017-05-19 17:11:42 +03:00
|
|
|
|
$this->config->expects($this->at(2))->method('getAppValue')->with('theming', 'backgroundMime', false)->willReturn('jpeg');
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'logoheaderMime', false)->willReturn('jpeg');
|
|
|
|
|
$this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'faviconMime', false)->willReturn('jpeg');
|
|
|
|
|
|
2018-08-28 19:21:17 +03:00
|
|
|
|
$this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary());
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
|
2018-08-28 19:21:17 +03:00
|
|
|
|
$this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
|
2017-05-19 17:11:42 +03:00
|
|
|
|
$this->config->expects($this->at(8))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
|
2017-02-17 18:42:07 +03:00
|
|
|
|
|
2017-04-28 19:08:51 +03:00
|
|
|
|
$this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
|
2017-09-02 00:06:44 +03:00
|
|
|
|
$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->cacheFactory->expects($this->once())
|
|
|
|
|
->method('createDistributed')
|
|
|
|
|
->with('theming-')
|
|
|
|
|
->willReturn($this->cache);
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
|
2018-03-28 15:56:31 +03:00
|
|
|
|
$this->imageManager->expects($this->at(0))->method('getImageUrl')->with('logo')->willReturn('custom-logo?v=0');
|
|
|
|
|
$this->imageManager->expects($this->at(1))->method('getImageUrl')->with('logoheader')->willReturn('custom-logoheader?v=0');
|
|
|
|
|
$this->imageManager->expects($this->at(2))->method('getImageUrl')->with('favicon')->willReturn('custom-favicon?v=0');
|
|
|
|
|
$this->imageManager->expects($this->at(3))->method('getImageUrl')->with('background')->willReturn('custom-background?v=0');
|
2017-04-25 13:16:07 +03:00
|
|
|
|
|
2017-02-17 18:42:07 +03:00
|
|
|
|
$expected = [
|
|
|
|
|
'theming-cachebuster' => '\'0\'',
|
2017-05-19 17:11:42 +03:00
|
|
|
|
'theming-logo-mime' => '\'jpeg\'',
|
|
|
|
|
'theming-background-mime' => '\'jpeg\'',
|
2018-06-03 12:26:06 +03:00
|
|
|
|
'image-logo' => "url('custom-logo?v=0')",
|
|
|
|
|
'image-login-background' => "url('custom-background?v=0')",
|
2017-04-28 19:08:51 +03:00
|
|
|
|
'color-primary' => $this->defaults->getColorPrimary(),
|
2017-05-01 11:42:19 +03:00
|
|
|
|
'color-primary-text' => '#ffffff',
|
2017-09-02 00:06:44 +03:00
|
|
|
|
'image-login-plain' => 'false',
|
2018-03-28 15:56:31 +03:00
|
|
|
|
'color-primary-element' => '#aaaaaa',
|
|
|
|
|
'theming-logoheader-mime' => '\'jpeg\'',
|
|
|
|
|
'theming-favicon-mime' => '\'jpeg\'',
|
2019-08-21 18:18:23 +03:00
|
|
|
|
'image-logoheader' => "url('custom-logoheader?v=0')",
|
|
|
|
|
'image-favicon' => "url('custom-favicon?v=0')",
|
2018-05-24 16:21:35 +03:00
|
|
|
|
'has-legal-links' => 'false'
|
2017-02-17 18:42:07 +03:00
|
|
|
|
];
|
|
|
|
|
$this->assertEquals($expected, $this->template->getScssVariables());
|
|
|
|
|
}
|
2017-07-19 11:20:47 +03:00
|
|
|
|
|
|
|
|
|
public function testGetDefaultAndroidURL() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
|
|
|
|
|
->willReturn('https://play.google.com/store/apps/details?id=com.nextcloud.client');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://play.google.com/store/apps/details?id=com.nextcloud.client', $this->template->getAndroidClientUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetCustomAndroidURL() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
|
|
|
|
|
->willReturn('https://play.google.com/store/apps/details?id=com.mycloud.client');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://play.google.com/store/apps/details?id=com.mycloud.client', $this->template->getAndroidClientUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetDefaultiOSURL() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2018-02-02 23:26:33 +03:00
|
|
|
|
->with('theming', 'iOSClientUrl', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
|
|
|
|
|
->willReturn('https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');
|
2017-07-19 11:20:47 +03:00
|
|
|
|
|
2018-02-02 23:26:33 +03:00
|
|
|
|
$this->assertEquals('https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', $this->template->getiOSClientUrl());
|
2017-07-19 11:20:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetCustomiOSURL() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
2018-02-02 23:26:33 +03:00
|
|
|
|
->with('theming', 'iOSClientUrl', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
|
|
|
|
|
->willReturn('https://geo.itunes.apple.com/us/app/nextcloud/id1234567890?mt=8');
|
2017-07-19 11:20:47 +03:00
|
|
|
|
|
2018-02-02 23:26:33 +03:00
|
|
|
|
$this->assertEquals('https://geo.itunes.apple.com/us/app/nextcloud/id1234567890?mt=8', $this->template->getiOSClientUrl());
|
2017-07-19 11:20:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetDefaultiTunesAppId() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'iTunesAppId', '1125420102')
|
|
|
|
|
->willReturn('1125420102');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('1125420102', $this->template->getiTunesAppId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetCustomiTunesAppId() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'iTunesAppId', '1125420102')
|
|
|
|
|
->willReturn('1234567890');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('1234567890', $this->template->getiTunesAppId());
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 16:03:47 +03:00
|
|
|
|
public function dataReplaceImagePath() {
|
|
|
|
|
return [
|
|
|
|
|
['core', 'test.png', false],
|
|
|
|
|
['core', 'manifest.json'],
|
|
|
|
|
['core', 'favicon.ico'],
|
|
|
|
|
['core', 'favicon-touch.png']
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @dataProvider dataReplaceImagePath */
|
|
|
|
|
public function testReplaceImagePath($app, $image, $result = 'themingRoute?v=0') {
|
2017-09-12 10:47:38 +03:00
|
|
|
|
$this->cache->expects($this->any())
|
2017-09-11 16:03:47 +03:00
|
|
|
|
->method('get')
|
|
|
|
|
->with('shouldReplaceIcons')
|
|
|
|
|
->willReturn(true);
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->any())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
|
->willReturn('0');
|
|
|
|
|
$this->urlGenerator
|
|
|
|
|
->expects($this->any())
|
|
|
|
|
->method('linkToRoute')
|
|
|
|
|
->willReturn('themingRoute');
|
|
|
|
|
$this->assertEquals($result, $this->template->replaceImagePath($app, $image));
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|