aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/App
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-09-26 14:59:05 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-09-26 14:59:05 +0200
commit2d28e8110fd8a5b01d1d540f1d1cf42f117c3bab (patch)
tree5cc4b729838f572ed6d5aadc390590b4c861ef0b /tests/lib/App
parenta4a3d94f058864d188e4daaa300f834ba3cba380 (diff)
downloadnextcloud-server-2d28e8110fd8a5b01d1d540f1d1cf42f117c3bab.tar.gz
nextcloud-server-2d28e8110fd8a5b01d1d540f1d1cf42f117c3bab.zip
Fix and extend tests for AppManager::getDefaultAppForUser
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib/App')
-rw-r--r--tests/lib/App/AppManagerTest.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 3bf2195499f..73ac7b79909 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -607,21 +607,43 @@ class AppManagerTest extends TestCase {
// none specified, default to files
[
'',
+ '',
+ '{}',
'files',
],
// unexisting or inaccessible app specified, default to files
[
'unexist',
+ '',
+ '{}',
'files',
],
// non-standard app
[
'settings',
+ '',
+ '{}',
'settings',
],
// non-standard app with fallback
[
'unexist,settings',
+ '',
+ '{}',
+ 'settings',
+ ],
+ // user-customized defaultapp
+ [
+ 'unexist,settings',
+ 'files',
+ '{"settings":[1],"files":[2]}',
+ 'files',
+ ],
+ // user-customized apporder fallback
+ [
+ '',
+ '',
+ '{"settings":[1],"files":[2]}',
'settings',
],
];
@@ -630,7 +652,7 @@ class AppManagerTest extends TestCase {
/**
* @dataProvider provideDefaultApps
*/
- public function testGetDefaultAppForUser($defaultApps, $expectedApp) {
+ public function testGetDefaultAppForUser($defaultApps, $userDefaultApps, $userApporder, $expectedApp) {
$user = $this->newUser('user1');
$this->userSession->expects($this->once())
@@ -642,10 +664,12 @@ class AppManagerTest extends TestCase {
->with('defaultapp', $this->anything())
->willReturn($defaultApps);
- $this->config->expects($this->once())
+ $this->config->expects($this->atLeastOnce())
->method('getUserValue')
- ->with('user1', 'core', 'defaultapp')
- ->willReturn('');
+ ->willReturnMap([
+ ['user1', 'core', 'defaultapp', '', $userDefaultApps],
+ ['user1', 'core', 'apporder', '[]', $userApporder],
+ ]);
$this->assertEquals($expectedApp, $this->manager->getDefaultAppForUser());
}