Skip to content

Commit 281ccd1

Browse files
committed
fixup! fixup! fixup! chore: use Event instead of early boot method for Navigation registration
1 parent 298945f commit 281ccd1

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

lib/private/NavigationManager.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,15 @@ private function proceedNavigation(array $list, string $type): array {
167167
/**
168168
* removes all the entries
169169
*/
170-
public function clear(bool $loadDefaultLinks = true): void {
170+
public function clear(bool $resetInit = true): void {
171171
$this->entries = [];
172172
$this->closureEntries = [];
173-
$this->init = !$loadDefaultLinks;
173+
174+
if ($resetInit) {
175+
$this->loadedAppInfo = [];
176+
$this->additionalEntriesLoaded = false;
177+
$this->init = false;
178+
}
174179
}
175180

176181
#[Override]

tests/lib/NavigationManagerTest.php

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ public function testAddClosure(array $entry, array $expectedEntry): void {
148148
global $testAddClosureNumberOfCalls;
149149
$testAddClosureNumberOfCalls = 0;
150150

151+
$this->appManager->expects($this->atLeastOnce())
152+
->method('isAppLoaded')
153+
->willReturnMap([
154+
['files', true],
155+
]);
156+
151157
$this->navigationManager->add(function () use ($entry) {
152158
global $testAddClosureNumberOfCalls;
153159
$testAddClosureNumberOfCalls++;
@@ -235,8 +241,10 @@ public function testWithAppManager($expected, $navigation, $isAdmin = false): vo
235241
->willReturn($navigation);
236242
$this->appManager->expects($this->any())
237243
->method('isAppLoaded')
238-
->with('test')
239-
->willReturn(true);
244+
->willReturnMap([
245+
['test', true],
246+
['files', true],
247+
]);
240248
$this->urlGenerator->expects($this->any())
241249
->method('imagePath')
242250
->willReturnCallback(function ($appName, $file) {
@@ -431,9 +439,20 @@ function (string $userId, string $appName, string $key, mixed $default = '') use
431439
->method('isEnabledForUser')
432440
->with('theming')
433441
->willReturn(true);
434-
$this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
435-
$this->appManager->expects($this->any())->method('isAppLoaded')->with('test')->willReturn(true);
436-
$this->appManager->expects($this->once())->method('getAppIcon')->with('test')->willReturn('/apps/test/img/app.svg');
442+
$this->appManager->expects($this->once())
443+
->method('getAppIcon')
444+
->with('test')
445+
->willReturn('/apps/test/img/app.svg');
446+
$this->appManager->expects($this->once())
447+
->method('getAppInfo')
448+
->with('test')
449+
->willReturn($navigation);
450+
$this->appManager->expects($this->atLeastOnce())
451+
->method('isAppLoaded')
452+
->willReturnMap([
453+
['test', true],
454+
['files', true],
455+
]);
437456
$this->l10nFac->expects($this->any())->method('get')->willReturn($l);
438457
$this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function ($appName, $file) {
439458
return "/apps/$appName/img/$file";
@@ -635,7 +654,13 @@ public function testGetDefaultEntryIdForUser(string $defaultApps, string $userDe
635654
];
636655
});
637656

638-
$this->appManager->method('getEnabledApps')->willReturn([]);
657+
$this->appManager->method('getEnabledApps')->willReturn(['files']);
658+
$this->appManager->expects($this->atLeastOnce())
659+
->method('isAppLoaded')
660+
->willReturnMap([
661+
['test', true],
662+
['files', true],
663+
]);
639664

640665
$user = $this->createMock(IUser::class);
641666
$user->method('getUID')->willReturn('user1');

0 commit comments

Comments
 (0)