diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-22 13:07:26 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:59 +0100 |
commit | 01b4db62fbc4230cff953a2385d305b149744b86 (patch) | |
tree | 788b5edf5acba069bd6996466ab9b1b30a6804d4 /tests/lib/App | |
parent | 55ae7fa2a48ce38e2807a40632f282740c0e8117 (diff) | |
download | nextcloud-server-01b4db62fbc4230cff953a2385d305b149744b86.tar.gz nextcloud-server-01b4db62fbc4230cff953a2385d305b149744b86.zip |
Add dispatcher events to User and Group objects
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/App')
-rw-r--r-- | tests/lib/App/AppManagerTest.php | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 67188fae633..cb94ccf44d0 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -17,7 +17,9 @@ use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\ICache; use OCP\ICacheFactory; +use OCP\IGroup; use OCP\IGroupManager; +use OCP\IUser; use OCP\IUserSession; use OCP\IAppConfig; use OCP\IConfig; @@ -144,10 +146,14 @@ class AppManagerTest extends TestCase { } public function testEnableAppForGroups() { - $groups = array( - new Group('group1', array(), null), - new Group('group2', array(), null) - ); + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID') + ->willReturn('group1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID') + ->willReturn('group2'); + + $groups = [$group1, $group2]; $this->expectClearCache(); /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ @@ -187,10 +193,14 @@ class AppManagerTest extends TestCase { * @param array $appInfo */ public function testEnableAppForGroupsAllowedTypes(array $appInfo) { - $groups = array( - new Group('group1', array(), null), - new Group('group2', array(), null) - ); + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID') + ->willReturn('group1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID') + ->willReturn('group2'); + + $groups = [$group1, $group2]; $this->expectClearCache(); /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ @@ -237,10 +247,14 @@ class AppManagerTest extends TestCase { * @expectedExceptionMessage test can't be enabled for groups. */ public function testEnableAppForGroupsForbiddenTypes($type) { - $groups = array( - new Group('group1', array(), null), - new Group('group2', array(), null) - ); + $group1 = $this->createMock(IGroup::class); + $group1->method('getGID') + ->willReturn('group1'); + $group2 = $this->createMock(IGroup::class); + $group2->method('getGID') + ->willReturn('group2'); + + $groups = [$group1, $group2]; /** @var AppManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) @@ -284,10 +298,11 @@ class AppManagerTest extends TestCase { } private function newUser($uid) { - $config = $this->createMock(IConfig::class); - $urlgenerator = $this->createMock(IURLGenerator::class); + $user = $this->createMock(IUser::class); + $user->method('getUID') + ->willReturn($uid); - return new User($uid, null, null, $config, $urlgenerator); + return $user; } public function testIsEnabledForUserEnabled() { |