summaryrefslogtreecommitdiffstats
path: root/tests/settings/controller/userscontrollertest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/settings/controller/userscontrollertest.php')
-rw-r--r--tests/settings/controller/userscontrollertest.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index eb48babadc8..42d91c7731a 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -172,6 +172,62 @@ class UsersControllerTest extends \Test\TestCase {
$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);
+ }
+
/**
* TODO: Since the function uses the static OC_Subadmin class it can't be mocked
* to test for subadmins. Thus the test always assumes you have admin permissions...