diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-05-17 22:16:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-17 22:16:03 +0300 |
commit | 9236c20a28dd9558d1577ebfd7c7ea9202ca70bb (patch) | |
tree | e6d84fdcbbde8af5bae264db7f58a5a833c7c78e /apps/theming/tests/ThemingDefaultsTest.php | |
parent | 8696651cfb0370bc6b1e4bcc70ffd4fa1d2b65bd (diff) | |
parent | feff9f5bd1f776ade18ec8e196553730ef408a54 (diff) |
Merge pull request #9437 from nextcloud/feature/noid/imprint
allow to specify a link to a legal notice
Diffstat (limited to 'apps/theming/tests/ThemingDefaultsTest.php')
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 71 |
1 files changed, 69 insertions, 2 deletions
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()) |