aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-05-17 21:16:03 +0200
committerGitHub <noreply@github.com>2018-05-17 21:16:03 +0200
commit9236c20a28dd9558d1577ebfd7c7ea9202ca70bb (patch)
treee6d84fdcbbde8af5bae264db7f58a5a833c7c78e /apps/theming/tests
parent8696651cfb0370bc6b1e4bcc70ffd4fa1d2b65bd (diff)
parentfeff9f5bd1f776ade18ec8e196553730ef408a54 (diff)
downloadnextcloud-server-9236c20a28dd9558d1577ebfd7c7ea9202ca70bb.tar.gz
nextcloud-server-9236c20a28dd9558d1577ebfd7c7ea9202ca70bb.zip
Merge pull request #9437 from nextcloud/feature/noid/imprint
allow to specify a link to a legal notice
Diffstat (limited to 'apps/theming/tests')
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php2
-rw-r--r--apps/theming/tests/Settings/AdminTest.php10
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php71
3 files changed, 81 insertions, 2 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index eddf5bc56dc..f196541d371 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -817,6 +817,7 @@ class ThemingControllerTest extends TestCase {
url: "",
slogan: "",
color: "#000",
+ imprintUrl: null,
inverted: false,
cacheBuster: null
};
@@ -851,6 +852,7 @@ class ThemingControllerTest extends TestCase {
url: "nextcloudurl",
slogan: "awesome",
color: "#ffffff",
+ imprintUrl: null,
inverted: true,
cacheBuster: null
};
diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php
index 4eac689fb3f..f7361677d77 100644
--- a/apps/theming/tests/Settings/AdminTest.php
+++ b/apps/theming/tests/Settings/AdminTest.php
@@ -83,6 +83,10 @@ class AdminTest extends TestCase {
->willReturn('https://example.com');
$this->themingDefaults
->expects($this->once())
+ ->method('getImprintUrl')
+ ->willReturn('');
+ $this->themingDefaults
+ ->expects($this->once())
->method('getSlogan')
->willReturn('MySlogan');
$this->themingDefaults
@@ -105,6 +109,7 @@ class AdminTest extends TestCase {
'canThemeIcons' => null,
'iconDocs' => null,
'images' => [],
+ 'imprintUrl' => '',
];
$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
@@ -132,6 +137,10 @@ class AdminTest extends TestCase {
->willReturn('https://example.com');
$this->themingDefaults
->expects($this->once())
+ ->method('getImprintUrl')
+ ->willReturn('');
+ $this->themingDefaults
+ ->expects($this->once())
->method('getSlogan')
->willReturn('MySlogan');
$this->themingDefaults
@@ -154,6 +163,7 @@ class AdminTest extends TestCase {
'canThemeIcons' => null,
'iconDocs' => '',
'images' => [],
+ 'imprintUrl' => '',
];
$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index c943af01c6c..b454b21f840 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -195,6 +195,27 @@ class ThemingDefaultsTest extends TestCase {
$this->assertEquals('https://example.com/', $this->template->getBaseUrl());
}
+ public function imprintUrlProvider() {
+ return [
+ [ '' ],
+ [ 'https://example.com/imprint.html']
+ ];
+ }
+
+ /**
+ * @param $imprintUrl
+ * @dataProvider imprintUrlProvider
+ */
+ public function testGetImprintURL($imprintUrl) {
+ $this->config
+ ->expects($this->once())
+ ->method('getAppValue')
+ ->with('theming', 'imprintUrl', '')
+ ->willReturn($imprintUrl);
+
+ $this->assertEquals($imprintUrl, $this->template->getImprintUrl());
+ }
+
public function testGetSloganWithDefault() {
$this->config
->expects($this->once())
@@ -217,12 +238,13 @@ class ThemingDefaultsTest extends TestCase {
public function testGetShortFooter() {
$this->config
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('getAppValue')
->willReturnMap([
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
['theming', 'name', 'Nextcloud', 'Name'],
['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
+ ['theming', 'imprintUrl', '', ''],
]);
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter());
@@ -230,17 +252,62 @@ class ThemingDefaultsTest extends TestCase {
public function testGetShortFooterEmptySlogan() {
$this->config
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('getAppValue')
->willReturnMap([
['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
['theming', 'name', 'Nextcloud', 'Name'],
['theming', 'slogan', $this->defaults->getSlogan(), ''],
+ ['theming', 'imprintUrl', '', ''],
]);
$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a>', $this->template->getShortFooter());
}
+ public function testGetShortFooterImprint() {
+ $this->config
+ ->expects($this->exactly(4))
+ ->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'],
+ ]);
+
+ $this->l10n
+ ->expects($this->any())
+ ->method('t')
+ ->willReturnArgument(0);
+
+ $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan<br/><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a>', $this->template->getShortFooter());
+ }
+
+ public function invalidImprintUrlProvider() {
+ return [
+ ['example.com/imprint'], # missing scheme
+ ['https:///imprint'], # missing host
+ ];
+ }
+
+ /**
+ * @param $invalidImprintUrl
+ * @dataProvider invalidImprintUrlProvider
+ */
+ public function testGetShortFooterInvalidImprint($invalidImprintUrl) {
+ $this->config
+ ->expects($this->exactly(4))
+ ->method('getAppValue')
+ ->willReturnMap([
+ ['theming', 'url', $this->defaults->getBaseUrl(), 'url'],
+ ['theming', 'name', 'Nextcloud', 'Name'],
+ ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'],
+ ['theming', 'imprintUrl', '', $invalidImprintUrl],
+ ]);
+
+ $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter());
+ }
+
public function testgetColorPrimaryWithDefault() {
$this->config
->expects($this->once())