public function searchGuidForAlias($alias)
{
$criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Alias', $alias
+ 'alias', $alias
);
return parent::searchRestrictKolab($criteria);
}
public function searchGuidForCn($cn)
{
$criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Cn', $cn
+ 'cn', $cn
);
return parent::searchGuid($criteria);
}
public function searchGuidForMail($mail)
{
$criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $mail
+ 'mail', $mail
);
return parent::searchRestrictKolab($criteria);
}
--- /dev/null
+<?php
+/**
+ * Test the search operations by alias.
+ *
+ * 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 alias.
+ *
+ * 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_GuidforaliasTest
+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->isSearchingByAlias()
+ ),
+ array('attributes' => 'guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Guidforalias($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
+ $this->assertEquals(array('a'), $search->searchGuidForAlias('test'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the search operations by cn.
+ *
+ * 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 cn.
+ *
+ * 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_GuidforcnTest
+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->isSearchingByCn(),
+ array('attributes' => 'guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Guidforcn($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
+ $this->assertEquals(array('a'), $search->searchGuidForCn('test'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the search operations by mail.
+ *
+ * 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 mail.
+ *
+ * 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_GuidformailTest
+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->isSearchingByMail()
+ ),
+ array('attributes' => 'guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Guidformail($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
+ $this->assertEquals(array('a'), $search->searchGuidForMail('test'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class Horde_Kolab_Server_Constraint_Searchalias 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() == 'alias') {
+ 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 alias',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that is searching by alias';
+ }
+}
--- /dev/null
+<?php
+
+class Horde_Kolab_Server_Constraint_Searchcn 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() == 'cn') {
+ 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 cn',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that is searching by cn';
+ }
+}
--- /dev/null
+<?php
+
+class Horde_Kolab_Server_Constraint_Searchmail 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() == 'mail') {
+ 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 mail',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that is searching by mail';
+ }
+}
require_once dirname(__FILE__) . '/Constraints/Restrictkolabusers.php';
require_once dirname(__FILE__) . '/Constraints/Restrictgroups.php';
require_once dirname(__FILE__) . '/Constraints/Searchuid.php';
+require_once dirname(__FILE__) . '/Constraints/Searchmail.php';
+require_once dirname(__FILE__) . '/Constraints/Searchcn.php';
+require_once dirname(__FILE__) . '/Constraints/Searchalias.php';
/**
* Skip LDAP based tests if we don't have ldap or Net_LDAP2.
{
return new Horde_Kolab_Server_Constraint_Searchuid();
}
+
+ public function isSearchingByMail()
+ {
+ return new Horde_Kolab_Server_Constraint_Searchmail();
+ }
+
+ public function isSearchingByCn()
+ {
+ return new Horde_Kolab_Server_Constraint_Searchcn();
+ }
+
+ public function isSearchingByAlias()
+ {
+ return new Horde_Kolab_Server_Constraint_Searchcn();
+ }
}
\ No newline at end of file