diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-02-02 14:47:29 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-02-16 15:15:35 +0100 |
commit | 2b58e8489fcb5eff0e2312209beca038bfe9b40a (patch) | |
tree | a86ba1a304e63e71f8a075a6401fa6449e0551be /tests | |
parent | 9c47ab91f2c27ced6b80ce44003809358da76ee2 (diff) | |
download | nextcloud-server-2b58e8489fcb5eff0e2312209beca038bfe9b40a.tar.gz nextcloud-server-2b58e8489fcb5eff0e2312209beca038bfe9b40a.zip |
Add getInstalledApps and getAppsForUser to the app manager
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/app/manager.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/app/manager.php b/tests/lib/app/manager.php index 4c0555b501f..4eaf4f08be9 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->getAppsEnabledForUser($user)); + } } |