summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-04-07 14:51:05 +0200
committerMorris Jobke <hey@morrisjobke.de>2017-04-07 12:03:47 -0500
commit281ad406e88d36c1492c7aefd8ef28762379f9e3 (patch)
tree91b81364f1a9244455657b86848025c628fd4089 /apps
parent1be75e8db8f583476f1cd03498afd608fce6408d (diff)
downloadnextcloud-server-281ad406e88d36c1492c7aefd8ef28762379f9e3.tar.gz
nextcloud-server-281ad406e88d36c1492c7aefd8ef28762379f9e3.zip
Add support for theming
Add support for theming in generated emails and simplify API Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps')
-rw-r--r--apps/provisioning_api/lib/AppInfo/Application.php16
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php34
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php238
-rw-r--r--apps/theming/lib/ThemingDefaults.php51
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php57
5 files changed, 163 insertions, 233 deletions
diff --git a/apps/provisioning_api/lib/AppInfo/Application.php b/apps/provisioning_api/lib/AppInfo/Application.php
index 2d6a82e2ff9..fd03fd41e16 100644
--- a/apps/provisioning_api/lib/AppInfo/Application.php
+++ b/apps/provisioning_api/lib/AppInfo/Application.php
@@ -3,8 +3,11 @@
namespace OCA\Provisioning_API\AppInfo;
use OC\AppFramework\Utility\SimpleContainer;
+use OC\AppFramework\Utility\TimeFactory;
+use OC\Settings\Mailer\NewUserMailHelper;
use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware;
use OCP\AppFramework\App;
+use OCP\Util;
class Application extends App {
public function __construct(array $urlParams = array()) {
@@ -13,6 +16,19 @@ class Application extends App {
$container = $this->getContainer();
$server = $container->getServer();
+ $container->registerService(NewUserMailHelper::class, function(SimpleContainer $c) use ($server) {
+ return new NewUserMailHelper(
+ $server->getThemingDefaults(),
+ $server->getURLGenerator(),
+ $server->getL10N('settings'),
+ $server->getMailer(),
+ $server->getSecureRandom(),
+ new TimeFactory(),
+ $server->getConfig(),
+ $server->getCrypto(),
+ Util::getDefaultEmailAddress('no-reply')
+ );
+ });
$container->registerService('ProvisioningApiMiddleware', function(SimpleContainer $c) use ($server) {
$user = $server->getUserManager()->get($c['UserId']);
$isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false;
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 9155d34276b..0ccbc978a69 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -30,6 +30,7 @@
namespace OCA\Provisioning_API\Controller;
use OC\Accounts\AccountManager;
+use OC\Settings\Mailer\NewUserMailHelper;
use \OC_Helper;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\TemplateResponse;
@@ -72,6 +73,8 @@ class UsersController extends OCSController {
private $defaults;
/** @var IFactory */
private $l10nFactory;
+ /** @var NewUserMailHelper */
+ private $newUserMailHelper;
/**
* @param string $appName
@@ -87,6 +90,7 @@ class UsersController extends OCSController {
* @param IMailer $mailer
* @param \OC_Defaults $defaults
* @param IFactory $l10nFactory
+ * @param NewUserMailHelper $newUserMailHelper
*/
public function __construct($appName,
IRequest $request,
@@ -100,7 +104,8 @@ class UsersController extends OCSController {
IURLGenerator $urlGenerator,
IMailer $mailer,
\OC_Defaults $defaults,
- IFactory $l10nFactory) {
+ IFactory $l10nFactory,
+ NewUserMailHelper $newUserMailHelper) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
@@ -114,6 +119,7 @@ class UsersController extends OCSController {
$this->mailer = $mailer;
$this->defaults = $defaults;
$this->l10nFactory = $l10nFactory;
+ $this->newUserMailHelper = $newUserMailHelper;
}
/**
@@ -786,30 +792,10 @@ class UsersController extends OCSController {
$l10n = $this->l10nFactory->get('settings', $lang);
- // data for the mail template
- $mailData = [
- 'username' => $username,
- 'url' => $this->urlGenerator->getAbsoluteURL('/')
- ];
-
- // FIXME: set users language in email
- $mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
- $mailContent = $mail->render();
-
- // FIXME: set users language in email
- $mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
- $plainTextMailContent = $mail->render();
-
- $subject = $l10n->t('Your %s account was created', [$this->defaults->getName()]);
-
try {
- $message = $this->mailer->createMessage();
- $message->setTo([$email => $username]);
- $message->setSubject($subject);
- $message->setHtmlBody($mailContent);
- $message->setPlainBody($plainTextMailContent);
- $message->setFrom([$this->fromMailAddress => $this->defaults->getName()]);
- $this->mailer->send($message);
+ $this->newUserMailHelper->setL10N($l10n);
+ $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false);
+ $this->newUserMailHelper->sendMail($targetUser, $emailTemplate);
} catch(\Exception $e) {
$this->logger->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings'));
throw new OCSException('Sending email failed', 102);
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index b5b63319d35..0cbcccebf6f 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -32,6 +32,8 @@ namespace OCA\Provisioning_API\Tests\Controller;
use Exception;
use OC\Accounts\AccountManager;
use OC\Group\Manager;
+use OC\Mail\IEMailTemplate;
+use OC\Settings\Mailer\NewUserMailHelper;
use OC\SubAdmin;
use OCA\Provisioning_API\Controller\UsersController;
use OCP\AppFramework\Http\DataResponse;
@@ -54,39 +56,30 @@ class UsersControllerTest extends TestCase {
/** @var IUserManager|PHPUnit_Framework_MockObject_MockObject */
protected $userManager;
-
/** @var IConfig|PHPUnit_Framework_MockObject_MockObject */
protected $config;
-
/** @var Manager|PHPUnit_Framework_MockObject_MockObject */
protected $groupManager;
-
/** @var IUserSession|PHPUnit_Framework_MockObject_MockObject */
protected $userSession;
-
/** @var ILogger|PHPUnit_Framework_MockObject_MockObject */
protected $logger;
-
/** @var UsersController|PHPUnit_Framework_MockObject_MockObject */
protected $api;
-
/** @var AccountManager|PHPUnit_Framework_MockObject_MockObject */
protected $accountManager;
-
/** @var IRequest|PHPUnit_Framework_MockObject_MockObject */
protected $request;
-
- /** @var IURLGenerator | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IURLGenerator|PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
-
- /** @var IMailer | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IMailer|PHPUnit_Framework_MockObject_MockObject */
private $mailer;
-
- /** @var \OC_Defaults | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OC_Defaults|PHPUnit_Framework_MockObject_MockObject */
private $defaults;
-
- /** @var IFactory | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IFactory|PHPUnit_Framework_MockObject_MockObject */
private $l10nFactory;
+ /** @var NewUserMailHelper|PHPUnit_Framework_MockObject_MockObject */
+ private $newUserMailHelper;
protected function setUp() {
parent::setUp();
@@ -102,6 +95,7 @@ class UsersControllerTest extends TestCase {
$this->mailer = $this->createMock(IMailer::class);
$this->defaults = $this->createMock(\OC_Defaults::class);
$this->l10nFactory = $this->createMock(IFactory::class);
+ $this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
$this->api = $this->getMockBuilder(UsersController::class)
->setConstructorArgs([
@@ -117,7 +111,8 @@ class UsersControllerTest extends TestCase {
$this->urlGenerator,
$this->mailer,
$this->defaults,
- $this->l10nFactory
+ $this->l10nFactory,
+ $this->newUserMailHelper
])
->setMethods(['fillStorageInfo'])
->getMock();
@@ -2621,7 +2616,8 @@ class UsersControllerTest extends TestCase {
$this->urlGenerator,
$this->mailer,
$this->defaults,
- $this->l10nFactory
+ $this->l10nFactory,
+ $this->newUserMailHelper
])
->setMethods(['getUserData'])
->getMock();
@@ -2684,7 +2680,8 @@ class UsersControllerTest extends TestCase {
$this->urlGenerator,
$this->mailer,
$this->defaults,
- $this->l10nFactory
+ $this->l10nFactory,
+ $this->newUserMailHelper
])
->setMethods(['getUserData'])
->getMock();
@@ -2884,56 +2881,6 @@ class UsersControllerTest extends TestCase {
->expects($this->once())
->method('getEmailAddress')
->will($this->returnValue('abc@example.org'));
- $message = $this->getMockBuilder('\OC\Mail\Message')
- ->disableOriginalConstructor()->getMock();
- $message
- ->expects($this->at(0))
- ->method('setTo')
- ->with(['abc@example.org' => 'user-id']);
- $message
- ->expects($this->at(1))
- ->method('setSubject')
- ->with('Your account was created');
- $htmlBody = new TemplateResponse(
- 'settings',
- 'email.new_user',
- [
- 'username' => 'user-id',
- 'url' => null,
- ],
- 'blank'
- );
- $message
- ->expects($this->at(2))
- ->method('setHtmlBody')
- ->with($htmlBody->render());
- $plainBody = new TemplateResponse(
- 'settings',
- 'email.new_user_plain_text',
- [
- 'username' => 'user-id',
- 'url' => null,
- ],
- 'blank'
- );
- $message
- ->expects($this->at(3))
- ->method('setPlainBody')
- ->with($plainBody->render());
- $message
- ->expects($this->at(4))
- ->method('setFrom')
- ->with(['test@example.org' => null]);
-
- $this->mailer
- ->expects($this->at(0))
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->at(1))
- ->method('send')
- ->with($message);
-
$this->config
->expects($this->at(0))
->method('getUserValue')
@@ -2942,11 +2889,6 @@ class UsersControllerTest extends TestCase {
$l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()
->getMock();
- $l10n
- ->expects($this->at(0))
- ->method('t')
- ->with('Your %s account was created', [null])
- ->willReturn('Your account was created');
$this->l10nFactory
->expects($this->at(0))
->method('languageExists')
@@ -2957,6 +2899,19 @@ class UsersControllerTest extends TestCase {
->method('get')
->with('settings', 'es')
->willReturn($l10n);
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $this->newUserMailHelper
+ ->expects($this->at(0))
+ ->method('setL10N')
+ ->willReturn($l10n);
+ $this->newUserMailHelper
+ ->expects($this->at(1))
+ ->method('generateTemplate')
+ ->willReturn($emailTemplate);
+ $this->newUserMailHelper
+ ->expects($this->at(2))
+ ->method('sendMail')
+ ->with($targetUser, $emailTemplate);
$this->api->resendWelcomeMessage('UserToGet');
}
@@ -2996,56 +2951,6 @@ class UsersControllerTest extends TestCase {
->expects($this->once())
->method('getEmailAddress')
->will($this->returnValue('abc@example.org'));
- $message = $this->getMockBuilder('\OC\Mail\Message')
- ->disableOriginalConstructor()->getMock();
- $message
- ->expects($this->at(0))
- ->method('setTo')
- ->with(['abc@example.org' => 'user-id']);
- $message
- ->expects($this->at(1))
- ->method('setSubject')
- ->with('Your account was created');
- $htmlBody = new TemplateResponse(
- 'settings',
- 'email.new_user',
- [
- 'username' => 'user-id',
- 'url' => null,
- ],
- 'blank'
- );
- $message
- ->expects($this->at(2))
- ->method('setHtmlBody')
- ->with($htmlBody->render());
- $plainBody = new TemplateResponse(
- 'settings',
- 'email.new_user_plain_text',
- [
- 'username' => 'user-id',
- 'url' => null,
- ],
- 'blank'
- );
- $message
- ->expects($this->at(3))
- ->method('setPlainBody')
- ->with($plainBody->render());
- $message
- ->expects($this->at(4))
- ->method('setFrom')
- ->with(['test@example.org' => null]);
-
- $this->mailer
- ->expects($this->at(0))
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->at(1))
- ->method('send')
- ->with($message);
-
$this->config
->expects($this->at(0))
->method('getUserValue')
@@ -3054,11 +2959,6 @@ class UsersControllerTest extends TestCase {
$l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()
->getMock();
- $l10n
- ->expects($this->at(0))
- ->method('t')
- ->with('Your %s account was created', [null])
- ->willReturn('Your account was created');
$this->l10nFactory
->expects($this->at(0))
->method('languageExists')
@@ -3069,6 +2969,19 @@ class UsersControllerTest extends TestCase {
->method('get')
->with('settings', 'en')
->willReturn($l10n);
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $this->newUserMailHelper
+ ->expects($this->at(0))
+ ->method('setL10N')
+ ->willReturn($l10n);
+ $this->newUserMailHelper
+ ->expects($this->at(1))
+ ->method('generateTemplate')
+ ->willReturn($emailTemplate);
+ $this->newUserMailHelper
+ ->expects($this->at(2))
+ ->method('sendMail')
+ ->with($targetUser, $emailTemplate);
$this->api->resendWelcomeMessage('UserToGet');
}
@@ -3113,56 +3026,6 @@ class UsersControllerTest extends TestCase {
->expects($this->once())
->method('getEmailAddress')
->will($this->returnValue('abc@example.org'));
- $message = $this->getMockBuilder('\OC\Mail\Message')
- ->disableOriginalConstructor()->getMock();
- $message
- ->expects($this->at(0))
- ->method('setTo')
- ->with(['abc@example.org' => 'user-id']);
- $message
- ->expects($this->at(1))
- ->method('setSubject')
- ->with('Your account was created');
- $htmlBody = new TemplateResponse(
- 'settings',
- 'email.new_user',
- [
- 'username' => 'user-id',
- 'url' => null,
- ],
- 'blank'
- );
- $message
- ->expects($this->at(2))
- ->method('setHtmlBody')
- ->with($htmlBody->render());
- $plainBody = new TemplateResponse(
- 'settings',
- 'email.new_user_plain_text',
- [
- 'username' => 'user-id',
- 'url' => null,
- ],
- 'blank'
- );
- $message
- ->expects($this->at(3))
- ->method('setPlainBody')
- ->with($plainBody->render());
- $message
- ->expects($this->at(4))
- ->method('setFrom')
- ->with(['test@example.org' => null]);
-
- $this->mailer
- ->expects($this->at(0))
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->at(1))
- ->method('send')
- ->will($this->throwException(new \Exception()));
-
$this->config
->expects($this->at(0))
->method('getUserValue')
@@ -3171,11 +3034,6 @@ class UsersControllerTest extends TestCase {
$l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()
->getMock();
- $l10n
- ->expects($this->at(0))
- ->method('t')
- ->with('Your %s account was created', [null])
- ->willReturn('Your account was created');
$this->l10nFactory
->expects($this->at(0))
->method('languageExists')
@@ -3186,6 +3044,20 @@ class UsersControllerTest extends TestCase {
->method('get')
->with('settings', 'es')
->willReturn($l10n);
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $this->newUserMailHelper
+ ->expects($this->at(0))
+ ->method('setL10N')
+ ->willReturn($l10n);
+ $this->newUserMailHelper
+ ->expects($this->at(1))
+ ->method('generateTemplate')
+ ->willReturn($emailTemplate);
+ $this->newUserMailHelper
+ ->expects($this->at(2))
+ ->method('sendMail')
+ ->with($targetUser, $emailTemplate)
+ ->willThrowException(new \Exception());
$this->api->resendWelcomeMessage('UserToGet');
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index 5a863b1eb22..d4dc56d3ba9 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
*
* @license GNU AGPL version 3 or any later version
*
@@ -19,15 +20,14 @@
*
*/
-
namespace OCA\Theming;
+use OCP\Files\IAppData;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
-use OCP\Files\IRootFolder;
use OCP\Util;
class ThemingDefaults extends \OC_Defaults {
@@ -38,8 +38,8 @@ class ThemingDefaults extends \OC_Defaults {
private $l;
/** @var IURLGenerator */
private $urlGenerator;
- /** @var IRootFolder */
- private $rootFolder;
+ /** @var IAppData */
+ private $appData;
/** @var ICacheFactory */
private $cacheFactory;
/** @var string */
@@ -58,21 +58,21 @@ class ThemingDefaults extends \OC_Defaults {
* @param IL10N $l
* @param IURLGenerator $urlGenerator
* @param \OC_Defaults $defaults
- * @param IRootFolder $rootFolder
+ * @param IAppData $appData
* @param ICacheFactory $cacheFactory
*/
public function __construct(IConfig $config,
IL10N $l,
IURLGenerator $urlGenerator,
\OC_Defaults $defaults,
- IRootFolder $rootFolder,
+ IAppData $appData,
ICacheFactory $cacheFactory
) {
parent::__construct();
$this->config = $config;
$this->l = $l;
$this->urlGenerator = $urlGenerator;
- $this->rootFolder = $rootFolder;
+ $this->appData = $appData;
$this->cacheFactory = $cacheFactory;
$this->name = $defaults->getName();
@@ -130,11 +130,19 @@ class ThemingDefaults extends \OC_Defaults {
*/
public function getLogo() {
$logo = $this->config->getAppValue('theming', 'logoMime');
- if(!$logo || !$this->rootFolder->nodeExists('/themedinstancelogo')) {
+
+ $logoExists = true;
+ try {
+ $this->appData->getFolder('images')->getFile('logo');
+ } catch (\Exception $e) {
+ $logoExists = false;
+ }
+
+ if(!$logo || !$logoExists) {
return $this->urlGenerator->imagePath('core','logo.svg');
- } else {
- return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
}
+
+ return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
}
/**
@@ -144,11 +152,19 @@ class ThemingDefaults extends \OC_Defaults {
*/
public function getBackground() {
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime');
- if(!$backgroundLogo || !$this->rootFolder->nodeExists('/themedbackgroundlogo')) {
+
+ $backgroundExists = true;
+ try {
+ $this->appData->getFolder('images')->getFile('background');
+ } catch (\Exception $e) {
+ $backgroundExists = false;
+ }
+
+ if(!$backgroundLogo || !$backgroundExists) {
return $this->urlGenerator->imagePath('core','background.jpg');
- } else {
- return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
}
+
+ return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
}
/**
@@ -175,6 +191,15 @@ class ThemingDefaults extends \OC_Defaults {
}
/**
+ * Gets the current cache buster count
+ *
+ * @return string
+ */
+ public function getCacheBusterCounter() {
+ return $this->config->getAppValue('theming', 'cachebuster', '0');
+ }
+
+ /**
* Increases the cache buster key
*/
private function increaseCacheBuster() {
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 72ccaa57d77..986b2f34267 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -24,37 +24,36 @@
namespace OCA\Theming\Tests;
use OCA\Theming\ThemingDefaults;
+use OCP\Files\IAppData;
+use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
-use OCP\Files\IRootFolder;
use Test\TestCase;
class ThemingDefaultsTest extends TestCase {
- /** @var IConfig */
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
- /** @var IL10N */
+ /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
private $l10n;
- /** @var IURLGenerator */
+ /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
- /** @var \OC_Defaults */
+ /** @var \OC_Defaults|\PHPUnit_Framework_MockObject_MockObject */
private $defaults;
+ /** @var IAppData|\PHPUnit_Framework_MockObject_MockObject */
+ private $appData;
+ /** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $cacheFactory;
/** @var ThemingDefaults */
private $template;
- /** @var IRootFolder */
- private $rootFolder;
- /** @var ICacheFactory */
- private $cacheFactory;
public function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
$this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock();
- $this->rootFolder = $this->getMockBuilder(IRootFolder::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->appData = $this->createMock(IAppData::class);
$this->cacheFactory = $this->getMockBuilder(ICacheFactory::class)->getMock();
$this->defaults = $this->getMockBuilder(\OC_Defaults::class)
->disableOriginalConstructor()
@@ -80,7 +79,7 @@ class ThemingDefaultsTest extends TestCase {
$this->l10n,
$this->urlGenerator,
$this->defaults,
- $this->rootFolder,
+ $this->appData,
$this->cacheFactory
);
}
@@ -386,6 +385,11 @@ class ThemingDefaultsTest extends TestCase {
->method('getAppValue')
->with('theming', 'backgroundMime')
->willReturn('');
+ $this->appData
+ ->expects($this->once())
+ ->method('getFolder')
+ ->with('images')
+ ->willThrowException(new \Exception());
$expected = $this->urlGenerator->imagePath('core','background.jpg');
$this->assertEquals($expected, $this->template->getBackground());
}
@@ -396,6 +400,17 @@ class ThemingDefaultsTest extends TestCase {
->method('getAppValue')
->with('theming', 'backgroundMime')
->willReturn('image/svg+xml');
+ $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('');
$expected = $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
$this->assertEquals($expected, $this->template->getBackground());
}
@@ -406,6 +421,11 @@ class ThemingDefaultsTest extends TestCase {
->method('getAppValue')
->with('theming', 'logoMime')
->willReturn('');
+ $this->appData
+ ->expects($this->once())
+ ->method('getFolder')
+ ->with('images')
+ ->willThrowException(new \Exception());
$expected = $this->urlGenerator->imagePath('core','logo.svg');
$this->assertEquals($expected, $this->template->getLogo());
}
@@ -416,6 +436,17 @@ class ThemingDefaultsTest extends TestCase {
->method('getAppValue')
->with('theming', 'logoMime')
->willReturn('image/svg+xml');
+ $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('');
$expected = $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
$this->assertEquals($expected, $this->template->getLogo());
}