diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-01-24 14:07:52 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-01-24 14:23:18 +0100 |
commit | fee42647fb06b30cf35e2b21e2e8b5c8ef72bcc8 (patch) | |
tree | fc00cb2fe9fc579a7668d50b64ee164b95127e9b /apps/provisioning_api/tests | |
parent | 5d486478d3d6d316b1895ea440a05f31488e2f9f (diff) | |
download | nextcloud-server-fee42647fb06b30cf35e2b21e2e8b5c8ef72bcc8.tar.gz nextcloud-server-fee42647fb06b30cf35e2b21e2e8b5c8ef72bcc8.zip |
add data from the users profile to the provisioning api
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/provisioning_api/tests')
-rw-r--r-- | apps/provisioning_api/tests/Controller/UsersControllerTest.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 4d3da5fd33a..1565407b839 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -29,6 +29,7 @@ namespace OCA\Provisioning_API\Tests\Controller; +use OC\Accounts\AccountManager; use OCA\Provisioning_API\Controller\UsersController; use OCP\AppFramework\Http\DataResponse; use OCP\IGroup; @@ -41,7 +42,7 @@ use Test\TestCase as OriginalTest; use OCP\ILogger; class UsersControllerTest extends OriginalTest { - + /** @var IUserManager | PHPUnit_Framework_MockObject_MockObject */ protected $userManager; /** @var IConfig | PHPUnit_Framework_MockObject_MockObject */ @@ -54,6 +55,8 @@ class UsersControllerTest extends OriginalTest { protected $logger; /** @var UsersController | PHPUnit_Framework_MockObject_MockObject */ protected $api; + /** @var AccountManager | PHPUnit_Framework_MockObject_MockObject */ + protected $accountManager; protected function tearDown() { parent::tearDown(); @@ -80,6 +83,9 @@ class UsersControllerTest extends OriginalTest { $request = $this->getMockBuilder('OCP\IRequest') ->disableOriginalConstructor() ->getMock(); + $this->accountManager = $this->getMockBuilder(AccountManager::class) + ->disableOriginalConstructor() + ->getMock(); $this->api = $this->getMockBuilder('OCA\Provisioning_API\Controller\UsersController') ->setConstructorArgs([ 'provisioning_api', @@ -88,6 +94,7 @@ class UsersControllerTest extends OriginalTest { $this->config, $this->groupManager, $this->userSession, + $this->accountManager, $this->logger, ]) ->setMethods(['fillStorageInfo']) @@ -652,6 +659,16 @@ class UsersControllerTest extends OriginalTest { ->method('isAdmin') ->with('admin') ->will($this->returnValue(true)); + $this->accountManager->expects($this->any())->method('getUser') + ->with($targetUser) + ->willReturn( + [ + AccountManager::PROPERTY_ADDRESS => ['value' => 'address'], + AccountManager::PROPERTY_PHONE => ['value' => 'phone'], + AccountManager::PROPERTY_TWITTER => ['value' => 'twitter'], + AccountManager::PROPERTY_WEBSITE => ['value' => 'website'], + ] + ); $this->config ->expects($this->at(0)) ->method('getUserValue') @@ -672,6 +689,10 @@ class UsersControllerTest extends OriginalTest { 'quota' => ['DummyValue'], 'email' => 'demo@owncloud.org', 'displayname' => 'Demo User', + 'phone' => 'phone', + 'address' => 'address', + 'webpage' => 'website', + 'twitter' => 'twitter' ]; $this->assertEquals($expected, $this->api->getUser('UserToGet')->getData()); } @@ -731,12 +752,26 @@ class UsersControllerTest extends OriginalTest { ->expects($this->once()) ->method('getDisplayName') ->will($this->returnValue('Demo User')); + $this->accountManager->expects($this->any())->method('getUser') + ->with($targetUser) + ->willReturn( + [ + AccountManager::PROPERTY_ADDRESS => ['value' => 'address'], + AccountManager::PROPERTY_PHONE => ['value' => 'phone'], + AccountManager::PROPERTY_TWITTER => ['value' => 'twitter'], + AccountManager::PROPERTY_WEBSITE => ['value' => 'website'], + ] + ); $expected = [ 'enabled' => 'true', 'quota' => ['DummyValue'], 'email' => 'demo@owncloud.org', 'displayname' => 'Demo User', + 'phone' => 'phone', + 'address' => 'address', + 'webpage' => 'website', + 'twitter' => 'twitter' ]; $this->assertEquals($expected, $this->api->getUser('UserToGet')->getData()); } @@ -837,11 +872,25 @@ class UsersControllerTest extends OriginalTest { ->expects($this->once()) ->method('getEMailAddress') ->will($this->returnValue('subadmin@owncloud.org')); + $this->accountManager->expects($this->any())->method('getUser') + ->with($targetUser) + ->willReturn( + [ + AccountManager::PROPERTY_ADDRESS => ['value' => 'address'], + AccountManager::PROPERTY_PHONE => ['value' => 'phone'], + AccountManager::PROPERTY_TWITTER => ['value' => 'twitter'], + AccountManager::PROPERTY_WEBSITE => ['value' => 'website'], + ] + ); $expected = [ 'quota' => ['DummyValue'], 'email' => 'subadmin@owncloud.org', 'displayname' => 'Subadmin User', + 'phone' => 'phone', + 'address' => 'address', + 'webpage' => 'website', + 'twitter' => 'twitter' ]; $this->assertEquals($expected, $this->api->getUser('subadmin')->getData()); } |