aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests/Controller
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
commit3a7cf40aaa678bea1df143d2982d603b7a334eec (patch)
tree63c1e3ad7f7f401d14411a4d44c523632906afc9 /apps/provisioning_api/tests/Controller
parent0568b012672d650c6b5a49e72c4028dde5463c60 (diff)
downloadnextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz
nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/provisioning_api/tests/Controller')
-rw-r--r--apps/provisioning_api/tests/Controller/AppConfigControllerTest.php6
-rw-r--r--apps/provisioning_api/tests/Controller/AppsControllerTest.php16
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php62
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php416
4 files changed, 252 insertions, 248 deletions
diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
index b7d40a6caac..ecc7393ad8f 100644
--- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
@@ -332,10 +332,11 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyAppIdThrows
- * @expectedException \InvalidArgumentException
* @param string $app
*/
public function testVerifyAppIdThrows($app) {
+ $this->expectException(\InvalidArgumentException::class);
+
$api = $this->getInstance();
$this->invokePrivate($api, 'verifyAppId', [$app]);
}
@@ -377,12 +378,13 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyConfigKeyThrows
- * @expectedException \InvalidArgumentException
* @param string $app
* @param string $key
* @param string $value
*/
public function testVerifyConfigKeyThrows($app, $key, $value) {
+ $this->expectException(\InvalidArgumentException::class);
+
$api = $this->getInstance();
$this->invokePrivate($api, 'verifyConfigKey', [$app, $key, $value]);
}
diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
index 1056d3ba4c1..5cd440e4202 100644
--- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
@@ -72,11 +72,11 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase {
$this->assertEquals($expected, $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 998
- */
+
public function testGetAppInfoOnBadAppID() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(998);
+
$this->api->getAppInfo('not_provisioning_api');
}
@@ -109,11 +109,11 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase {
$this->assertEquals(count($disabled), count($data['apps']));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testGetAppsInvalidFilter() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$this->api->getApps('foo');
}
}
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 676b809169e..6204907f76e 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -284,11 +284,11 @@ class GroupsControllerTest extends \Test\TestCase {
$this->assertEquals(['users' => ['user1', 'user2']], $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 403
- */
+
public function testGetGroupAsIrrelevantSubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(403);
+
$group = $this->createGroup('group');
$otherGroup = $this->createGroup('otherGroup');
$this->asSubAdminOfGroup($otherGroup);
@@ -329,23 +329,23 @@ class GroupsControllerTest extends \Test\TestCase {
$this->assertEquals(['users' => ['user1', 'user2']], $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 404
- * @expectedExceptionMessage The requested group could not be found
- */
+
public function testGetGroupNonExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('The requested group could not be found');
+ $this->expectExceptionCode(404);
+
$this->asUser();
$this->api->getGroup($this->getUniqueID());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Group does not exist
- */
+
public function testGetSubAdminsOfGroupsNotExists() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Group does not exist');
+ $this->expectExceptionCode(101);
+
$this->api->getSubAdminsOfGroup('NonExistingGroup');
}
@@ -387,20 +387,20 @@ class GroupsControllerTest extends \Test\TestCase {
$this->assertEquals([], $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Invalid group name
- */
+
public function testAddGroupEmptyGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Invalid group name');
+ $this->expectExceptionCode(101);
+
$this->api->addGroup('');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testAddGroupExistingGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->groupManager
->method('groupExists')
->with('ExistingGroup')
@@ -437,19 +437,19 @@ class GroupsControllerTest extends \Test\TestCase {
$this->api->addGroup('Iñtërnâtiônàlizætiøn');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteGroupNonExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$this->api->deleteGroup('NonExistingGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testDeleteAdminGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->groupManager
->method('groupExists')
->with('admin')
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 0c4fcd5071c..c4bfff6d69b 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -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();