diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-08-17 11:53:03 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-08-17 11:53:03 +0200 |
commit | 15da671349727ab26449ca4cc4e3140b7b455a9a (patch) | |
tree | 7610e4b56afab70c856b165d6e5bf9816c8561f8 /tests/settings/controller/userscontrollertest.php | |
parent | f74416a0cb6bbb17ae646c952987e5eeea8390cf (diff) | |
download | nextcloud-server-15da671349727ab26449ca4cc4e3140b7b455a9a.tar.gz nextcloud-server-15da671349727ab26449ca4cc4e3140b7b455a9a.zip |
[test] more tests for UserController::setMailAddress
* fixes #12885
Diffstat (limited to 'tests/settings/controller/userscontrollertest.php')
-rw-r--r-- | tests/settings/controller/userscontrollertest.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php index 5f98cf21c04..06065a8454e 100644 --- a/tests/settings/controller/userscontrollertest.php +++ b/tests/settings/controller/userscontrollertest.php @@ -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()); } } |