[Pkg-owncloud-commits] [owncloud] 22/32: test for group manager's displayNamesInGroup

David Prévot taffit at moszumanska.debian.org
Wed Apr 23 18:59:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 6aeb5996b63cd542bb75ce139700eee27d13a620
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Sat Mar 15 08:11:10 2014 +0100

    test for group manager's displayNamesInGroup
---
 tests/lib/group/manager.php | 50 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php
index 830eb1b..18be3eb 100644
--- a/tests/lib/group/manager.php
+++ b/tests/lib/group/manager.php
@@ -310,4 +310,54 @@ class Manager extends \PHPUnit_Framework_TestCase {
 		$this->assertEquals('group1', $group1->getGID());
 		$this->assertEquals('group2', $group2->getGID());
 	}
+
+	public function testDisplayNamesInGroupMultipleUserBackends() {
+		$user1 = new User('user1', null);
+		$user2 = new User('user2', null);
+		$user3 = new User('user3', null);
+		$user4 = new User('user33', null);
+
+		/**
+		 * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend1
+		 */
+		$backend = $this->getMock('\OC_Group_Database');
+		$backend->expects($this->exactly(2))
+			->method('groupExists')
+			->with('testgroup')
+			->will($this->returnValue(true));
+
+		$backend->expects($this->once())
+			->method('usersInGroup')
+			->with('testgroup', '', -1, 0)
+			->will($this->returnValue(array('user2', 'user33')));
+
+		/**
+		 * @var \OC\User\Manager $userManager
+		 */
+		$userManager = $this->getMock('\OC\User\Manager');
+		$userManager->expects($this->once())
+			->method('search')
+			->with('user3')
+			->will($this->returnValue(array('user3' => $user3, 'user33' => $user4)));
+
+		$userManager->expects($this->any())
+			->method('get')
+			->will($this->returnCallback(function($uid) {
+				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);
+					default:
+						return null;
+				}
+			}));
+
+		$manager = new \OC\Group\Manager($userManager);
+		$manager->addBackend($backend);
+
+		$users = $manager->displayNamesInGroup('testgroup', 'user3');
+		$this->assertEquals(1, count($users));
+		$this->assertTrue(isset($users['user33']));
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list