diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-12-10 11:56:45 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-12-10 11:56:45 +0100 |
commit | 5398bbdc003a93f8652b7c7a88bc80e7710996c9 (patch) | |
tree | 17094823bcdeea09393f8f0d03ca1c28016dc8ca /tests | |
parent | dd4ef58297f5f87284177f579ef69a200112bb67 (diff) | |
parent | 7a290a3d6b779a624700ee3d264d3a87cb38b08b (diff) | |
download | nextcloud-server-5398bbdc003a93f8652b7c7a88bc80e7710996c9.tar.gz nextcloud-server-5398bbdc003a93f8652b7c7a88bc80e7710996c9.zip |
Merge pull request #12711 from owncloud/add-backend-to-rest-index
Expose backend type via REST API
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/contacts/localadressbook.php | 3 | ||||
-rw-r--r-- | tests/lib/user/user.php | 7 | ||||
-rw-r--r-- | tests/settings/controller/userscontrollertest.php | 115 |
3 files changed, 87 insertions, 38 deletions
diff --git a/tests/lib/contacts/localadressbook.php b/tests/lib/contacts/localadressbook.php index 5fa260ffc3b..a34d45bf3d0 100644 --- a/tests/lib/contacts/localadressbook.php +++ b/tests/lib/contacts/localadressbook.php @@ -78,6 +78,9 @@ class SimpleUserForTesting implements \OCP\IUser { public function getHome() { } + public function getBackendClassName() { + } + public function canChangeAvatar() { } diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php index a940d6eb627..e7085182fd6 100644 --- a/tests/lib/user/user.php +++ b/tests/lib/user/user.php @@ -215,6 +215,13 @@ class User extends \Test\TestCase { $this->assertEquals('/home/foo', $user->getHome()); } + public function testGetBackendClassName() { + $user = new \OC\User\User('foo', new \OC_User_Dummy()); + $this->assertEquals('OC_User_Dummy', $user->getBackendClassName()); + $user = new \OC\User\User('foo', new \OC_User_Database()); + $this->assertEquals('OC_User_Database', $user->getBackendClassName()); + } + public function testGetHomeNotSupported() { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php index 4b0683b6dae..eb48babadc8 100644 --- a/tests/settings/controller/userscontrollertest.php +++ b/tests/settings/controller/userscontrollertest.php @@ -54,30 +54,68 @@ class UsersControllerTest extends \Test\TestCase { * to test for subadmins. Thus the test always assumes you have admin permissions... */ public function testIndex() { - $admin = $this->getMockBuilder('\OC\User\User') - ->disableOriginalConstructor()->getMock(); - $admin - ->method('getLastLogin') - ->will($this->returnValue(12)); - $admin - ->method('getHome') - ->will($this->returnValue('/home/admin')); $foo = $this->getMockBuilder('\OC\User\User') ->disableOriginalConstructor()->getMock(); $foo + ->expects($this->exactly(3)) + ->method('getUID') + ->will($this->returnValue('foo')); + $foo + ->expects($this->once()) + ->method('getDisplayName') + ->will($this->returnValue('M. Foo')); + $foo ->method('getLastLogin') ->will($this->returnValue(500)); $foo ->method('getHome') ->will($this->returnValue('/home/foo')); + $foo + ->expects($this->once()) + ->method('getBackendClassName') + ->will($this->returnValue('OC_User_Database')); + $admin = $this->getMockBuilder('\OC\User\User') + ->disableOriginalConstructor()->getMock(); + $admin + ->expects($this->exactly(3)) + ->method('getUID') + ->will($this->returnValue('admin')); + $admin + ->expects($this->once()) + ->method('getDisplayName') + ->will($this->returnValue('S. Admin')); + $admin + ->expects($this->once()) + ->method('getLastLogin') + ->will($this->returnValue(12)); + $admin + ->expects($this->once()) + ->method('getHome') + ->will($this->returnValue('/home/admin')); + $admin + ->expects($this->once()) + ->method('getBackendClassName') + ->will($this->returnValue('OC_User_Dummy')); $bar = $this->getMockBuilder('\OC\User\User') ->disableOriginalConstructor()->getMock(); $bar + ->expects($this->exactly(3)) + ->method('getUID') + ->will($this->returnValue('bar')); + $bar + ->expects($this->once()) + ->method('getDisplayName') + ->will($this->returnValue('B. Ar')); + $bar ->method('getLastLogin') ->will($this->returnValue(3999)); $bar ->method('getHome') ->will($this->returnValue('/home/bar')); + $bar + ->expects($this->once()) + ->method('getBackendClassName') + ->will($this->returnValue('OC_User_Dummy')); $this->container['GroupManager'] ->expects($this->once()) @@ -98,36 +136,36 @@ class UsersControllerTest extends \Test\TestCase { $expectedResponse = new DataResponse( array( - 'status' => 'success', - 'data' => array( - 0 => array( - 'name' => 'foo', - 'displayname' => 'M. Foo', - 'groups' => array('Users', 'Support'), - 'subadmin' => array(), - 'quota' => 1024, - 'storageLocation' => '/home/foo', - 'lastLogin' => 500 - ), - 1 => array( - 'name' => 'admin', - 'displayname' => 'S. Admin', - 'groups' => array('admins', 'Support'), - 'subadmin' => array(), - 'quota' => 404, - 'storageLocation' => '/home/admin', - 'lastLogin' => 12 - ), - 2 => array( - 'name' => 'bar', - 'displayname' => 'B. Ar', - 'groups' => array('External Users'), - 'subadmin' => array(), - 'quota' => 2323, - 'storageLocation' => '/home/bar', - 'lastLogin' => 3999 - ), - ) + 0 => array( + 'name' => 'foo', + 'displayname' => 'M. Foo', + 'groups' => array('Users', 'Support'), + 'subadmin' => array(), + 'quota' => 1024, + 'storageLocation' => '/home/foo', + 'lastLogin' => 500, + 'backend' => 'OC_User_Database' + ), + 1 => array( + 'name' => 'admin', + 'displayname' => 'S. Admin', + 'groups' => array('admins', 'Support'), + 'subadmin' => array(), + 'quota' => 404, + 'storageLocation' => '/home/admin', + 'lastLogin' => 12, + 'backend' => 'OC_User_Dummy' + ), + 2 => array( + 'name' => 'bar', + 'displayname' => 'B. Ar', + 'groups' => array('External Users'), + 'subadmin' => array(), + 'quota' => 2323, + 'storageLocation' => '/home/bar', + 'lastLogin' => 3999, + 'backend' => 'OC_User_Dummy' + ), ) ); $response = $this->usersController->index(0, 10, 'pattern'); @@ -341,4 +379,5 @@ class UsersControllerTest extends \Test\TestCase { $response = $this->usersController->destroy('UserToDelete'); $this->assertEquals($expectedResponse, $response); } + } |