2016-06-21 22:21:46 +03:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
|
*
|
2016-07-21 17:49:16 +03:00
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
|
*
|
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/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
namespace OCA\Theming\Tests;
|
|
|
|
|
|
2016-08-12 16:30:35 +03:00
|
|
|
|
use OCA\Theming\ThemingDefaults;
|
2017-04-07 15:51:05 +03:00
|
|
|
|
use OCP\Files\IAppData;
|
|
|
|
|
use OCP\Files\SimpleFS\ISimpleFolder;
|
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;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
public function setUp() {
|
2016-08-23 23:02:28 +03:00
|
|
|
|
parent::setUp();
|
2016-08-31 21:33:18 +03:00
|
|
|
|
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
|
|
|
|
|
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
|
|
|
|
|
$this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock();
|
2017-04-07 15:51:05 +03:00
|
|
|
|
$this->appData = $this->createMock(IAppData::class);
|
2016-10-14 15:57:58 +03:00
|
|
|
|
$this->cacheFactory = $this->getMockBuilder(ICacheFactory::class)->getMock();
|
2016-08-31 21:33:18 +03:00
|
|
|
|
$this->defaults = $this->getMockBuilder(\OC_Defaults::class)
|
2016-06-21 22:21:46 +03:00
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$this->defaults
|
|
|
|
|
->expects($this->at(0))
|
|
|
|
|
->method('getName')
|
|
|
|
|
->willReturn('Nextcloud');
|
|
|
|
|
$this->defaults
|
|
|
|
|
->expects($this->at(1))
|
|
|
|
|
->method('getBaseUrl')
|
|
|
|
|
->willReturn('https://nextcloud.com/');
|
|
|
|
|
$this->defaults
|
|
|
|
|
->expects($this->at(2))
|
|
|
|
|
->method('getSlogan')
|
|
|
|
|
->willReturn('Safe Data');
|
|
|
|
|
$this->defaults
|
|
|
|
|
->expects($this->at(3))
|
2017-03-28 02:37:47 +03:00
|
|
|
|
->method('getColorPrimary')
|
2016-06-21 22:21:46 +03:00
|
|
|
|
->willReturn('#000');
|
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,
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$this->defaults,
|
2017-04-07 15:51:05 +03:00
|
|
|
|
$this->appData,
|
2016-10-14 15:57:58 +03:00
|
|
|
|
$this->cacheFactory
|
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')
|
|
|
|
|
->with('theming', 'url', 'https://nextcloud.com/')
|
|
|
|
|
->willReturn('https://nextcloud.com/');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://nextcloud.com/', $this->template->getBaseUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetBaseUrlWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'url', 'https://nextcloud.com/')
|
|
|
|
|
->willReturn('https://example.com/');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://example.com/', $this->template->getBaseUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetSloganWithDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'slogan', 'Safe Data')
|
|
|
|
|
->willReturn('Safe Data');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Safe Data', $this->template->getSlogan());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetSloganWithCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'slogan', 'Safe Data')
|
|
|
|
|
->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
|
|
|
|
|
->expects($this->exactly(3))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', 'https://nextcloud.com/', 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', 'Safe Data', 'Slogan'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a> – Slogan', $this->template->getShortFooter());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetShortFooterEmptySlogan() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->exactly(3))
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['theming', 'url', 'https://nextcloud.com/', 'url'],
|
|
|
|
|
['theming', 'name', 'Nextcloud', 'Name'],
|
|
|
|
|
['theming', 'slogan', 'Safe Data', ''],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer">Name</a>', $this->template->getShortFooter());
|
|
|
|
|
}
|
|
|
|
|
|
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')
|
|
|
|
|
->with('theming', 'color', '#000')
|
|
|
|
|
->willReturn('#000');
|
|
|
|
|
|
2017-03-28 02:37:47 +03:00
|
|
|
|
$this->assertEquals('#000', $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')
|
|
|
|
|
->with('theming', 'color', '#000')
|
|
|
|
|
->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);
|
|
|
|
|
|
|
|
|
|
$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')
|
|
|
|
|
->with('theming', 'url', 'https://nextcloud.com/')
|
|
|
|
|
->willReturn('https://nextcloud.com/');
|
|
|
|
|
|
|
|
|
|
$this->assertSame('https://nextcloud.com/', $this->template->undo('url'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
->with('theming', 'slogan', 'Safe Data')
|
|
|
|
|
->willReturn('Safe Data');
|
|
|
|
|
|
|
|
|
|
$this->assertSame('Safe Data', $this->template->undo('slogan'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
->with('theming', 'color', '#000')
|
|
|
|
|
->willReturn('#000');
|
|
|
|
|
|
|
|
|
|
$this->assertSame('#000', $this->template->undo('color'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
public function testGetBackgroundDefault() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'backgroundMime')
|
|
|
|
|
->willReturn('');
|
2017-04-07 15:51:05 +03:00
|
|
|
|
$this->appData
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getFolder')
|
|
|
|
|
->with('images')
|
|
|
|
|
->willThrowException(new \Exception());
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$expected = $this->urlGenerator->imagePath('core','background.jpg');
|
|
|
|
|
$this->assertEquals($expected, $this->template->getBackground());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetBackgroundCustom() {
|
|
|
|
|
$this->config
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getAppValue')
|
|
|
|
|
->with('theming', 'backgroundMime')
|
|
|
|
|
->willReturn('image/svg+xml');
|
2017-04-07 15:51:05 +03:00
|
|
|
|
$simpleFolder = $this->createMock(ISimpleFolder::class);
|
|
|
|
|
$this->appData
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getFolder')
|
|
|
|
|
->with('images')
|
|
|
|
|
->willReturn($simpleFolder);
|
|
|
|
|
$simpleFolder
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getFile')
|
|
|
|
|
->with('background')
|
|
|
|
|
->willReturn('');
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$expected = $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
|
|
|
|
|
$this->assertEquals($expected, $this->template->getBackground());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetLogoDefault() {
|
|
|
|
|
$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-07 15:51:05 +03:00
|
|
|
|
$this->appData
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getFolder')
|
|
|
|
|
->with('images')
|
|
|
|
|
->willThrowException(new \Exception());
|
2017-04-09 04:48:57 +03:00
|
|
|
|
$expected = $this->urlGenerator->imagePath('core','logo.svg') . '?v=0';
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$this->assertEquals($expected, $this->template->getLogo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetLogoCustom() {
|
|
|
|
|
$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('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-07 15:51:05 +03:00
|
|
|
|
$simpleFolder = $this->createMock(ISimpleFolder::class);
|
|
|
|
|
$this->appData
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getFolder')
|
|
|
|
|
->with('images')
|
|
|
|
|
->willReturn($simpleFolder);
|
|
|
|
|
$simpleFolder
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getFile')
|
|
|
|
|
->with('logo')
|
|
|
|
|
->willReturn('');
|
2017-04-09 04:48:57 +03:00
|
|
|
|
$expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=0';
|
2016-08-23 23:02:28 +03:00
|
|
|
|
$this->assertEquals($expected, $this->template->getLogo());
|
|
|
|
|
}
|
2016-06-21 22:21:46 +03:00
|
|
|
|
}
|