diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-05-09 15:52:41 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-05-09 15:52:41 +0200 |
commit | 62f1156a56a671cb593c0531922976914b1d4fa9 (patch) | |
tree | 7bc7e28895aee8e29bfc6d4ce7a19a1ee4bd64eb /apps/theming/tests | |
parent | 57ea4624741c36ed6e68f60c672ddddbfece628a (diff) | |
download | nextcloud-server-62f1156a56a671cb593c0531922976914b1d4fa9.tar.gz nextcloud-server-62f1156a56a671cb593c0531922976914b1d4fa9.zip |
allow to specify a link to a legal notice
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/theming/tests')
-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()) |