mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
Merge pull request #18345 from owncloud/increase-setMailAddress-tests
[tests] more tests for UserController::setMailAddress
This commit is contained in:
commit
47e05c97a2
1 changed files with 13 additions and 5 deletions
|
|
@ -1390,9 +1390,11 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
|
||||
public function setEmailAddressData() {
|
||||
return [
|
||||
['', true, false, true],
|
||||
['foobar@localhost', true, true, false],
|
||||
['foo@bar@localhost', false, false, false],
|
||||
/* mailAddress, isValid, expectsUpdate, expectsDelete, canChangeDisplayName, responseCode */
|
||||
[ '', true, false, true, true, Http::STATUS_OK ],
|
||||
[ 'foo@local', true, true, false, true, Http::STATUS_OK],
|
||||
[ 'foo@bar@local', false, false, false, true, Http::STATUS_UNPROCESSABLE_ENTITY],
|
||||
[ 'foo@local', true, false, false, false, Http::STATUS_FORBIDDEN],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -1404,7 +1406,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
* @param bool $expectsUpdate
|
||||
* @param bool $expectsDelete
|
||||
*/
|
||||
public function testSetEmailAddress($mailAddress, $isValid, $expectsUpdate, $expectsDelete) {
|
||||
public function testSetEmailAddress($mailAddress, $isValid, $expectsUpdate, $expectsDelete, $canChangeDisplayName, $responseCode) {
|
||||
$this->container['IsAdmin'] = true;
|
||||
|
||||
$user = $this->getMockBuilder('\OC\User\User')
|
||||
|
|
@ -1413,6 +1415,10 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
->expects($this->any())
|
||||
->method('getUID')
|
||||
->will($this->returnValue('foo'));
|
||||
$user
|
||||
->expects($this->any())
|
||||
->method('canChangeDisplayName')
|
||||
->will($this->returnValue($canChangeDisplayName));
|
||||
$this->container['UserSession']
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getUser')
|
||||
|
|
@ -1455,7 +1461,9 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
|
||||
);
|
||||
|
||||
$this->container['UsersController']->setMailAddress($user->getUID(), $mailAddress);
|
||||
$response = $this->container['UsersController']->setMailAddress($user->getUID(), $mailAddress);
|
||||
|
||||
$this->assertSame($responseCode, $response->getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue