diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-01 12:05:40 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-02 21:25:05 +0100 |
commit | eebe2b9c239a7f9e7e127f52ab4b9e97763b0149 (patch) | |
tree | 81d9d855b7b6e0d5fb387cd5e8c6092f17e21de3 /apps/provisioning_api | |
parent | df5872ec50a68de5d99bd6b5cf17ceb94f2ef833 (diff) | |
download | nextcloud-server-eebe2b9c239a7f9e7e127f52ab4b9e97763b0149.tar.gz nextcloud-server-eebe2b9c239a7f9e7e127f52ab4b9e97763b0149.zip |
User IUser::getEMailAddress() all over the place
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r-- | apps/provisioning_api/lib/users.php | 2 | ||||
-rw-r--r-- | apps/provisioning_api/tests/userstest.php | 55 |
2 files changed, 27 insertions, 30 deletions
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php index a2568425d0f..ad067b03cfd 100644 --- a/apps/provisioning_api/lib/users.php +++ b/apps/provisioning_api/lib/users.php @@ -199,7 +199,7 @@ class Users { // Find the data $data['quota'] = $this->fillStorageInfo($userId); - $data['email'] = $this->config->getUserValue($userId, 'settings', 'email'); + $data['email'] = $targetUserObject->getEMailAddress(); $data['displayname'] = $targetUserObject->getDisplayName(); return new OC_OCS_Result($data); diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php index 63180eb3472..72c76326ac5 100644 --- a/apps/provisioning_api/tests/userstest.php +++ b/apps/provisioning_api/tests/userstest.php @@ -27,26 +27,27 @@ namespace OCA\Provisioning_API\Tests; use OCA\Provisioning_API\Users; +use OCP\API; use OCP\IUserManager; use OCP\IConfig; -use OCP\IGroupManager; use OCP\IUserSession; +use PHPUnit_Framework_MockObject_MockObject; use Test\TestCase as OriginalTest; use OCP\ILogger; class UsersTest extends OriginalTest { - /** @var IUserManager */ + /** @var IUserManager | PHPUnit_Framework_MockObject_MockObject */ protected $userManager; - /** @var IConfig */ + /** @var IConfig | PHPUnit_Framework_MockObject_MockObject */ protected $config; - /** @var \OC\Group\Manager */ + /** @var \OC\Group\Manager | PHPUnit_Framework_MockObject_MockObject */ protected $groupManager; - /** @var IUserSession */ + /** @var IUserSession | PHPUnit_Framework_MockObject_MockObject */ protected $userSession; - /** @var ILogger */ + /** @var ILogger | PHPUnit_Framework_MockObject_MockObject */ protected $logger; - /** @var Users */ + /** @var Users | PHPUnit_Framework_MockObject_MockObject */ protected $api; protected function tearDown() { @@ -83,7 +84,7 @@ class UsersTest extends OriginalTest { ->method('getUser') ->will($this->returnValue(null)); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED); $this->assertEquals($expected, $this->api->getUsers()); } @@ -203,7 +204,7 @@ class UsersTest extends OriginalTest { ->method('getSubAdmin') ->will($this->returnValue($subAdminManager)); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED); $this->assertEquals($expected, $this->api->getUsers()); } @@ -464,7 +465,7 @@ class UsersTest extends OriginalTest { ->with() ->willReturn($subAdminManager); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED); $this->assertEquals($expected, $this->api->addUser()); } @@ -653,7 +654,7 @@ class UsersTest extends OriginalTest { ->method('getUser') ->will($this->returnValue(null)); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED); $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); } @@ -669,7 +670,7 @@ class UsersTest extends OriginalTest { ->with('UserToGet') ->will($this->returnValue(null)); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found'); + $expected = new \OC_OCS_Result(null, API::RESPOND_NOT_FOUND, 'The requested user could not be found'); $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); } @@ -680,6 +681,9 @@ class UsersTest extends OriginalTest { ->method('getUID') ->will($this->returnValue('admin')); $targetUser = $this->getMock('\OCP\IUser'); + $targetUser->expects($this->once()) + ->method('getEMailAddress') + ->willReturn('demo@owncloud.org'); $this->userSession ->expects($this->once()) ->method('getUser') @@ -704,11 +708,6 @@ class UsersTest extends OriginalTest { ->method('fillStorageInfo') ->with('UserToGet') ->will($this->returnValue(['DummyValue'])); - $this->config - ->expects($this->at(1)) - ->method('getUserValue') - ->with('UserToGet', 'settings', 'email') - ->will($this->returnValue('demo@owncloud.org')); $targetUser ->expects($this->once()) ->method('getDisplayName') @@ -732,6 +731,10 @@ class UsersTest extends OriginalTest { ->method('getUID') ->will($this->returnValue('subadmin')); $targetUser = $this->getMock('\OCP\IUser'); + $targetUser + ->expects($this->once()) + ->method('getEMailAddress') + ->willReturn('demo@owncloud.org'); $this->userSession ->expects($this->once()) ->method('getUser') @@ -768,11 +771,6 @@ class UsersTest extends OriginalTest { ->method('fillStorageInfo') ->with('UserToGet') ->will($this->returnValue(['DummyValue'])); - $this->config - ->expects($this->at(1)) - ->method('getUserValue') - ->with('UserToGet', 'settings', 'email') - ->will($this->returnValue('demo@owncloud.org')); $targetUser ->expects($this->once()) ->method('getDisplayName') @@ -823,7 +821,7 @@ class UsersTest extends OriginalTest { ->method('getSubAdmin') ->will($this->returnValue($subAdminManager)); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED); $this->assertEquals($expected, $this->api->getUser(['userid' => 'UserToGet'])); } @@ -865,15 +863,14 @@ class UsersTest extends OriginalTest { ->method('fillStorageInfo') ->with('subadmin') ->will($this->returnValue(['DummyValue'])); - $this->config - ->expects($this->once()) - ->method('getUserValue') - ->with('subadmin', 'settings', 'email') - ->will($this->returnValue('subadmin@owncloud.org')); $targetUser ->expects($this->once()) ->method('getDisplayName') ->will($this->returnValue('Subadmin User')); + $targetUser + ->expects($this->once()) + ->method('getEMailAddress') + ->will($this->returnValue('subadmin@owncloud.org')); $expected = new \OC_OCS_Result([ 'quota' => ['DummyValue'], @@ -889,7 +886,7 @@ class UsersTest extends OriginalTest { ->method('getUser') ->will($this->returnValue(null)); - $expected = new \OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); + $expected = new \OC_OCS_Result(null, API::RESPOND_UNAUTHORISED); $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit'])); } |