From 62f1156a56a671cb593c0531922976914b1d4fa9 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 9 May 2018 15:52:41 +0200 Subject: allow to specify a link to a legal notice Signed-off-by: Arthur Schiwon --- apps/theming/tests/ThemingDefaultsTest.php | 71 +++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'apps/theming/tests') 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('Name – 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('Name', $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('Name – Slogan
Legal notice', $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('Name – Slogan', $this->template->getShortFooter()); + } + public function testgetColorPrimaryWithDefault() { $this->config ->expects($this->once()) -- cgit v1.2.3 From 850e2256f3dee5f94b407ea6b8d85fb84d170eb5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 11 May 2018 15:11:09 +0200 Subject: fix tests Signed-off-by: Arthur Schiwon --- apps/theming/tests/Controller/ThemingControllerTest.php | 2 ++ apps/theming/tests/Settings/AdminTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'apps/theming/tests') diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index dda881525f0..f2f14e44a02 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -814,6 +814,7 @@ class ThemingControllerTest extends TestCase { url: "", slogan: "", color: "#000", + imprintUrl: null, inverted: false, cacheBuster: null }; @@ -848,6 +849,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 @@ -81,6 +81,10 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('getBaseUrl') ->willReturn('https://example.com'); + $this->themingDefaults + ->expects($this->once()) + ->method('getImprintUrl') + ->willReturn(''); $this->themingDefaults ->expects($this->once()) ->method('getSlogan') @@ -105,6 +109,7 @@ class AdminTest extends TestCase { 'canThemeIcons' => null, 'iconDocs' => null, 'images' => [], + 'imprintUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); @@ -130,6 +135,10 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('getBaseUrl') ->willReturn('https://example.com'); + $this->themingDefaults + ->expects($this->once()) + ->method('getImprintUrl') + ->willReturn(''); $this->themingDefaults ->expects($this->once()) ->method('getSlogan') @@ -154,6 +163,7 @@ class AdminTest extends TestCase { 'canThemeIcons' => null, 'iconDocs' => '', 'images' => [], + 'imprintUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); -- cgit v1.2.3