public function searchGuidForUid($uid)
{
$criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Uid', $uid
+ 'uid', $uid
);
return parent::searchRestrictKolab($criteria);
}
$criteria = new Horde_Kolab_Server_Query_Element_And(
array(
new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
+ 'objectBlass',
Horde_Kolab_Server_Object_Groupofnames::OBJECTCLASS_GROUPOFNAMES
),
$criteria
--- /dev/null
+<?php
+/**
+ * Test the search operations by uid.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/../../../../TestCase.php';
+
+/**
+ * Test the search operations by uid.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Search_Operation_GuidforuidTest
+extends Horde_Kolab_Server_TestCase
+{
+ public function setUp()
+ {
+ $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface');
+ }
+
+ public function testMethodRestrictkolabHasResultRestrictedToKolabUsers()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result_Interface');
+ $result->expects($this->once())
+ ->method('asArray')
+ ->will($this->returnValue(array('a' => 'a')));
+ $this->structure->expects($this->once())
+ ->method('find')
+ ->with(
+ $this->logicalAnd(
+ $this->isRestrictedToKolabUsers(),
+ $this->isSearchingByUid()
+ ),
+ array('attributes' => 'guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Guidforuid($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
+ $this->assertEquals(array('a'), $search->searchGuidForUid('test'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the search operations restricted to groups.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/../../../../TestCase.php';
+
+/**
+ * Test the search operations restricted to groups.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Search_Operation_RestrictgroupsTest
+extends Horde_Kolab_Server_TestCase
+{
+ public function setUp()
+ {
+ $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface');
+ }
+
+ public function testMethodSearchrestrictgroupsHasResultRestrictedToGroups()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result_Interface');
+ $result->expects($this->once())
+ ->method('asArray')
+ ->will($this->returnValue(array('a' => 'a')));
+ $this->structure->expects($this->once())
+ ->method('find')
+ ->with(
+ $this->isRestrictedToGroups(),
+ array('attributes' => 'guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Restrictgroups($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
+ $this->assertEquals(array('a'), $search->searchRestrictGroups($criteria));
+ }
+}
\ No newline at end of file
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../../../../Autoload.php';
+require_once dirname(__FILE__) . '/../../../../TestCase.php';
/**
* Test the search operations restricted to Kolab users.
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Class_Server_Search_Operation_RestrictkolabTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Server_TestCase
{
public function setUp()
{
$criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
$this->assertEquals(array('a'), $search->searchRestrictkolab($criteria));
}
-
- public function isRestrictedToKolabUsers()
- {
- return new Constraint_RestrictedToKolabUsers();
- }
-}
-
-class Constraint_RestrictedToKolabUsers extends PHPUnit_Framework_Constraint
-{
- public function evaluate($other)
- {
- if ($other instanceOf Horde_Kolab_Server_Query_Element_Interface) {
- if ($other instanceOf Horde_Kolab_Server_Query_Element_Group) {
- $elements = $other->getElements();
- foreach ($elements as $element) {
- if ($this->evaluate($element)) {
- return true;
- }
- }
- return true;
- } else {
- if ($other->getName() == 'objectClass'
- && $other->getValue() == Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON) {
- return true;
- } else {
- return false;
- }
- }
- } else {
- return false;
- }
- }
-
- public function fail($other, $description, $not = FALSE)
- {
- throw new PHPUnit_Framework_ExpectationFailedException(
- sprintf(
- '%sFailed asserting that %s contains a query element that restricts the search to Kolab users',
-
- !empty($description) ? $description . "\n" : '',
- PHPUnit_Util_Type::toString($other, TRUE)
- ),
- NULL
- );
- }
-
- public function toString()
- {
- return 'contains a query element that restricts the search to Kolab users';
- }
-}
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class Horde_Kolab_Server_Constraint_Restrictgroups extends PHPUnit_Framework_Constraint
+{
+ public function evaluate($other)
+ {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Interface) {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Group) {
+ $elements = $other->getElements();
+ foreach ($elements as $element) {
+ if ($this->evaluate($element)) {
+ return true;
+ }
+ }
+ return true;
+ } else {
+ if ($other->getName() == 'objectClass'
+ && $other->getValue() == Horde_Kolab_Server_Object_Groupofnames::OBJECTCLASS_GROUPOFNAMES) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public function fail($other, $description, $not = FALSE)
+ {
+ throw new PHPUnit_Framework_ExpectationFailedException(
+ sprintf(
+ '%sFailed asserting that %s contains a query element that restricts the search to groups',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that restricts the search to groups';
+ }
+}
--- /dev/null
+<?php
+
+class Horde_Kolab_Server_Constraint_Restrictedkolabusers extends PHPUnit_Framework_Constraint
+{
+ public function evaluate($other)
+ {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Interface) {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Group) {
+ $elements = $other->getElements();
+ foreach ($elements as $element) {
+ if ($this->evaluate($element)) {
+ return true;
+ }
+ }
+ return true;
+ } else {
+ if ($other->getName() == 'objectClass'
+ && $other->getValue() == Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public function fail($other, $description, $not = FALSE)
+ {
+ throw new PHPUnit_Framework_ExpectationFailedException(
+ sprintf(
+ '%sFailed asserting that %s contains a query element that restricts the search to Kolab users',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that restricts the search to Kolab users';
+ }
+}
--- /dev/null
+<?php
+
+class Horde_Kolab_Server_Constraint_Searchuid extends PHPUnit_Framework_Constraint
+{
+ public function evaluate($other)
+ {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Interface) {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Group) {
+ $elements = $other->getElements();
+ foreach ($elements as $element) {
+ if ($this->evaluate($element)) {
+ return true;
+ }
+ }
+ return true;
+ } else {
+ if ($other->getName() == 'uid') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public function fail($other, $description, $not = FALSE)
+ {
+ throw new PHPUnit_Framework_ExpectationFailedException(
+ sprintf(
+ '%sFailed asserting that %s contains a query element that is searching by uid',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that is searching by uid';
+ }
+}
*/
require_once dirname(__FILE__) . '/Autoload.php';
+require_once dirname(__FILE__) . '/Constraints/Restrictkolabusers.php';
+require_once dirname(__FILE__) . '/Constraints/Restrictgroups.php';
+require_once dirname(__FILE__) . '/Constraints/Searchuid.php';
+
/**
* Skip LDAP based tests if we don't have ldap or Net_LDAP2.
*
$this->getMock('Horde_Kolab_Server_Schema_Interface')
);
}
+
+ public function isRestrictedToGroups()
+ {
+ return new Horde_Kolab_Server_Constraint_Restrictgroups();
+ }
+
+ public function isRestrictedToKolabUsers()
+ {
+ return new Horde_Kolab_Server_Constraint_Restrictedkolabusers();
+ }
+
+ public function isSearchingByUid()
+ {
+ return new Horde_Kolab_Server_Constraint_Searchuid();
+ }
}
\ No newline at end of file