From 16c061818eceb2d5356030cfa620d256e7a8b284 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 24 May 2018 14:45:49 +0200 Subject: also add a privacy link Signed-off-by: Arthur Schiwon --- .../tests/Controller/ThemingControllerTest.php | 2 + apps/theming/tests/Settings/AdminTest.php | 10 +++ apps/theming/tests/ThemingDefaultsTest.php | 99 +++++++++++++++++++--- 3 files changed, 100 insertions(+), 11 deletions(-) (limited to 'apps/theming/tests') 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 @@ -85,6 +85,10 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('getImprintUrl') ->willReturn(''); + $this->themingDefaults + ->expects($this->once()) + ->method('getPrivacyUrl') + ->willReturn(''); $this->themingDefaults ->expects($this->once()) ->method('getSlogan') @@ -110,6 +114,7 @@ class AdminTest extends TestCase { 'iconDocs' => null, 'images' => [], 'imprintUrl' => '', + 'privacyUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); @@ -139,6 +144,10 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('getImprintUrl') ->willReturn(''); + $this->themingDefaults + ->expects($this->once()) + ->method('getPrivacyUrl') + ->willReturn(''); $this->themingDefaults ->expects($this->once()) ->method('getSlogan') @@ -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('Name – 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('Name', $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('Name – Slogan
Legal notice', $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('Name – Slogan
Privacy policy', $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('Name – Slogan
Legal notice · Privacy policy', $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('Name – 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('Name – Slogan', $this->template->getShortFooter()); -- cgit v1.2.3