summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-02-12 17:30:08 +0100
committerJulius Härtl <jus@bitgrid.net>2018-02-12 21:20:21 +0100
commit5a23b35ddbbefcb308915e3fb088e3beaf1f8be5 (patch)
tree4e7bf2ccc01e58424912aa505aca222493ca5ef2
parentada5aed35ee23048f7a02c9cd4e554600998124a (diff)
downloadnextcloud-server-5a23b35ddbbefcb308915e3fb088e3beaf1f8be5.tar.gz
nextcloud-server-5a23b35ddbbefcb308915e3fb088e3beaf1f8be5.zip
Also rewrite icon url
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--core/Controller/NavigationController.php3
-rw-r--r--tests/Core/Controller/NavigationControllerTest.php23
2 files changed, 22 insertions, 4 deletions
diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php
index 92f103c3a34..3521fac3b46 100644
--- a/core/Controller/NavigationController.php
+++ b/core/Controller/NavigationController.php
@@ -83,6 +83,9 @@ class NavigationController extends OCSController {
if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) {
$entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']);
}
+ if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) {
+ $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']);
+ }
}
return $navigation;
}
diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php
index 9b1d33ab868..1143ed003f0 100644
--- a/tests/Core/Controller/NavigationControllerTest.php
+++ b/tests/Core/Controller/NavigationControllerTest.php
@@ -68,22 +68,31 @@ class NavigationControllerTest extends TestCase {
$this->navigationManager->expects($this->once())
->method('getAll')
->with('link')
- ->willReturn([ ['id' => 'files', 'href' => '/index.php/apps/files'] ]);
+ ->willReturn([ ['id' => 'files', 'href' => '/index.php/apps/files', 'icon' => 'icon' ] ]);
if ($absolute) {
$this->urlGenerator->expects($this->any())
->method('getBaseURL')
->willReturn('http://localhost/');
- $this->urlGenerator->expects($this->once())
+ $this->urlGenerator->expects($this->at(1))
->method('getAbsoluteURL')
->with('/index.php/apps/files')
->willReturn('http://localhost/index.php/apps/files');
+ $this->urlGenerator->expects($this->at(3))
+ ->method('getAbsoluteURL')
+ ->with('icon')
+ ->willReturn('http://localhost/icon');
$actual = $this->controller->getAppsNavigation($absolute);
$this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals('http://localhost/index.php/apps/files', $actual->getData()[0]['href']);
+ $this->assertEquals('http://localhost/icon', $actual->getData()[0]['icon']);
+
+
} else {
$actual = $this->controller->getAppsNavigation($absolute);
$this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals('/index.php/apps/files', $actual->getData()[0]['href']);
+ $this->assertEquals('icon', $actual->getData()[0]['icon']);
+
}
}
@@ -92,22 +101,28 @@ class NavigationControllerTest extends TestCase {
$this->navigationManager->expects($this->once())
->method('getAll')
->with('settings')
- ->willReturn([ ['id' => 'settings', 'href' => '/index.php/settings/user'] ]);
+ ->willReturn([ ['id' => 'settings', 'href' => '/index.php/settings/user', 'icon' => '/core/img/settings.svg'] ]);
if ($absolute) {
$this->urlGenerator->expects($this->any())
->method('getBaseURL')
->willReturn('http://localhost/');
- $this->urlGenerator->expects($this->once())
+ $this->urlGenerator->expects($this->at(1))
->method('getAbsoluteURL')
->with('/index.php/settings/user')
->willReturn('http://localhost/index.php/settings/user');
+ $this->urlGenerator->expects($this->at(3))
+ ->method('getAbsoluteURL')
+ ->with('/core/img/settings.svg')
+ ->willReturn('http://localhost/core/img/settings.svg');
$actual = $this->controller->getSettingsNavigation($absolute);
$this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals('http://localhost/index.php/settings/user', $actual->getData()[0]['href']);
+ $this->assertEquals('http://localhost/core/img/settings.svg', $actual->getData()[0]['icon']);
} else {
$actual = $this->controller->getSettingsNavigation($absolute);
$this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals('/index.php/settings/user', $actual->getData()[0]['href']);
+ $this->assertEquals('/core/img/settings.svg', $actual->getData()[0]['icon']);
}
}