Fix tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
24b58a7683
commit
fbeaacdf1b
|
@ -168,7 +168,7 @@ class UsersController extends OCSController {
|
|||
* @return DataResponse
|
||||
* @throws OCSException
|
||||
*/
|
||||
public function addUser(string $userid, string $password, $groups = null): DataResponse {
|
||||
public function addUser(string $userid, string $password, array $groups = []): DataResponse {
|
||||
$user = $this->userSession->getUser();
|
||||
$isAdmin = $this->groupManager->isAdmin($user->getUID());
|
||||
$subAdminManager = $this->groupManager->getSubAdmin();
|
||||
|
@ -178,7 +178,7 @@ class UsersController extends OCSController {
|
|||
throw new OCSException('User already exists', 102);
|
||||
}
|
||||
|
||||
if(is_array($groups)) {
|
||||
if($groups !== []) {
|
||||
foreach ($groups as $group) {
|
||||
if(!$this->groupManager->groupExists($group)) {
|
||||
throw new OCSException('group '.$group.' does not exist', 104);
|
||||
|
@ -197,12 +197,11 @@ class UsersController extends OCSController {
|
|||
$newUser = $this->userManager->createUser($userid, $password);
|
||||
$this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
|
||||
|
||||
if (is_array($groups)) {
|
||||
foreach ($groups as $group) {
|
||||
$this->groupManager->get($group)->addUser($newUser);
|
||||
$this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']);
|
||||
}
|
||||
foreach ($groups as $group) {
|
||||
$this->groupManager->get($group)->addUser($newUser);
|
||||
$this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']);
|
||||
}
|
||||
|
||||
return new DataResponse();
|
||||
} catch (HintException $e ) {
|
||||
$this->logger->logException($e, [
|
||||
|
|
|
@ -138,7 +138,7 @@ class AppConfigControllerTest extends TestCase {
|
|||
|
||||
public function dataGetValue() {
|
||||
return [
|
||||
['app1 ', null, null, null, new \InvalidArgumentException('error'), Http::STATUS_FORBIDDEN],
|
||||
['app1', 'key', 'default', null, new \InvalidArgumentException('error'), Http::STATUS_FORBIDDEN],
|
||||
['app2', 'key', 'default', 'return', null, Http::STATUS_OK],
|
||||
];
|
||||
}
|
||||
|
@ -186,8 +186,8 @@ class AppConfigControllerTest extends TestCase {
|
|||
|
||||
public function dataSetValue() {
|
||||
return [
|
||||
['app1 ', null, null, new \InvalidArgumentException('error1'), null, Http::STATUS_FORBIDDEN],
|
||||
['app2', 'key', null, null, new \InvalidArgumentException('error2'), Http::STATUS_FORBIDDEN],
|
||||
['app1', 'key', 'default', new \InvalidArgumentException('error1'), null, Http::STATUS_FORBIDDEN],
|
||||
['app2', 'key', 'default', null, new \InvalidArgumentException('error2'), Http::STATUS_FORBIDDEN],
|
||||
['app2', 'key', 'default', null, null, Http::STATUS_OK],
|
||||
];
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class AppConfigControllerTest extends TestCase {
|
|||
|
||||
public function dataDeleteValue() {
|
||||
return [
|
||||
['app1 ', null, new \InvalidArgumentException('error1'), null, Http::STATUS_FORBIDDEN],
|
||||
['app1', 'key', new \InvalidArgumentException('error1'), null, Http::STATUS_FORBIDDEN],
|
||||
['app2', 'key', null, new \InvalidArgumentException('error2'), Http::STATUS_FORBIDDEN],
|
||||
['app2', 'key', null, null, Http::STATUS_OK],
|
||||
];
|
||||
|
|
|
@ -242,7 +242,7 @@ class UsersControllerTest extends TestCase {
|
|||
->with('adminUser')
|
||||
->willReturn(true);
|
||||
|
||||
$this->api->addUser('AlreadyExistingUser', null, null);
|
||||
$this->api->addUser('AlreadyExistingUser', 'password', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -490,7 +490,7 @@ class UsersControllerTest extends TestCase {
|
|||
->with()
|
||||
->willReturn($subAdminManager);
|
||||
|
||||
$this->api->addUser('NewUser', 'PasswordOfTheNewUser', null);
|
||||
$this->api->addUser('NewUser', 'PasswordOfTheNewUser', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2128,7 +2128,7 @@ class UsersControllerTest extends TestCase {
|
|||
->method('getUser')
|
||||
->will($this->returnValue($loggedInUser));
|
||||
|
||||
$this->api->removeFromGroup('TargetUser', null);
|
||||
$this->api->removeFromGroup('TargetUser', '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2450,7 +2450,7 @@ class UsersControllerTest extends TestCase {
|
|||
->with('NotExistingUser')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->api->addSubAdmin('NotExistingUser', null);
|
||||
$this->api->addSubAdmin('NotExistingUser', '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue