public function testIsGroupAdminIfAtLeastOneGroupHasResourceAdminRole() { $userId = 123; $expectedIsAdmin = true; $groups = array(new UserGroup(1, null, null, RoleLevel::APPLICATION_ADMIN), new UserGroup(3, null, null, RoleLevel::GROUP_ADMIN)); $user = new User(); $user->WithGroups($groups); $actualIsAdmin = $this->authorizationService->IsGroupAdministrator($user); $this->assertEquals($expectedIsAdmin, $actualIsAdmin); }
public function testIsGroupAdminForGroup() { $user = new User(); $user->WithOwnedGroups(array(new UserGroup(1, 'g1'), new UserGroup(2, 'g2'))); $user->WithGroups(array(new UserGroup(4, 'g4'), new UserGroup(5, 'g5'))); $this->assertTrue($user->IsGroupAdminFor(1)); $this->assertTrue($user->IsGroupAdminFor(2)); $this->assertFalse($user->IsGroupAdminFor(4)); $this->assertFalse($user->IsGroupAdminFor(5)); }