Skip to content

Commit 5a23b35

Browse files
committed
Also rewrite icon url
Signed-off-by: Julius Härtl <[email protected]>
1 parent ada5aed commit 5a23b35

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

core/Controller/NavigationController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ private function rewriteToAbsoluteUrls(array $navigation): array {
8383
if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) {
8484
$entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']);
8585
}
86+
if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) {
87+
$entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']);
88+
}
8689
}
8790
return $navigation;
8891
}

tests/Core/Controller/NavigationControllerTest.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,31 @@ public function testGetAppNavigation($absolute) {
6868
$this->navigationManager->expects($this->once())
6969
->method('getAll')
7070
->with('link')
71-
->willReturn([ ['id' => 'files', 'href' => '/index.php/apps/files'] ]);
71+
->willReturn([ ['id' => 'files', 'href' => '/index.php/apps/files', 'icon' => 'icon' ] ]);
7272
if ($absolute) {
7373
$this->urlGenerator->expects($this->any())
7474
->method('getBaseURL')
7575
->willReturn('http://localhost/');
76-
$this->urlGenerator->expects($this->once())
76+
$this->urlGenerator->expects($this->at(1))
7777
->method('getAbsoluteURL')
7878
->with('/index.php/apps/files')
7979
->willReturn('http://localhost/index.php/apps/files');
80+
$this->urlGenerator->expects($this->at(3))
81+
->method('getAbsoluteURL')
82+
->with('icon')
83+
->willReturn('http://localhost/icon');
8084
$actual = $this->controller->getAppsNavigation($absolute);
8185
$this->assertInstanceOf(DataResponse::class, $actual);
8286
$this->assertEquals('http://localhost/index.php/apps/files', $actual->getData()[0]['href']);
87+
$this->assertEquals('http://localhost/icon', $actual->getData()[0]['icon']);
88+
89+
8390
} else {
8491
$actual = $this->controller->getAppsNavigation($absolute);
8592
$this->assertInstanceOf(DataResponse::class, $actual);
8693
$this->assertEquals('/index.php/apps/files', $actual->getData()[0]['href']);
94+
$this->assertEquals('icon', $actual->getData()[0]['icon']);
95+
8796
}
8897
}
8998

@@ -92,22 +101,28 @@ public function testGetSettingsNavigation($absolute) {
92101
$this->navigationManager->expects($this->once())
93102
->method('getAll')
94103
->with('settings')
95-
->willReturn([ ['id' => 'settings', 'href' => '/index.php/settings/user'] ]);
104+
->willReturn([ ['id' => 'settings', 'href' => '/index.php/settings/user', 'icon' => '/core/img/settings.svg'] ]);
96105
if ($absolute) {
97106
$this->urlGenerator->expects($this->any())
98107
->method('getBaseURL')
99108
->willReturn('http://localhost/');
100-
$this->urlGenerator->expects($this->once())
109+
$this->urlGenerator->expects($this->at(1))
101110
->method('getAbsoluteURL')
102111
->with('/index.php/settings/user')
103112
->willReturn('http://localhost/index.php/settings/user');
113+
$this->urlGenerator->expects($this->at(3))
114+
->method('getAbsoluteURL')
115+
->with('/core/img/settings.svg')
116+
->willReturn('http://localhost/core/img/settings.svg');
104117
$actual = $this->controller->getSettingsNavigation($absolute);
105118
$this->assertInstanceOf(DataResponse::class, $actual);
106119
$this->assertEquals('http://localhost/index.php/settings/user', $actual->getData()[0]['href']);
120+
$this->assertEquals('http://localhost/core/img/settings.svg', $actual->getData()[0]['icon']);
107121
} else {
108122
$actual = $this->controller->getSettingsNavigation($absolute);
109123
$this->assertInstanceOf(DataResponse::class, $actual);
110124
$this->assertEquals('/index.php/settings/user', $actual->getData()[0]['href']);
125+
$this->assertEquals('/core/img/settings.svg', $actual->getData()[0]['icon']);
111126
}
112127
}
113128

0 commit comments

Comments
 (0)