summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-05-13 23:23:11 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-13 23:23:11 +0200
commit5fb94bf76f199a4dc713fe6e37e683d1d908e972 (patch)
tree7d2e456d6618c0674556ba8089b1a047df090f6f /tests
parent401bc60981f3a5da967ee7aa26662b46f0502aa0 (diff)
parent37ba6f503abfdd0f24ac515d1c71aa4a705a211f (diff)
downloadnextcloud-server-5fb94bf76f199a4dc713fe6e37e683d1d908e972.tar.gz
nextcloud-server-5fb94bf76f199a4dc713fe6e37e683d1d908e972.zip
Merge pull request #8542 from owncloud/phpdoc-improvements
PHPDoc Improvements
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/group/group.php28
-rw-r--r--tests/lib/group/manager.php27
2 files changed, 34 insertions, 21 deletions
diff --git a/tests/lib/group/group.php b/tests/lib/group/group.php
index 990f8ecc1d5..4d15999a826 100644
--- a/tests/lib/group/group.php
+++ b/tests/lib/group/group.php
@@ -17,9 +17,10 @@ class Group extends \PHPUnit_Framework_TestCase {
*/
protected function getUserManager() {
$userManager = $this->getMock('\OC\User\Manager');
- $user1 = new User('user1', null);
- $user2 = new User('user2', null);
- $user3 = new User('user3', null);
+ $backend = $this->getMock('\OC_User_Backend');
+ $user1 = new User('user1', $backend);
+ $user2 = new User('user2', $backend);
+ $user3 = new User('user3', $backend);
$userManager->expects($this->any())
->method('get')
->will($this->returnValueMap(array(
@@ -79,6 +80,7 @@ class Group extends \PHPUnit_Framework_TestCase {
public function testInGroupSingleBackend() {
$backend = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend), $userManager);
$backend->expects($this->once())
@@ -86,13 +88,14 @@ class Group extends \PHPUnit_Framework_TestCase {
->with('user1', 'group1')
->will($this->returnValue(true));
- $this->assertTrue($group->inGroup(new User('user1', null)));
+ $this->assertTrue($group->inGroup(new User('user1', $userBackend)));
}
public function testInGroupMultipleBackends() {
$backend1 = $this->getMock('OC_Group_Database');
$backend2 = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
$backend1->expects($this->once())
@@ -105,12 +108,13 @@ class Group extends \PHPUnit_Framework_TestCase {
->with('user1', 'group1')
->will($this->returnValue(true));
- $this->assertTrue($group->inGroup(new User('user1', null)));
+ $this->assertTrue($group->inGroup(new User('user1', $userBackend)));
}
public function testAddUser() {
$backend = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend), $userManager);
$backend->expects($this->once())
@@ -125,12 +129,13 @@ class Group extends \PHPUnit_Framework_TestCase {
->method('addToGroup')
->with('user1', 'group1');
- $group->addUser(new User('user1', null));
+ $group->addUser(new User('user1', $userBackend));
}
public function testAddUserAlreadyInGroup() {
$backend = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend), $userManager);
$backend->expects($this->once())
@@ -144,12 +149,13 @@ class Group extends \PHPUnit_Framework_TestCase {
$backend->expects($this->never())
->method('addToGroup');
- $group->addUser(new User('user1', null));
+ $group->addUser(new User('user1', $userBackend));
}
public function testRemoveUser() {
$backend = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend), $userManager);
$backend->expects($this->once())
@@ -164,12 +170,13 @@ class Group extends \PHPUnit_Framework_TestCase {
->method('removeFromGroup')
->with('user1', 'group1');
- $group->removeUser(new User('user1', null));
+ $group->removeUser(new User('user1', $userBackend));
}
public function testRemoveUserNotInGroup() {
$backend = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend), $userManager);
$backend->expects($this->once())
@@ -183,13 +190,14 @@ class Group extends \PHPUnit_Framework_TestCase {
$backend->expects($this->never())
->method('removeFromGroup');
- $group->removeUser(new User('user1', null));
+ $group->removeUser(new User('user1', $userBackend));
}
public function testRemoveUserMultipleBackends() {
$backend1 = $this->getMock('OC_Group_Database');
$backend2 = $this->getMock('OC_Group_Database');
$userManager = $this->getUserManager();
+ $userBackend = $this->getMock('\OC_User_Backend');
$group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager);
$backend1->expects($this->once())
@@ -216,7 +224,7 @@ class Group extends \PHPUnit_Framework_TestCase {
->method('removeFromGroup')
->with('user1', 'group1');
- $group->removeUser(new User('user1', null));
+ $group->removeUser(new User('user1', $userBackend));
}
public function testSearchUsers() {
diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php
index 9d1f175c109..061c9e7ea34 100644
--- a/tests/lib/group/manager.php
+++ b/tests/lib/group/manager.php
@@ -294,10 +294,11 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \OC\User\Manager $userManager
*/
$userManager = $this->getMock('\OC\User\Manager');
+ $userBackend = $this->getMock('\OC_User_Backend');
$manager = new \OC\Group\Manager($userManager);
$manager->addBackend($backend);
- $groups = $manager->getUserGroups(new User('user1', null));
+ $groups = $manager->getUserGroups(new User('user1', $userBackend));
$this->assertEquals(1, count($groups));
$group1 = $groups[0];
$this->assertEquals('group1', $group1->getGID());
@@ -332,11 +333,12 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \OC\User\Manager $userManager
*/
$userManager = $this->getMock('\OC\User\Manager');
+ $userBackend = $this->getMock('\OC_User_Backend');
$manager = new \OC\Group\Manager($userManager);
$manager->addBackend($backend1);
$manager->addBackend($backend2);
- $groups = $manager->getUserGroups(new User('user1', null));
+ $groups = $manager->getUserGroups(new User('user1', $userBackend));
$this->assertEquals(2, count($groups));
$group1 = $groups[0];
$group2 = $groups[1];
@@ -345,10 +347,12 @@ class Manager extends \PHPUnit_Framework_TestCase {
}
public function testDisplayNamesInGroupMultipleUserBackends() {
- $user1 = new User('user1', null);
- $user2 = new User('user2', null);
- $user3 = new User('user3', null);
- $user4 = new User('user33', null);
+ $userBackend = $this->getMock('\OC_User_Backend');
+
+ $user1 = new User('user1', $userBackend);
+ $user2 = new User('user2', $userBackend);
+ $user3 = new User('user3', $userBackend);
+ $user4 = new User('user33', $userBackend);
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend1
@@ -368,6 +372,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \OC\User\Manager $userManager
*/
$userManager = $this->getMock('\OC\User\Manager');
+ $userBackend = $this->getMock('\OC_User_Backend');
$userManager->expects($this->once())
->method('search')
->with('user3')
@@ -375,12 +380,12 @@ class Manager extends \PHPUnit_Framework_TestCase {
$userManager->expects($this->any())
->method('get')
- ->will($this->returnCallback(function($uid) {
+ ->will($this->returnCallback(function($uid) use ($userBackend) {
switch($uid) {
- case 'user1' : return new User('user1', null);
- case 'user2' : return new User('user2', null);
- case 'user3' : return new User('user3', null);
- case 'user33': return new User('user33', null);
+ case 'user1' : return new User('user1', $userBackend);
+ case 'user2' : return new User('user2', $userBackend);
+ case 'user3' : return new User('user3', $userBackend);
+ case 'user33': return new User('user33', $userBackend);
default:
return null;
}