summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-18 20:27:43 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-20 14:57:20 +0100
commitaeb89947a2bddb1db10426538afaccdc141c059e (patch)
tree4cd9bada02f0c7d4c944d5b83160f2d8e2bf831b /tests
parentdd733d89256e0a2d1f7f4f96ac46b5a7bfbff984 (diff)
downloadnextcloud-server-aeb89947a2bddb1db10426538afaccdc141c059e.tar.gz
nextcloud-server-aeb89947a2bddb1db10426538afaccdc141c059e.zip
Introduce IUser::setEMailAddress and add hook mechanism
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/contacts/localadressbook.php6
-rw-r--r--tests/lib/user/user.php3
-rw-r--r--tests/settings/controller/userscontrollertest.php39
3 files changed, 21 insertions, 27 deletions
diff --git a/tests/lib/contacts/localadressbook.php b/tests/lib/contacts/localadressbook.php
index e5c43460835..ad3c088e3cd 100644
--- a/tests/lib/contacts/localadressbook.php
+++ b/tests/lib/contacts/localadressbook.php
@@ -47,6 +47,9 @@ class Test_LocalAddressBook extends \Test\TestCase
class SimpleUserForTesting implements IUser {
+ private $uid;
+ private $displayName;
+
public function __construct($uid, $displayName) {
$this->uid = $uid;
@@ -105,4 +108,7 @@ class SimpleUserForTesting implements IUser {
public function getCloudId() {
}
+
+ public function setEMailAddress($mailAddress) {
+ }
}
diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php
index 1f613edc4e6..a8d688d9c88 100644
--- a/tests/lib/user/user.php
+++ b/tests/lib/user/user.php
@@ -342,7 +342,8 @@ class User extends \Test\TestCase {
$backend->expects($this->once())
->method('setDisplayName')
- ->with('foo','Foo');
+ ->with('foo','Foo')
+ ->willReturn(true);
$user = new \OC\User\User('foo', $backend);
$this->assertTrue($user->setDisplayName('Foo'));
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index e1e3c4d4b6b..38fc1ee6102 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -1679,11 +1679,11 @@ class UsersControllerTest extends \Test\TestCase {
*/
public function setEmailAddressData() {
return [
- /* 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],
+ /* mailAddress, isValid, expectsUpdate, canChangeDisplayName, responseCode */
+ [ '', true, true, true, Http::STATUS_OK ],
+ [ 'foo@local', true, true, true, Http::STATUS_OK],
+ [ 'foo@bar@local', false, false, true, Http::STATUS_UNPROCESSABLE_ENTITY],
+ [ 'foo@local', true, false, false, Http::STATUS_FORBIDDEN],
];
}
@@ -1695,7 +1695,7 @@ class UsersControllerTest extends \Test\TestCase {
* @param bool $expectsUpdate
* @param bool $expectsDelete
*/
- public function testSetEmailAddress($mailAddress, $isValid, $expectsUpdate, $expectsDelete, $canChangeDisplayName, $responseCode) {
+ public function testSetEmailAddress($mailAddress, $isValid, $expectsUpdate, $canChangeDisplayName, $responseCode) {
$this->container['IsAdmin'] = true;
$user = $this->getMockBuilder('\OC\User\User')
@@ -1708,6 +1708,13 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->any())
->method('canChangeDisplayName')
->will($this->returnValue($canChangeDisplayName));
+ $user
+ ->expects($expectsUpdate ? $this->once() : $this->never())
+ ->method('setEMailAddress')
+ ->with(
+ $this->equalTo($mailAddress)
+ );
+
$this->container['UserSession']
->expects($this->atLeastOnce())
->method('getUser')
@@ -1730,26 +1737,6 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue($user));
}
- $this->container['Config']
- ->expects(($expectsUpdate) ? $this->once() : $this->never())
- ->method('setUserValue')
- ->with(
- $this->equalTo($user->getUID()),
- $this->equalTo('settings'),
- $this->equalTo('email'),
- $this->equalTo($mailAddress)
-
- );
- $this->container['Config']
- ->expects(($expectsDelete) ? $this->once() : $this->never())
- ->method('deleteUserValue')
- ->with(
- $this->equalTo($user->getUID()),
- $this->equalTo('settings'),
- $this->equalTo('email')
-
- );
-
$response = $this->container['UsersController']->setMailAddress($user->getUID(), $mailAddress);
$this->assertSame($responseCode, $response->getStatus());