aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests/Controller/UsersControllerTest.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-11-28 08:36:10 +0100
committerGitHub <noreply@github.com>2019-11-28 08:36:10 +0100
commit669302e570024c83140ff5c4f4b1489c5a1c66ed (patch)
tree010182798f5c83193554031753e063a8a0b35ca1 /apps/provisioning_api/tests/Controller/UsersControllerTest.php
parent125be68311a319f2b839e5aa4ea29cd642cd1e00 (diff)
parente3e782b63df4f1d65c86cb3b204b4bdecf93a6cd (diff)
downloadnextcloud-server-669302e570024c83140ff5c4f4b1489c5a1c66ed.tar.gz
nextcloud-server-669302e570024c83140ff5c4f4b1489c5a1c66ed.zip
Merge pull request #18064 from nextcloud/feature/php74
Add php7.4 support
Diffstat (limited to 'apps/provisioning_api/tests/Controller/UsersControllerTest.php')
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php418
1 files changed, 210 insertions, 208 deletions
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index e47db4fd51d..c4bfff6d69b 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -90,7 +90,7 @@ class UsersControllerTest extends TestCase {
/** @var RemoteWipe|MockObject */
private $remoteWipe;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
@@ -219,11 +219,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testAddUserAlreadyExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->userManager
->expects($this->once())
->method('userExists')
@@ -253,12 +253,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('AlreadyExistingUser', 'password', '', '', []);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- * @expectedExceptionMessage group NonExistingGroup does not exist
- */
+
public function testAddUserNonExistingGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('group NonExistingGroup does not exist');
+ $this->expectExceptionCode(104);
+
$this->userManager
->expects($this->once())
->method('userExists')
@@ -289,12 +289,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'pass', '', '', ['NonExistingGroup']);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- * @expectedExceptionMessage group NonExistingGroup does not exist
- */
+
public function testAddUserExistingGroupNonExistingGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('group NonExistingGroup does not exist');
+ $this->expectExceptionCode(104);
+
$this->userManager
->expects($this->once())
->method('userExists')
@@ -479,12 +479,12 @@ class UsersControllerTest extends TestCase {
));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 111
- * @expectedExceptionMessage Could not create non-existing user id
- */
+
public function testAddUserFailedToGenerateUserID() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Could not create non-existing user id');
+ $this->expectExceptionCode(111);
+
$this->config
->expects($this->any())
->method('getAppValue')
@@ -522,12 +522,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('', 'PasswordOfTheNewUser')->getData();
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 110
- * @expectedExceptionMessage Required email address was not provided
- */
+
public function testAddUserEmailRequired() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Required email address was not provided');
+ $this->expectExceptionCode(110);
+
$this->config
->expects($this->any())
->method('getAppValue')
@@ -629,12 +629,12 @@ class UsersControllerTest extends TestCase {
));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Bad request
- */
+
public function testAddUserUnsuccessful() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Bad request');
+ $this->expectExceptionCode(101);
+
$exception = new Exception('User backend not found.');
$this->userManager
->expects($this->once())
@@ -674,12 +674,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'PasswordOfTheNewUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 106
- * @expectedExceptionMessage no group specified (required for subadmins)
- */
+
public function testAddUserAsSubAdminNoGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('no group specified (required for subadmins)');
+ $this->expectExceptionCode(106);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -707,12 +707,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', []);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage insufficient privileges for group ExistingGroup
- */
+
public function testAddUserAsSubAdminValidGroupNotSubAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('insufficient privileges for group ExistingGroup');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -850,12 +850,12 @@ class UsersControllerTest extends TestCase {
));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 404
- * @expectedExceptionMessage User does not exist
- */
+
public function testGetUserTargetDoesNotExist() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(404);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1142,11 +1142,11 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testGetUserDataAsSubAdminAndUserIsNotAccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1376,11 +1376,11 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testEditUserRegularUserSelfEditChangeEmailInvalid() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1445,11 +1445,11 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testEditUserRegularUserSelfEditChangeQuota() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1510,12 +1510,12 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- * @expectedExceptionMessage Invalid quota value ABC
- */
+
public function testEditUserAdminUserSelfEditChangeInvalidQuota() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Invalid quota value ABC');
+ $this->expectExceptionCode(103);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1635,9 +1635,10 @@ class UsersControllerTest extends TestCase {
/**
* @dataProvider dataEditUserSelfEditChangeLanguageButForced
- * @expectedException \OCP\AppFramework\OCS\OCSException
*/
public function testEditUserSelfEditChangeLanguageButForced($forced) {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+
$this->config->expects($this->any())
->method('getSystemValue')
->willReturnMap([
@@ -1719,9 +1720,10 @@ class UsersControllerTest extends TestCase {
/**
* @dataProvider dataEditUserSelfEditChangeLanguageButForced
- * @expectedException \OCP\AppFramework\OCS\OCSException
*/
public function testEditUserAdminEditChangeLanguageInvalidLanguage() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+
$this->l10nFactory->expects($this->once())
->method('findAvailableLanguages')
@@ -1801,11 +1803,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testEditUserSubadminUserInaccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1841,11 +1843,11 @@ class UsersControllerTest extends TestCase {
$this->api->editUser('UserToEdit', 'quota', 'value');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUserNotExistingUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1864,11 +1866,11 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUserSelf() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1925,11 +1927,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUnsuccessfulUserAsAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2006,11 +2008,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUnsuccessfulUserAsSubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2054,11 +2056,11 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testDeleteUserAsSubAdminAndUserIsNotAccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2098,11 +2100,11 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 998
- */
+
public function testGetUsersGroupsTargetUserNotExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(998);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2235,11 +2237,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals(['groups' => ['Group1']], $this->api->getUsersGroups('UserToLookup')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
@@ -2284,11 +2286,11 @@ class UsersControllerTest extends TestCase {
$this->api->getUsersGroups('UserToLookup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testAddToGroupWithTargetGroupNotExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->groupManager->expects($this->once())
->method('get')
->with('GroupToAddTo')
@@ -2297,19 +2299,19 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser', 'GroupToAddTo');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testAddToGroupWithNoGroupSpecified() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$this->api->addToGroup('TargetUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- */
+
public function testAddToGroupWithTargetUserNotExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(103);
+
$targetGroup = $this->createMock(IGroup::class);
$this->groupManager->expects($this->once())
->method('get')
@@ -2319,11 +2321,11 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser', 'GroupToAddTo');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- */
+
public function testAddToGroupNoSubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(104);
+
$targetUser = $this->createMock(IUser::class);
$loggedInUser = $this->createMock(IUser::class);
$loggedInUser->expects($this->once())
@@ -2453,11 +2455,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals(new DataResponse(), $this->api->addToGroup('TargetUser', 'GroupToAddTo'));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testRemoveFromGroupWithNoTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2467,11 +2469,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', '');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testRemoveFromGroupWithEmptyTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2481,11 +2483,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', '');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testRemoveFromGroupWithNotExistingTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2500,11 +2502,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- */
+
public function testRemoveFromGroupWithNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(103);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userSession
@@ -2525,11 +2527,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- */
+
public function testRemoveFromGroupWithoutPermission() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(104);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
@@ -2566,12 +2568,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage Cannot remove yourself from the admin group
- */
+
public function testRemoveFromGroupAsAdminFromAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Cannot remove yourself from the admin group');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2616,12 +2618,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('Admin', 'admin');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage Cannot remove yourself from this group as you are a SubAdmin
- */
+
public function testRemoveFromGroupAsSubAdminFromSubAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Cannot remove yourself from this group as you are a SubAdmin');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2671,12 +2673,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('SubAdmin', 'subadmin');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage Not viable to remove user from the last group you are SubAdmin of
- */
+
public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Not viable to remove user from the last group you are SubAdmin of');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2774,12 +2776,12 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->removeFromGroup('AnotherUser', 'admin')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage User does not exist
- */
+
public function testAddSubAdminWithNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(101);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -2789,12 +2791,12 @@ class UsersControllerTest extends TestCase {
$this->api->addSubAdmin('NotExistingUser', '');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- * @expectedExceptionMessage Group does not exist
- */
+
public function testAddSubAdminWithNotExistingTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Group does not exist');
+ $this->expectExceptionCode(102);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userManager
@@ -2811,12 +2813,12 @@ class UsersControllerTest extends TestCase {
$this->api->addSubAdmin('ExistingUser', 'NotExistingGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- * @expectedExceptionMessage Cannot create subadmins for admin group
- */
+
public function testAddSubAdminToAdminGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Cannot create subadmins for admin group');
+ $this->expectExceptionCode(103);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
@@ -2898,12 +2900,12 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->addSubAdmin('ExistingUser', 'TargetGroup')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage User does not exist
- */
+
public function testRemoveSubAdminNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(101);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -2913,12 +2915,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeSubAdmin('NotExistingUser', 'GroupToDeleteFrom');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Group does not exist
- */
+
public function testRemoveSubAdminNotExistingTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Group does not exist');
+ $this->expectExceptionCode(101);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
@@ -2935,12 +2937,12 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- * @expectedExceptionMessage User is not a subadmin of this group
- */
+
public function testRemoveSubAdminFromNotASubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User is not a subadmin of this group');
+ $this->expectExceptionCode(102);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
@@ -3001,12 +3003,12 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->removeSubAdmin('ExistingUser', 'GroupToDeleteFrom')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 404
- * @expectedExceptionMessage User does not exist
- */
+
public function testGetUserSubAdminGroupsNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(404);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -3155,10 +3157,10 @@ class UsersControllerTest extends TestCase {
$this->assertSame($expected, $api->getCurrentUser()->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- */
+
public function testGetCurrentUserNotLoggedIn() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+
$this->userSession->expects($this->once())->method('getUser')
->willReturn(null);
@@ -3208,11 +3210,11 @@ class UsersControllerTest extends TestCase {
$this->assertSame($expected, $api->getUser('uid')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 998
- */
+
public function testResendWelcomeMessageWithNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(998);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -3222,11 +3224,11 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('NotExistingUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -3267,12 +3269,12 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Email address not available
- */
+
public function testResendWelcomeMessageNoEmail() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Email address not available');
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -3308,12 +3310,12 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Email address not available
- */
+
public function testResendWelcomeMessageNullEmail() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Email address not available');
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -3448,12 +3450,12 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- * @expectedExceptionMessage Sending email failed
- */
+
public function testResendWelcomeMessageFailed() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Sending email failed');
+ $this->expectExceptionCode(102);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();