aboutsummaryrefslogtreecommitdiffstats
path: root/tests/settings
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-12-13 08:50:15 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-13 08:50:15 +0100
commitefb495b09f220410defbbbd786ccddab4de609fd (patch)
tree36cae63f8a8f1d467782e810ef84bc1aba597411 /tests/settings
parent416e21d90292677f4b94d335544550a5af5e1e12 (diff)
parent76a633bf52647ab9ae44c5f53bc86fa02cb7d3a8 (diff)
downloadnextcloud-server-efb495b09f220410defbbbd786ccddab4de609fd.tar.gz
nextcloud-server-efb495b09f220410defbbbd786ccddab4de609fd.zip
Merge pull request #12726 from owncloud/add-filter-for-backend-to-rest-index
Add filter for backend to rest index
Diffstat (limited to 'tests/settings')
-rw-r--r--tests/settings/controller/userscontrollertest.php89
1 files changed, 86 insertions, 3 deletions
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index 26ca6f7e5f3..0ac6d3f0c01 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -126,9 +126,20 @@ class UsersControllerTest extends \Test\TestCase {
->method('getUserGroupIds')
->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users')));
$this->container['UserManager']
- ->expects($this->exactly(3))
+ ->expects($this->at(0))
+ ->method('get')
+ ->with('foo')
+ ->will($this->returnValue($foo));
+ $this->container['UserManager']
+ ->expects($this->at(1))
+ ->method('get')
+ ->with('admin')
+ ->will($this->returnValue($admin));
+ $this->container['UserManager']
+ ->expects($this->at(2))
->method('get')
- ->will($this->onConsecutiveCalls($foo, $admin, $bar));
+ ->with('bar')
+ ->will($this->returnValue($bar));
$this->container['Config']
->expects($this->exactly(3))
->method('getUserValue')
@@ -168,7 +179,79 @@ class UsersControllerTest extends \Test\TestCase {
),
)
);
- $response = $this->usersController->index(0, 10, 'pattern');
+ $response = $this->usersController->index(0, 10, 'gid', 'pattern');
+ $this->assertEquals($expectedResponse, $response);
+ }
+
+ public function testIndexWithBackend() {
+ $user = $this->getMockBuilder('\OC\User\User')
+ ->disableOriginalConstructor()->getMock();
+ $user
+ ->expects($this->exactly(3))
+ ->method('getUID')
+ ->will($this->returnValue('foo'));
+ $user
+ ->expects($this->once())
+ ->method('getDisplayName')
+ ->will($this->returnValue('M. Foo'));
+ $user
+ ->method('getLastLogin')
+ ->will($this->returnValue(500));
+ $user
+ ->method('getHome')
+ ->will($this->returnValue('/home/foo'));
+ $user
+ ->expects($this->once())
+ ->method('getBackendClassName')
+ ->will($this->returnValue('OC_User_Database'));
+ $this->container['UserManager']
+ ->expects($this->once())
+ ->method('getBackends')
+ ->will($this->returnValue([new \OC_User_Dummy(), new \OC_User_Database()]));
+ $this->container['UserManager']
+ ->expects($this->once())
+ ->method('clearBackends');
+ $this->container['UserManager']
+ ->expects($this->once())
+ ->method('registerBackend')
+ ->with(new \OC_User_Dummy());
+ $this->container['UserManager']
+ ->expects($this->once())
+ ->method('search')
+ ->with('')
+ ->will($this->returnValue([$user]));
+
+ $expectedResponse = new DataResponse(
+ array(
+ 0 => array(
+ 'name' => 'foo',
+ 'displayname' => 'M. Foo',
+ 'groups' => null,
+ 'subadmin' => array(),
+ 'quota' => null,
+ 'storageLocation' => '/home/foo',
+ 'lastLogin' => 500,
+ 'backend' => 'OC_User_Database'
+ )
+ )
+ );
+ $response = $this->usersController->index(0, 10, '','', 'OC_User_Dummy');
+ $this->assertEquals($expectedResponse, $response);
+ }
+
+ public function testIndexWithBackendNoUser() {
+ $this->container['UserManager']
+ ->expects($this->once())
+ ->method('getBackends')
+ ->will($this->returnValue([new \OC_User_Dummy(), new \OC_User_Database()]));
+ $this->container['UserManager']
+ ->expects($this->once())
+ ->method('search')
+ ->with('')
+ ->will($this->returnValue([]));
+
+ $expectedResponse = new DataResponse([]);
+ $response = $this->usersController->index(0, 10, '','', 'OC_User_Dummy');
$this->assertEquals($expectedResponse, $response);
}