diff options
Diffstat (limited to 'apps/provisioning_api/tests/Controller')
-rw-r--r-- | apps/provisioning_api/tests/Controller/GroupsControllerTest.php | 31 | ||||
-rw-r--r-- | apps/provisioning_api/tests/Controller/UsersControllerTest.php | 27 |
2 files changed, 48 insertions, 10 deletions
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index cd3dae79336..352264c7afb 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -85,6 +85,10 @@ class GroupsControllerTest extends \Test\TestCase { $group ->method('getGID') ->willReturn($gid); + $group + ->method('getDisplayName') + ->willReturn($gid.'-name'); + return $group; } @@ -165,6 +169,33 @@ class GroupsControllerTest extends \Test\TestCase { $result = $this->api->getGroups($search, $limit, $offset); $this->assertEquals(['groups' => ['group1', 'group2']], $result->getData()); + + } + + /** + * @dataProvider dataGetGroups + * + * @param string|null $search + * @param int|null $limit + * @param int|null $offset + */ + public function testGetGroupsDetails($search, $limit, $offset) { + $groups = [$this->createGroup('group1'), $this->createGroup('group2')]; + + $search = $search === null ? '' : $search; + + $this->groupManager + ->expects($this->once()) + ->method('search') + ->with($search, $limit, $offset) + ->willReturn($groups); + + $result = $this->api->getGroupsDetails($search, $limit, $offset); + $this->assertEquals(['groups' => [ + Array('id' => 'group1', 'displayname' => 'group1-name'), + Array('id' => 'group2', 'displayname' => 'group2-name') + ]], $result->getData()); + } public function testGetGroupAsSubadmin() { diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 38e35988137..3f2cf3b1105 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -56,6 +56,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Mail\IMailer; +use OCP\Security\ISecureRandom; use PHPUnit_Framework_MockObject_MockObject; use Test\TestCase; @@ -85,6 +86,8 @@ class UsersControllerTest extends TestCase { private $newUserMailHelper; /** @var FederatedFileSharingFactory|\PHPUnit_Framework_MockObject_MockObject */ private $federatedFileSharingFactory; + /** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */ + private $secureRandom; protected function setUp() { parent::setUp(); @@ -100,6 +103,7 @@ class UsersControllerTest extends TestCase { $this->l10nFactory = $this->createMock(IFactory::class); $this->newUserMailHelper = $this->createMock(NewUserMailHelper::class); $this->federatedFileSharingFactory = $this->createMock(FederatedFileSharingFactory::class); + $this->secureRandom = $this->createMock(ISecureRandom::class); $this->api = $this->getMockBuilder(UsersController::class) ->setConstructorArgs([ @@ -114,7 +118,8 @@ class UsersControllerTest extends TestCase { $this->logger, $this->l10nFactory, $this->newUserMailHelper, - $this->federatedFileSharingFactory + $this->federatedFileSharingFactory, + $this->secureRandom ]) ->setMethods(['fillStorageInfo']) ->getMock(); @@ -242,7 +247,7 @@ class UsersControllerTest extends TestCase { ->with('adminUser') ->willReturn(true); - $this->api->addUser('AlreadyExistingUser', 'password', []); + $this->api->addUser('AlreadyExistingUser', 'password', '', []); } /** @@ -278,7 +283,7 @@ class UsersControllerTest extends TestCase { ->with('NonExistingGroup') ->willReturn(false); - $this->api->addUser('NewUser', 'pass', ['NonExistingGroup']); + $this->api->addUser('NewUser', 'pass', '', ['NonExistingGroup']); } /** @@ -320,7 +325,7 @@ class UsersControllerTest extends TestCase { ['NonExistingGroup', false] ])); - $this->api->addUser('NewUser', 'pass', ['ExistingGroup', 'NonExistingGroup']); + $this->api->addUser('NewUser', 'pass', '', ['ExistingGroup', 'NonExistingGroup']); } public function testAddUserSuccessful() { @@ -412,7 +417,7 @@ class UsersControllerTest extends TestCase { ['Added userid NewUser to group ExistingGroup', ['app' => 'ocs_api']] ); - $this->assertEquals([], $this->api->addUser('NewUser', 'PasswordOfTheNewUser', ['ExistingGroup'])->getData()); + $this->assertEquals([], $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', ['ExistingGroup'])->getData()); } /** @@ -490,7 +495,7 @@ class UsersControllerTest extends TestCase { ->with() ->willReturn($subAdminManager); - $this->api->addUser('NewUser', 'PasswordOfTheNewUser', []); + $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', []); } /** @@ -539,7 +544,7 @@ class UsersControllerTest extends TestCase { ->with('ExistingGroup') ->willReturn(true); - $this->api->addUser('NewUser', 'PasswordOfTheNewUser', ['ExistingGroup'])->getData(); + $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', ['ExistingGroup'])->getData(); } public function testAddUserAsSubAdminExistingGroups() { @@ -630,7 +635,7 @@ class UsersControllerTest extends TestCase { ) ->willReturn(true); - $this->assertEquals([], $this->api->addUser('NewUser', 'PasswordOfTheNewUser', ['ExistingGroup1', 'ExistingGroup2'])->getData()); + $this->assertEquals([], $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', ['ExistingGroup1', 'ExistingGroup2'])->getData()); } /** @@ -2928,7 +2933,8 @@ class UsersControllerTest extends TestCase { $this->logger, $this->l10nFactory, $this->newUserMailHelper, - $this->federatedFileSharingFactory + $this->federatedFileSharingFactory, + $this->secureRandom ]) ->setMethods(['getUserData']) ->getMock(); @@ -2990,7 +2996,8 @@ class UsersControllerTest extends TestCase { $this->logger, $this->l10nFactory, $this->newUserMailHelper, - $this->federatedFileSharingFactory + $this->federatedFileSharingFactory, + $this->secureRandom ]) ->setMethods(['getUserData']) ->getMock(); |