aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/NavigationManagerTest.php
diff options
context:
space:
mode:
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']);
+ }
}