aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/NavigationManagerTest.php
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-09-04 17:48:30 +0200
committerprovokateurin <kate@provokateurin.de>2024-09-09 11:04:36 +0200
commitd5e98cd190249906aa7547528b3e7123fb6cb94b (patch)
treed44477ca2d45a090e8452d21e0cb7d2fcf7b97eb /tests/lib/NavigationManagerTest.php
parent0a3093d05da92036684afb5814a4925b443468f7 (diff)
downloadnextcloud-server-d5e98cd190249906aa7547528b3e7123fb6cb94b.tar.gz
nextcloud-server-d5e98cd190249906aa7547528b3e7123fb6cb94b.zip
fix(NavigationManager): Skip invalid default navigation entries
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'tests/lib/NavigationManagerTest.php')
-rw-r--r--tests/lib/NavigationManagerTest.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php
index 416b4730147..27f14e97bb0 100644
--- a/tests/lib/NavigationManagerTest.php
+++ b/tests/lib/NavigationManagerTest.php
@@ -724,4 +724,61 @@ class NavigationManagerTest extends TestCase {
$this->assertEquals($expectedApp, $this->navigationManager->getDefaultEntryIdForUser(null, $withFallbacks));
}
+
+ public function testDefaultEntryUpdated() {
+ $this->appManager->method('getInstalledApps')->willReturn([]);
+
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')->willReturn('user1');
+
+ $this->userSession
+ ->method('getUser')
+ ->willReturn($user);
+
+ $this->config
+ ->method('getSystemValueString')
+ ->with('defaultapp', $this->anything())
+ ->willReturn('app4,app3,app2,app1');
+
+ $this->config
+ ->method('getUserValue')
+ ->willReturnMap([
+ ['user1', 'core', 'defaultapp', '', ''],
+ ['user1', 'core', 'apporder', '[]', ''],
+ ]);
+
+ $this->navigationManager->add([
+ 'id' => 'app1',
+ ]);
+
+ $this->assertEquals('app1', $this->navigationManager->getDefaultEntryIdForUser(null, false));
+ $this->assertEquals(true, $this->navigationManager->get('app1')['default']);
+
+ $this->navigationManager->add([
+ 'id' => 'app3',
+ ]);
+
+ $this->assertEquals('app3', $this->navigationManager->getDefaultEntryIdForUser(null, false));
+ $this->assertEquals(false, $this->navigationManager->get('app1')['default']);
+ $this->assertEquals(true, $this->navigationManager->get('app3')['default']);
+
+ $this->navigationManager->add([
+ 'id' => 'app2',
+ ]);
+
+ $this->assertEquals('app3', $this->navigationManager->getDefaultEntryIdForUser(null, false));
+ $this->assertEquals(false, $this->navigationManager->get('app1')['default']);
+ $this->assertEquals(false, $this->navigationManager->get('app2')['default']);
+ $this->assertEquals(true, $this->navigationManager->get('app3')['default']);
+
+ $this->navigationManager->add([
+ 'id' => 'app4',
+ ]);
+
+ $this->assertEquals('app4', $this->navigationManager->getDefaultEntryIdForUser(null, false));
+ $this->assertEquals(false, $this->navigationManager->get('app1')['default']);
+ $this->assertEquals(false, $this->navigationManager->get('app2')['default']);
+ $this->assertEquals(false, $this->navigationManager->get('app3')['default']);
+ $this->assertEquals(true, $this->navigationManager->get('app4')['default']);
+ }
}