aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/app
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-02-23 16:03:32 +0100
committerVincent Petry <pvince81@owncloud.com>2015-02-23 16:03:32 +0100
commit4290e1990ec7d04a06298df9aad4c4fd8519f9aa (patch)
treedbb8c02e3f7a3d008b554931d8888f81dcb79b5c /tests/lib/app
parent81760321765272f638bf50487518860374ffb7f0 (diff)
parent5542fafd3696033ea8bfdcc441c05522cf6a5736 (diff)
downloadnextcloud-server-4290e1990ec7d04a06298df9aad4c4fd8519f9aa.tar.gz
nextcloud-server-4290e1990ec7d04a06298df9aad4c4fd8519f9aa.zip
Merge pull request #13829 from owncloud/appmanager-list
Better caching for enabled apps
Diffstat (limited to 'tests/lib/app')
-rw-r--r--tests/lib/app/manager.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/app/manager.php b/tests/lib/app/manager.php
index 4c0555b501f..cb41f737469 100644
--- a/tests/lib/app/manager.php
+++ b/tests/lib/app/manager.php
@@ -192,4 +192,36 @@ class Manager extends \PHPUnit_Framework_TestCase {
$appConfig->setValue('test', 'enabled', '["foo"]');
$this->assertTrue($manager->isEnabledForUser('test'));
}
+
+ public function testGetInstalledApps() {
+ $userSession = $this->getMock('\OCP\IUserSession');
+ $groupManager = $this->getMock('\OCP\IGroupManager');
+
+ $appConfig = $this->getAppConfig();
+ $manager = new \OC\App\AppManager($userSession, $appConfig, $groupManager);
+ $appConfig->setValue('test1', 'enabled', 'yes');
+ $appConfig->setValue('test2', 'enabled', 'no');
+ $appConfig->setValue('test3', 'enabled', '["foo"]');
+ $this->assertEquals(['test1', 'test3'], $manager->getInstalledApps());
+ }
+
+ public function testGetAppsForUser() {
+ $userSession = $this->getMock('\OCP\IUserSession');
+ $groupManager = $this->getMock('\OCP\IGroupManager');
+
+ $user = new User('user1', null);
+
+ $groupManager->expects($this->any())
+ ->method('getUserGroupIds')
+ ->with($user)
+ ->will($this->returnValue(array('foo', 'bar')));
+
+ $appConfig = $this->getAppConfig();
+ $manager = new \OC\App\AppManager($userSession, $appConfig, $groupManager);
+ $appConfig->setValue('test1', 'enabled', 'yes');
+ $appConfig->setValue('test2', 'enabled', 'no');
+ $appConfig->setValue('test3', 'enabled', '["foo"]');
+ $appConfig->setValue('test4', 'enabled', '["asd"]');
+ $this->assertEquals(['test1', 'test3'], $manager->getEnabledAppsForUser($user));
+ }
}