diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-05-24 14:45:49 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-05-24 23:32:07 +0200 |
commit | 16c061818eceb2d5356030cfa620d256e7a8b284 (patch) | |
tree | 39fa6b40064eea212d62eae5eb482c6a89c36823 /apps/theming/tests | |
parent | eefe256abc377ca9e6d43682d50fadebfcfed966 (diff) | |
download | nextcloud-server-16c061818eceb2d5356030cfa620d256e7a8b284.tar.gz nextcloud-server-16c061818eceb2d5356030cfa620d256e7a8b284.zip |
also add a privacy link
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 2 | ||||
-rw-r--r-- | apps/theming/tests/Settings/AdminTest.php | 10 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 99 |
3 files changed, 100 insertions, 11 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index f196541d371..cd50061c59a 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -818,6 +818,7 @@ class ThemingControllerTest extends TestCase { slogan: "", color: "#000", imprintUrl: null, + privacyUrl: null, inverted: false, cacheBuster: null }; @@ -853,6 +854,7 @@ class ThemingControllerTest extends TestCase { slogan: "awesome", color: "#ffffff", imprintUrl: null, + privacyUrl: null, inverted: true, cacheBuster: null }; diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php index f7361677d77..5943866edc1 100644 --- a/apps/theming/tests/Settings/AdminTest.php +++ b/apps/theming/tests/Settings/AdminTest.php @@ -87,6 +87,10 @@ class AdminTest extends TestCase { ->willReturn(''); $this->themingDefaults ->expects($this->once()) + ->method('getPrivacyUrl') + ->willReturn(''); + $this->themingDefaults + ->expects($this->once()) ->method('getSlogan') ->willReturn('MySlogan'); $this->themingDefaults @@ -110,6 +114,7 @@ class AdminTest extends TestCase { 'iconDocs' => null, 'images' => [], 'imprintUrl' => '', + 'privacyUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); @@ -141,6 +146,10 @@ class AdminTest extends TestCase { ->willReturn(''); $this->themingDefaults ->expects($this->once()) + ->method('getPrivacyUrl') + ->willReturn(''); + $this->themingDefaults + ->expects($this->once()) ->method('getSlogan') ->willReturn('MySlogan'); $this->themingDefaults @@ -164,6 +173,7 @@ class AdminTest extends TestCase { 'iconDocs' => '', 'images' => [], 'imprintUrl' => '', + 'privacyUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index b454b21f840..2cd415d98df 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -195,16 +195,16 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals('https://example.com/', $this->template->getBaseUrl()); } - public function imprintUrlProvider() { + public function legalUrlProvider() { return [ [ '' ], - [ 'https://example.com/imprint.html'] + [ 'https://example.com/legal.html'] ]; } /** * @param $imprintUrl - * @dataProvider imprintUrlProvider + * @dataProvider legalUrlProvider */ public function testGetImprintURL($imprintUrl) { $this->config @@ -216,6 +216,20 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals($imprintUrl, $this->template->getImprintUrl()); } + /** + * @param $privacyUrl + * @dataProvider legalUrlProvider + */ + public function testGetPrivacyURL($privacyUrl) { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'privacyUrl', '') + ->willReturn($privacyUrl); + + $this->assertEquals($privacyUrl, $this->template->getPrivacyUrl()); + } + public function testGetSloganWithDefault() { $this->config ->expects($this->once()) @@ -238,13 +252,14 @@ class ThemingDefaultsTest extends TestCase { public function testGetShortFooter() { $this->config - ->expects($this->exactly(4)) + ->expects($this->exactly(5)) ->method('getAppValue') ->willReturnMap([ ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], ['theming', 'name', 'Nextcloud', 'Name'], ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], ['theming', 'imprintUrl', '', ''], + ['theming', 'privacyUrl', '', ''], ]); $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter()); @@ -252,13 +267,14 @@ class ThemingDefaultsTest extends TestCase { public function testGetShortFooterEmptySlogan() { $this->config - ->expects($this->exactly(4)) + ->expects($this->exactly(5)) ->method('getAppValue') ->willReturnMap([ ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], ['theming', 'name', 'Nextcloud', 'Name'], ['theming', 'slogan', $this->defaults->getSlogan(), ''], ['theming', 'imprintUrl', '', ''], + ['theming', 'privacyUrl', '', ''], ]); $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a>', $this->template->getShortFooter()); @@ -266,13 +282,14 @@ class ThemingDefaultsTest extends TestCase { public function testGetShortFooterImprint() { $this->config - ->expects($this->exactly(4)) + ->expects($this->exactly(5)) ->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'], + ['theming', 'privacyUrl', '', ''], ]); $this->l10n @@ -283,26 +300,86 @@ class ThemingDefaultsTest extends TestCase { $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() { + public function testGetShortFooterPrivacy() { + $this->config + ->expects($this->exactly(5)) + ->method('getAppValue') + ->willReturnMap([ + ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], + ['theming', 'name', 'Nextcloud', 'Name'], + ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], + ['theming', 'imprintUrl', '', ''], + ['theming', 'privacyUrl', '', 'https://example.com/privacy'], + ]); + + $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/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a>', $this->template->getShortFooter()); + } + + public function testGetShortFooterAllLegalLinks() { + $this->config + ->expects($this->exactly(5)) + ->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'], + ['theming', 'privacyUrl', '', 'https://example.com/privacy'], + ]); + + $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> · <a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a>', $this->template->getShortFooter()); + } + + public function invalidLegalUrlProvider() { return [ - ['example.com/imprint'], # missing scheme - ['https:///imprint'], # missing host + ['example.com/legal'], # missing scheme + ['https:///legal'], # missing host ]; } /** * @param $invalidImprintUrl - * @dataProvider invalidImprintUrlProvider + * @dataProvider invalidLegalUrlProvider */ public function testGetShortFooterInvalidImprint($invalidImprintUrl) { $this->config - ->expects($this->exactly(4)) + ->expects($this->exactly(5)) ->method('getAppValue') ->willReturnMap([ ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], ['theming', 'name', 'Nextcloud', 'Name'], ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], ['theming', 'imprintUrl', '', $invalidImprintUrl], + ['theming', 'privacyUrl', '', ''], + ]); + + $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter()); + } + + /** + * @param $invalidPrivacyUrl + * @dataProvider invalidLegalUrlProvider + */ + public function testGetShortFooterInvalidPrivacy($invalidPrivacyUrl) { + $this->config + ->expects($this->exactly(5)) + ->method('getAppValue') + ->willReturnMap([ + ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], + ['theming', 'name', 'Nextcloud', 'Name'], + ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], + ['theming', 'imprintUrl', '', ''], + ['theming', 'privacyUrl', '', $invalidPrivacyUrl], ]); $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter()); |