*/
public function getGuid()
{
- $this->_server->getGuid();
+ return $this->_server->getGuid();
}
/**
*/
public function getBaseGuid()
{
- $this->_server->getBaseGuid();
+ return $this->_server->getBaseGuid();
}
/**
*/
public function find($query, array $params = array())
{
- return $this->_server->find($criteria, $params);
+ return $this->_server->find($query, $params);
}
/**
*/
public function findBelow($query, $parent, array $params = array())
{
- return $this->_server->findBelow($criteria, $parent, $params);
+ return $this->_server->findBelow($query, $parent, $params);
}
/**
public function __construct(
Horde_Kolab_Server $server,
Horde_Kolab_Server_Objects $objects,
- Horde_Kolab_Server_Structure $structure,
- Horde_Kolab_Server_Search $search,
+ Horde_Kolab_Server_Structure_Interface $structure,
+ Horde_Kolab_Server_Search_Interface $search,
Horde_Kolab_Server_Schema $schema
) {
$this->_server = $server;
class Horde_Kolab_Server_Connection_Mock
implements Horde_Kolab_Server_Connection
{
-
- /**
- * The current database data.
- *
- * @var array
- */
- protected $data = array();
-
- /**
- * Indicates if we are bound.
- *
- * @var array
- */
- protected $bound;
-
- /**
- * Array holding the current result set.
- *
- * @var array
- */
- private $_result;
-
- /**
- * Buffer for error numbers.
- *
- * @var int
- */
- private $_errno = 0;
-
/**
- * Buffer for error descriptions.
+ * The LDAP connection handle.
*
- * @var int
+ * @var Net_LDAP2
*/
- private $_error = '';
+ private $_ldap;
/**
- * Attribute used for sorting.
+ * Constructor
*
- * @var string
+ * @param Net_LDAP2 $ldap The ldap connection.
*/
- private $_sort_by;
-
- /**
- * A result cache for iterating over the result.
- *
- * @var array
- */
- private $_current_result;
-
- /**
- * An index into the current result for iterating.
- *
- * @var int
- */
- private $_current_index;
-
- /**
- * Set configuration parameters.
- *
- * @param array $params The parameters.
- *
- * @return NULL
- */
- public function __construct(array $params)
+ public function __construct(Horde_Kolab_Server_Connection_Mock_Ldap $ldap)
{
- if (isset($params['data'])) {
- $this->data = $params['data'];
- }
-
- if (isset($this->params['admin'])
- && isset($this->params['admin']['type'])) {
- $type = $this->params['admin']['type'];
- $data = $this->params['admin'];
- unset($data['type']);
- $admin = new $type($this, null, $data);
- if (!$admin->exists()) {
- $admin->save();
- }
- }
+ $this->_ldap = $ldap;
}
/**
*/
public function getRead()
{
- return $this;
+ return $this->_ldap;
}
/**
*/
public function getWrite()
{
- return $this;
- }
-
- /**
- * Binds the LDAP connection with a specific user and pass.
- *
- * @param string $dn DN to bind with
- * @param string $pw Password associated to this DN.
- *
- * @return boolean Whether or not the binding succeeded.
- *
- * @throws Horde_Kolab_Server_Exception If the user does not exit, he has no
- * password, provided an incorrect
- * password or anonymous binding is not
- * allowed.
- */
- public function bind($dn = '', $pw = '')
- {
- if ($this->bound && empty($dn) && empty($pw)) {
- return true;
- }
-
- if (!$dn) {
- if (isset($this->params['uid'])) {
- $dn = $this->params['uid'];
- } else {
- $dn = '';
- }
- }
- if (!$pw) {
- if (isset($this->params['pass'])) {
- $pw = $this->params['pass'];
- }
- }
-
- if (!empty($dn)) {
- if (!isset($this->data[$dn])) {
- throw new Horde_Kolab_Server_Exception('User does not exist!');
- }
-
- $this->bound = true;
-
- try {
- $data = $this->read($dn, array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD));
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->bound = false;
- throw $e;
- }
- if (!isset($data[Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD])) {
- $this->bound = false;
- throw new Horde_Kolab_Server_Exception('User has no password entry!');
- }
- $this->bound = $data['userPassword'][0] == $pw;
- if (!$this->bound) {
- throw new Horde_Kolab_Server_Exception('Incorrect password!');
- }
- } else if (!empty($this->params['no_anonymous_bind'])) {
- $this->bound = false;
- throw new Horde_Kolab_Server_Exception('Anonymous bind is not allowed!');
- } else {
- $this->bound = true;
- }
-
- if ($this->bound) {
- $this->load();
- }
-
- return $this->bound;
- }
-
- /**
- * Get a specific entry based on the DN
- *
- * @param string $dn DN of the entry that should be fetched
- * @param array $attr Array of Attributes to select. If ommitted, all attributes are fetched.
- *
- * @return Net_LDAP2_Entry|Net_LDAP2_Error Reference to a Net_LDAP2_Entry object or Net_LDAP2_Error object
- * @todo Maybe check against the shema should be done to be sure the attribute type exists
- */
- public function getEntry($dn, $attr = array())
- {
- if (!is_array($attr)) {
- $attr = array($attr);
- }
- $result = $this->search($dn, '(objectClass=*)',
- array('scope' => 'base', 'attributes' => $attr));
- if ($result->count() == 0) {
- throw new Horde_Kolab_Server_Exception('Could not fetch entry '.$dn.': no entry found');
- }
- $entry = $result->shiftEntry();
- if (false == $entry) {
- throw new Horde_Kolab_Server_Exception('Could not fetch entry (error retrieving entry from search result)');
- }
- return $entry;
- }
-
- /**
- * Search for object data.
- *
- * @param string $base The search base
- * @param string $filter The LDAP search filter.
- * @param string $params Additional search parameters.
- *
- * @return array The result array.
- *
- * @throws Horde_Kolab_Server_Exception If the search operation encountered
- * a problem.
- */
- public function search($base = null, $filter = null, $params = array())
- {
- $this->bind();
-
- $filter = $this->parse($filter);
- if (isset($params['attributes'])) {
- $attributes = $params['attributes'];
- if (!is_array($attributes)) {
- $attributes = array($attributes);
- }
- } else {
- $attributes = array();
- }
-
- $result = $this->doSearch($filter, $attributes);
-
- if (empty($result)) {
- $search = new Horde_Kolab_Server_Connection_Mock_Search(array());
- return $search;
- }
-
- if (!empty($base)) {
- $subtree = array();
- foreach ($result as $entry) {
- if (strpos($entry['dn'], $base)) {
- $subtree[] = $entry;
- }
- }
- $result = $subtree;
- }
-
- $search = new Horde_Kolab_Server_Connection_Mock_Search($this->getEntries($result));
- return $search;
- }
-
- /**
- * Return the entries of a result.
- *
- * @param array $result The LDAP search result.
- *
- * @return mixed The entries of the result or false.
- */
- public function getEntries($result)
- {
- if (is_array($result)) {
- $data = array();
- foreach ($result as $entry) {
- $t = $entry['data'];
- $t['dn'] = $entry['dn'];
- $data[$entry['dn']] = $t;
- }
- return $data;
- }
- return false;
- }
-
- /**
- * Parse LDAP filter.
- * Partially derived from Net_LDAP_Filter.
- *
- * @param string $filter The filter string.
- *
- * @return array An array of the parsed filter.
- *
- * @throws Horde_Kolab_Server_Exception If parsing the filter expression
- * fails.
- */
- public function parse($filter)
- {
- $result = array();
- if (preg_match('/^\((.+?)\)$/', $filter, $matches)) {
- if (in_array(substr($matches[1], 0, 1), array('!', '|', '&'))) {
- $result['op'] = substr($matches[1], 0, 1);
- $result['sub'] = $this->parseSub(substr($matches[1], 1));
- return $result;
- } else {
- if (stristr($matches[1], ')(')) {
- throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - multiple leaf components detected!');
- } else {
- $filter_parts = preg_split('/(?<!\\\\)(=|=~|>|<|>=|<=)/',
- $matches[1], 2,
- PREG_SPLIT_DELIM_CAPTURE);
- if (count($filter_parts) != 3) {
- throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - unknown matching rule used');
- } else {
- $result['att'] = $filter_parts[0];
- $result['log'] = $filter_parts[1];
- $val = Net_LDAP2_Util::unescape_filter_value($filter_parts[2]);
- $result['val'] = $val[0];
- return $result;
- }
- }
- }
- } else {
- throw new Horde_Kolab_Server_Exception(sprintf("Filter parsing error: %s - filter components must be enclosed in round brackets",
- $filter));
- }
- }
-
- /**
- * Parse a LDAP subfilter.
- *
- * @param string $filter The subfilter string.
- *
- * @return array An array of the parsed subfilter.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function parseSub($filter)
- {
- $result = array();
- $level = 0;
- $collect = '';
- while (preg_match('/^(\(.+?\))(.*)/', $filter, $matches)) {
- if (in_array(substr($matches[1], 0, 2), array('(!', '(|', '(&'))) {
- $level++;
- }
- if ($level) {
- $collect .= $matches[1];
- if (substr($matches[2], 0, 1) == ')') {
- $collect .= ')';
- $matches[2] = substr($matches[2], 1);
- $level--;
- if (!$level) {
- $result[] = $this->parse($collect);
- }
- }
- } else {
- $result[] = $this->parse($matches[1]);
- }
- $filter = $matches[2];
- }
- return $result;
- }
-
- /**
- * Perform the search.
- *
- * @param array $filter Filter criteria-
- * @param array $attributes Restrict the search result to
- * these attributes.
- *
- * @return array A LDAP serach result.
- *
- * @throws Horde_Kolab_Server_Exception If the search operation is not
- * available.
- */
- public function doSearch($filter, $attributes = null)
- {
- if (isset($filter['log'])) {
- $result = array();
- foreach ($this->data as $element) {
- if (isset($element['data'][$filter['att']])) {
- switch ($filter['log']) {
- case '=':
- $value = $element['data'][$filter['att']];
- if (!empty($value) && is_array($value)) {
- $keys = array_keys($value);
- $first = $value[$keys[0]];
- } else {
- $first = $value;
- }
- if ((($filter['val'] == '*')
- && !empty($value))
- || $value == $filter['val']
- || (substr($filter['val'], 0, 1) == '*'
- && substr($filter['val'], strlen($filter['val']) - 1) == '*'
- && strpos($first, substr($filter['val'], 1, strlen($filter['val']) - 2)) !== false)
- || (is_array($value)
- && in_array($filter['val'], $value))) {
- if (empty($attributes)) {
- $result[] = $element;
- } else {
- $selection = $element;
- foreach ($element['data'] as $attr => $value) {
- if (!in_array($attr, $attributes)) {
- unset($selection['data'][$attr]);
- }
- }
- $result[] = $selection;
- }
- }
- break;
- default:
- throw new Horde_Kolab_Server_Exception("Not implemented!");
- }
- }
- }
- return $result;
- } else {
- $subresult = array();
- $filtercount = count($filter['sub']);
- foreach ($filter['sub'] as $subfilter) {
- $subresult = array_merge($subresult,
- $this->doSearch($subfilter,
- $attributes));
- }
- $result = array();
- $dns = array();
- foreach ($subresult as $element) {
- $dns[] = $element['dn'];
-
- $result[$element['dn']] = $element;
- }
- switch ($filter['op']) {
- case '&':
- $count = array_count_values($dns);
- $selection = array();
- foreach ($count as $dn => $value) {
- if ($value == $filtercount) {
- $selection[] = $result[$dn];
- }
- }
- return $selection;
- case '|':
- return array_values($result);
- case '!':
- $dns = array();
- foreach ($result as $entry) {
- if (!in_array($entry['dn'], $dns) ) {
- $dns[] = $entry['dn'];
- }
- }
- $all_dns = array_keys($this->data);
- $diff = array_diff($all_dns, $dns);
-
- $result = array();
- foreach ($diff as $dn) {
- if (empty($attributes)) {
- $result[] = $this->data[$dn];
- } else {
- $selection = $this->data[$dn];
- foreach ($this->data[$dn]['data']
- as $attr => $value) {
- if (!in_array($attr, $attributes)) {
- unset($selection['data'][$attr]);
- }
- }
- $result[] = $selection;
- }
- }
- return $result;
- default:
- throw new Horde_Kolab_Server_Exception("Not implemented!");
- }
- }
- }
-
- /**
- * Add a new entryobject to a directory.
- *
- * @param Net_LDAP2_Entry $entry Net_LDAP2_Entry
- *
- * @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
- */
- public function add($entry)
- {
- $this->bind();
-
- $ldap_data = $this->toStorage($entry->getValues());
-
- $guid = $entry->getDn();
-
- $this->data[$guid] = array(
- 'dn' => $guid,
- 'data' => array_merge($ldap_data,
- array('dn' => $guid)),
- );
-
- $this->store();
- }
-
- /**
- * Modify an ldapentry directly on the server
- *
- * @param string|Net_LDAP2_Entry &$entry DN-string or Net_LDAP2_Entry
- * @param array $parms Array of changes
- *
- * @access public
- * @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
- */
- public function modify($entry, $data = array())
- {
- $this->bind();
-
- $guid = $entry->getDn();
-
- if (isset($data['delete'])) {
- foreach ($data['delete'] as $k => $v) {
- if (is_int($k)) {
- if (isset($this->data[$guid]['data'][$w])) {
- /** Delete a complete attribute */
- unset($this->data[$guid]['data'][$w]);
- }
- } else {
- if (isset($this->data[$guid]['data'][$l])) {
- if (!is_array($v)) {
- $v = array($v);
- }
- foreach ($v as $w) {
- $key = array_search($w, $this->data[$guid]['data'][$l]);
- if ($key !== false) {
- /** Delete a single value */
- unset($this->data[$guid]['data'][$l][$key]);
- }
- }
- }
- }
- }
- }
-
- if (isset($data['replace'])) {
- $ldap_data = $this->toStorage($data['replace']);
-
- $this->data[$guid] = array(
- 'dn' => $guid,
- 'data' => array_merge($this->data[$guid]['data'],
- $ldap_data,
- array('dn' => $guid)),
- );
- }
-
- if (isset($data['add'])) {
- $ldap_data = $this->toStorage($data['add']);
-
- foreach ($ldap_data as $k => $v) {
- if (is_array($v)) {
- foreach ($v as $w) {
- $this->data[$guid]['data'][$k][] = $w;
- }
- } else {
- $this->data[$guid]['data'][$k][] = $v;
- }
- $this->data[$guid]['data'][$k] = array_values($this->data[$guid]['data'][$k]);
- }
- }
-
- $this->store();
- }
-
- /**
- * Delete an object.
- *
- * @param string $uid The UID of the object to be deleted.
- *
- * @return NULL
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function delete($uid)
- {
- if (isset($this->data[$uid])) {
- unset($this->data[$uid]);
- } else {
- throw new Horde_Kolab_Server_MissingObjectException(sprintf("No such object: %s",
- $uid));
- }
-
- $this->store();
- }
-
- /**
- * Rename an object.
- *
- * @param string $uid The UID of the object to be renamed.
- * @param string $new The new UID of the object.
- *
- * @return NULL
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function move($uid, $new)
- {
- if (isset($this->data[$uid])) {
- $this->data[$new] = $this->data[$uid];
- unset($this->data[$uid]);
- }
-
- $this->store();
- }
-
- public function schema()
- {
- //@todo: implement
- }
-
- /**
- * Cleans the current state of the database.
- *
- * @return NULL
- */
- public function clean()
- {
- $this->unbind();
-
- $GLOBALS['KOLAB_SERVER_TEST_DATA'] = array();
-
- $this->data = array();
- }
-
- /**
- * Disconnect from LDAP.
- *
- * @return NULL
- */
- public function unbind()
- {
- $this->bound = false;
- }
-
- /**
- * Load the current state of the database.
- *
- * @return NULL
- */
- protected function load()
- {
- /**
- * @todo: remove as it does not make much sense. The file based handler
- * can do the same thing as a decorator.
- */
- if (isset($GLOBALS['KOLAB_SERVER_TEST_DATA'])) {
- $this->data = $GLOBALS['KOLAB_SERVER_TEST_DATA'];
- }
- }
-
- /**
- * Store the current state of the database.
- *
- * @return NULL
- */
- protected function store()
- {
- $GLOBALS['KOLAB_SERVER_TEST_DATA'] = $this->data;
- }
-
-
- /**
- * Rewrite a data array to our internal storage format.
- *
- * @param array $data The attributes of the object to be added/replaced.
- *
- * @return array The transformed data set.
- */
- protected function toStorage($data)
- {
- $ldap_data = array();
- foreach ($data as $key => $val) {
- if (!is_array($val)) {
- $val = array($val);
- }
- $ldap_data[$key] = $val;
- }
- return $ldap_data;
+ return $this->_ldap;
}
-}
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * A driver for simulating a Kolab user database stored in LDAP.
+ *
+ * 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
+ */
+
+/**
+ * This class provides a class for testing the Kolab Server DB.
+ *
+ * Copyright 2008-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_Connection_Mock_Ldap
+{
+ /**
+ * Connection parameters.
+ *
+ * @var array
+ */
+ private $_params;
+
+ /**
+ * The current database data.
+ *
+ * @var array
+ */
+ private $_data;
+
+ /**
+ * Is the connection bound via username / password?
+ *
+ * @var boolean
+ */
+ private $_bound = false;
+
+ /**
+ * Constructor.
+ *
+ * @param array $params Connection parameters.
+ * @param array $data Mockup LDAP data.
+ */
+ public function __construct(array $params, array $data)
+ {
+ $this->_params = $params;
+ $this->_data = $data;
+ }
+
+ /**
+ * Binds the LDAP connection with a specific user and pass.
+ *
+ * @param string $dn DN to bind with
+ * @param string $pw Password associated to this DN.
+ *
+ * @return NULL
+ *
+ * @throws Horde_Kolab_Server_Exception If the user does not exit, he has no
+ * password, provided an incorrect
+ * password or anonymous binding is not
+ * allowed.
+ */
+ public function bind($dn = '', $pw = '')
+ {
+ if ($dn == '' && $pw == '') {
+ if (isset($this->_params['binddn'])
+ && isset($this->_params['bindpw'])) {
+ $dn = $this->_params['binddn'];
+ $pw = $this->_params['bindpw'];
+ }
+ }
+
+ if ($dn != '') {
+ if (!isset($this->_data[$dn])) {
+ throw new Horde_Kolab_Server_Exception('User does not exist!');
+ }
+
+ if (!isset($this->_data[$dn]['userPassword'][0])) {
+ throw new Horde_Kolab_Server_Exception('User has no password entry!');
+ }
+ if ($this->_data[$dn]['userPassword'][0] != $pw) {
+ throw new Horde_Kolab_Server_Exception('Incorrect password!');
+ }
+ } else if (!empty($this->params_['no_anonymous_bind'])) {
+ throw new Horde_Kolab_Server_Exception('Anonymous bind is not allowed!');
+ }
+
+ $this->_bound = true;
+ }
+
+ /**
+ * Get a specific entry based on the DN
+ *
+ * @param string $dn DN of the entry that should be fetched
+ * @param array $attr Array of Attributes to select. If ommitted, all attributes are fetched.
+ *
+ * @return Net_LDAP2_Entry|Net_LDAP2_Error Reference to a Net_LDAP2_Entry object or Net_LDAP2_Error object
+ * @todo Maybe check against the shema should be done to be sure the attribute type exists
+ */
+ public function getEntry($dn, $attr = array())
+ {
+ $this->_checkBound();
+
+ if (!is_array($attr)) {
+ $attr = array($attr);
+ }
+ $result = $this->search($dn, '(objectClass=*)',
+ array('scope' => 'base', 'attributes' => $attr));
+ if ($result->count() == 0) {
+ throw new Horde_Kolab_Server_Exception('Could not fetch entry '.$dn.': no entry found');
+ }
+ $entry = $result->shiftEntry();
+ if (false == $entry) {
+ throw new Horde_Kolab_Server_Exception('Could not fetch entry (error retrieving entry from search result)');
+ }
+ return $entry;
+ }
+
+ /**
+ * Search for object data.
+ *
+ * @param string $base The search base
+ * @param string $filter The LDAP search filter.
+ * @param string $params Additional search parameters.
+ *
+ * @return array The result array.
+ *
+ * @throws Horde_Kolab_Server_Exception If the search operation encountered
+ * a problem.
+ */
+ public function search($base = null, $filter = null, $params = array())
+ {
+ $this->_checkBound();
+
+ if (isset($params['attributes'])) {
+ $attributes = $params['attributes'];
+ if (!is_array($attributes)) {
+ $attributes = array($attributes);
+ }
+ } else {
+ $attributes = array();
+ }
+
+ $result = array();
+
+ if (!empty($filter)) {
+ $filter = $this->parse($filter);
+ $result = $this->doSearch($filter, $attributes);
+ } else {
+ if (isset($params['scope'])) {
+ if ($params['scope'] == 'base') {
+ if (isset($this->_data[$base])) {
+ $result = $this->_data[$base];
+ } else {
+ $result = array();
+ }
+ } else if ($params['scope'] == 'sub') {
+ //@todo: separate function
+ foreach (array_keys($this->_data) as $dn) {
+ if (empty($attributes)) {
+ $result[] = $this->_data[$dn];
+ } else {
+ $selection = $this->_data[$dn];
+ foreach ($this->_data[$dn]['data']
+ as $attr => $value) {
+ if (!in_array($attr, $attributes)) {
+ unset($selection['data'][$attr]);
+ }
+ }
+ $result[] = $selection;
+ }
+ }
+ } else if ($params['scope'] == 'one') {
+ throw new Horde_Kolab_Server_Exception('Not implemented!');
+ }
+ } else {
+ //@todo: separate function
+ foreach (array_keys($this->_data) as $dn) {
+ if (empty($attributes)) {
+ $result[] = $this->_data[$dn];
+ } else {
+ $selection = $this->_data[$dn];
+ foreach ($this->_data[$dn]['data']
+ as $attr => $value) {
+ if (!in_array($attr, $attributes)) {
+ unset($selection['data'][$attr]);
+ }
+ }
+ $result[] = $selection;
+ }
+ }
+ }
+ }
+
+ if (empty($result)) {
+ $search = new Horde_Kolab_Server_Connection_Mock_Search(array());
+ return $search;
+ }
+
+ if (!empty($base)) {
+ $subtree = array();
+ foreach ($result as $entry) {
+ if (strpos($entry['dn'], $base)) {
+ $subtree[] = $entry;
+ }
+ }
+ $result = $subtree;
+ }
+
+ $search = new Horde_Kolab_Server_Connection_Mock_Search($this->getEntries($result));
+ return $search;
+ }
+
+ /**
+ * Return the entries of a result.
+ *
+ * @param array $result The LDAP search result.
+ *
+ * @return mixed The entries of the result or false.
+ */
+ public function getEntries($result)
+ {
+ if (is_array($result)) {
+ $data = array();
+ foreach ($result as $entry) {
+ $t = $entry['data'];
+ $t['dn'] = $entry['dn'];
+ $data[$entry['dn']] = $t;
+ }
+ return $data;
+ }
+ return false;
+ }
+
+ /**
+ * Parse LDAP filter.
+ * Partially derived from Net_LDAP_Filter.
+ *
+ * @param string $filter The filter string.
+ *
+ * @return array An array of the parsed filter.
+ *
+ * @throws Horde_Kolab_Server_Exception If parsing the filter expression
+ * fails.
+ */
+ public function parse($filter)
+ {
+ $result = array();
+ if (preg_match('/^\((.+?)\)$/', $filter, $matches)) {
+ if (in_array(substr($matches[1], 0, 1), array('!', '|', '&'))) {
+ $result['op'] = substr($matches[1], 0, 1);
+ $result['sub'] = $this->parseSub(substr($matches[1], 1));
+ return $result;
+ } else {
+ if (stristr($matches[1], ')(')) {
+ throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - multiple leaf components detected!');
+ } else {
+ $filter_parts = preg_split('/(?<!\\\\)(=|=~|>|<|>=|<=)/',
+ $matches[1], 2,
+ PREG_SPLIT_DELIM_CAPTURE);
+ if (count($filter_parts) != 3) {
+ throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - unknown matching rule used');
+ } else {
+ $result['att'] = $filter_parts[0];
+ $result['log'] = $filter_parts[1];
+ $val = Net_LDAP2_Util::unescape_filter_value($filter_parts[2]);
+ $result['val'] = $val[0];
+ return $result;
+ }
+ }
+ }
+ } else {
+ throw new Horde_Kolab_Server_Exception(sprintf("Filter parsing error: %s - filter components must be enclosed in round brackets",
+ $filter));
+ }
+ }
+
+ /**
+ * Parse a LDAP subfilter.
+ *
+ * @param string $filter The subfilter string.
+ *
+ * @return array An array of the parsed subfilter.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function parseSub($filter)
+ {
+ $result = array();
+ $level = 0;
+ $collect = '';
+ while (preg_match('/^(\(.+?\))(.*)/', $filter, $matches)) {
+ if (in_array(substr($matches[1], 0, 2), array('(!', '(|', '(&'))) {
+ $level++;
+ }
+ if ($level) {
+ $collect .= $matches[1];
+ if (substr($matches[2], 0, 1) == ')') {
+ $collect .= ')';
+ $matches[2] = substr($matches[2], 1);
+ $level--;
+ if (!$level) {
+ $result[] = $this->parse($collect);
+ }
+ }
+ } else {
+ $result[] = $this->parse($matches[1]);
+ }
+ $filter = $matches[2];
+ }
+ return $result;
+ }
+
+ /**
+ * Perform the search.
+ *
+ * @param array $filter Filter criteria-
+ * @param array $attributes Restrict the search result to
+ * these attributes.
+ *
+ * @return array A LDAP serach result.
+ *
+ * @throws Horde_Kolab_Server_Exception If the search operation is not
+ * available.
+ */
+ public function doSearch($filter, $attributes = null)
+ {
+ if (isset($filter['log'])) {
+ $result = array();
+ foreach ($this->_data as $element) {
+ if (isset($element['data'][$filter['att']])) {
+ switch ($filter['log']) {
+ case '=':
+ $value = $element['data'][$filter['att']];
+ if (!empty($value) && is_array($value)) {
+ $keys = array_keys($value);
+ $first = $value[$keys[0]];
+ } else {
+ $first = $value;
+ }
+ if ((($filter['val'] == '*')
+ && !empty($value))
+ || $value == $filter['val']
+ || (substr($filter['val'], 0, 1) == '*'
+ && substr($filter['val'], strlen($filter['val']) - 1) == '*'
+ && strpos($first, substr($filter['val'], 1, strlen($filter['val']) - 2)) !== false)
+ || (is_array($value)
+ && in_array($filter['val'], $value))) {
+ if (empty($attributes)) {
+ $result[] = $element;
+ } else {
+ $selection = $element;
+ foreach ($element['data'] as $attr => $value) {
+ if (!in_array($attr, $attributes)) {
+ unset($selection['data'][$attr]);
+ }
+ }
+ $result[] = $selection;
+ }
+ }
+ break;
+ default:
+ throw new Horde_Kolab_Server_Exception("Not implemented!");
+ }
+ }
+ }
+ return $result;
+ } else {
+ $subresult = array();
+ $filtercount = count($filter['sub']);
+ foreach ($filter['sub'] as $subfilter) {
+ $subresult = array_merge($subresult,
+ $this->doSearch($subfilter,
+ $attributes));
+ }
+ $result = array();
+ $dns = array();
+ foreach ($subresult as $element) {
+ $dns[] = $element['dn'];
+
+ $result[$element['dn']] = $element;
+ }
+ switch ($filter['op']) {
+ case '&':
+ $count = array_count_values($dns);
+ $selection = array();
+ foreach ($count as $dn => $value) {
+ if ($value == $filtercount) {
+ $selection[] = $result[$dn];
+ }
+ }
+ return $selection;
+ case '|':
+ return array_values($result);
+ case '!':
+ $dns = array();
+ foreach ($result as $entry) {
+ if (!in_array($entry['dn'], $dns) ) {
+ $dns[] = $entry['dn'];
+ }
+ }
+ $all_dns = array_keys($this->_data);
+ $diff = array_diff($all_dns, $dns);
+
+ $result = array();
+ foreach ($diff as $dn) {
+ if (empty($attributes)) {
+ $result[] = $this->_data[$dn];
+ } else {
+ $selection = $this->_data[$dn];
+ foreach ($this->_data[$dn]['data']
+ as $attr => $value) {
+ if (!in_array($attr, $attributes)) {
+ unset($selection['data'][$attr]);
+ }
+ }
+ $result[] = $selection;
+ }
+ }
+ return $result;
+ default:
+ throw new Horde_Kolab_Server_Exception("Not implemented!");
+ }
+ }
+ }
+
+ /**
+ * Add a new entryobject to a directory.
+ *
+ * @param Net_LDAP2_Entry $entry Net_LDAP2_Entry
+ *
+ * @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
+ */
+ public function add($entry)
+ {
+ $this->_checkBound();
+
+ $ldap_data = $this->toStorage($entry->getValues());
+
+ $guid = $entry->getDn();
+
+ $this->_data[$guid] = array(
+ 'dn' => $guid,
+ 'data' => array_merge($ldap_data,
+ array('dn' => $guid)),
+ );
+ }
+
+ /**
+ * Modify an ldapentry directly on the server
+ *
+ * @param string|Net_LDAP2_Entry &$entry DN-string or Net_LDAP2_Entry
+ * @param array $parms Array of changes
+ *
+ * @access public
+ * @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
+ */
+ public function modify($entry, $data = array())
+ {
+ $this->_checkBound();
+
+ $guid = $entry->getDn();
+
+ if (isset($data['delete'])) {
+ foreach ($data['delete'] as $k => $v) {
+ if (is_int($k)) {
+ if (isset($this->_data[$guid]['data'][$w])) {
+ /** Delete a complete attribute */
+ unset($this->_data[$guid]['data'][$w]);
+ }
+ } else {
+ if (isset($this->_data[$guid]['data'][$l])) {
+ if (!is_array($v)) {
+ $v = array($v);
+ }
+ foreach ($v as $w) {
+ $key = array_search($w, $this->_data[$guid]['data'][$l]);
+ if ($key !== false) {
+ /** Delete a single value */
+ unset($this->_data[$guid]['data'][$l][$key]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (isset($data['replace'])) {
+ $ldap_data = $this->toStorage($data['replace']);
+
+ $this->_data[$guid] = array(
+ 'dn' => $guid,
+ 'data' => array_merge($this->_data[$guid]['data'],
+ $ldap_data,
+ array('dn' => $guid)),
+ );
+ }
+
+ if (isset($data['add'])) {
+ $ldap_data = $this->toStorage($data['add']);
+
+ foreach ($ldap_data as $k => $v) {
+ if (is_array($v)) {
+ foreach ($v as $w) {
+ $this->_data[$guid]['data'][$k][] = $w;
+ }
+ } else {
+ $this->_data[$guid]['data'][$k][] = $v;
+ }
+ $this->_data[$guid]['data'][$k] = array_values($this->_data[$guid]['data'][$k]);
+ }
+ }
+ }
+
+ /**
+ * Delete an object.
+ *
+ * @param string $uid The UID of the object to be deleted.
+ *
+ * @return NULL
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function delete($uid)
+ {
+ $this->_checkBound();
+
+ if (isset($this->_data[$uid])) {
+ unset($this->_data[$uid]);
+ } else {
+ throw new Horde_Kolab_Server_MissingObjectException(sprintf("No such object: %s",
+ $uid));
+ }
+ }
+
+ /**
+ * Rename an object.
+ *
+ * @param string $uid The UID of the object to be renamed.
+ * @param string $new The new UID of the object.
+ *
+ * @return NULL
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function move($uid, $new)
+ {
+ $this->_checkBound();
+
+ if (isset($this->_data[$uid])) {
+ $this->_data[$new] = $this->_data[$uid];
+ unset($this->_data[$uid]);
+ }
+ }
+
+ public function schema()
+ {
+ //@todo: implement
+ }
+
+ /**
+ * Rewrite a data array to our internal storage format.
+ *
+ * @param array $data The attributes of the object to be added/replaced.
+ *
+ * @return array The transformed data set.
+ */
+ protected function toStorage($data)
+ {
+ $ldap_data = array();
+ foreach ($data as $key => $val) {
+ if (!is_array($val)) {
+ $val = array($val);
+ }
+ $ldap_data[$key] = $val;
+ }
+ return $ldap_data;
+ }
+
+ /**
+ * Check if the current connection is bound.
+ *
+ * @return NULL
+ *
+ * @throws Horde_Kolab_Server_Exception If the connection is not bound.
+ */
+ private function _checkBound()
+ {
+ if (!$this->_bound) {
+ throw new Horde_Kolab_Server_Exception('Unbound connection!');
+ }
+ }
+}
*/
public function getConnection()
{
+ $config = $this->getConfiguration();
+ if (isset($config['data'])) {
+ $data = $config['data'];
+ } else {
+ $data = array();
+ }
$connection = new Horde_Kolab_Server_Connection_Mock(
- $this->getConfiguration()
+ new Horde_Kolab_Server_Connection_Mock_Ldap(
+ $config, $data
+ )
);
return $connection;
}
public function __construct(
Horde_Kolab_Server_Factory_Conn $factory,
Horde_Kolab_Server_Objects $objects,
- Horde_Kolab_Server_Structure $structure,
- Horde_Kolab_Server_Search $search,
+ Horde_Kolab_Server_Structure_Interface $structure,
+ Horde_Kolab_Server_Search_Interface $search,
Horde_Kolab_Server_Schema $schema,
array $config
) {
private function _setupSearch()
{
$this->_injector->bindImplementation(
- 'Horde_Kolab_Server_Search',
+ 'Horde_Kolab_Server_Search_Interface',
'Horde_Kolab_Server_Search_Base'
);
}
$driver = $configuration['structure']['driver'];
}
- $this->_injector->bindImplementation('Horde_Kolab_Server_Structure', $driver);
+ $this->_injector->bindImplementation(
+ 'Horde_Kolab_Server_Structure_Interface', $driver
+ );
}
/**
*/
public function getStructure()
{
- return $this->_injector->getInstance('Horde_Kolab_Server_Structure');
+ return $this->_injector->getInstance('Horde_Kolab_Server_Structure_Interface');
}
/**
*/
public function getSearch()
{
- return $this->_injector->getInstance('Horde_Kolab_Server_Search');
+ return $this->_injector->getInstance('Horde_Kolab_Server_Search_Interface');
}
/**
}
/**
- * Returns the set of search operations supported by this object type.
- *
- * @return array An array of supported search operations.
- */
- static public function getSearchOperations()
- {
- $searches = array(
- 'Horde_Kolab_Server_Object_Search_Guidforkolabusers',
- 'Horde_Kolab_Server_Object_Search_Guidforuid',
- 'Horde_Kolab_Server_Object_Search_Guidformail',
- 'Horde_Kolab_Server_Object_Search_Guidforuidormail',
- 'Horde_Kolab_Server_Object_Search_Guidforalias',
- 'Horde_Kolab_Server_Object_Search_Guidformailoralias',
- 'Horde_Kolab_Server_Object_Search_Guidforuidormailoralias',
- 'Horde_Kolab_Server_Object_Search_Mailforuidormail',
- 'Horde_Kolab_Server_Object_Search_Addressesforuidormail',
- );
- return $searches;
- }
-
- /**
* Returns the server url of the given type for this user.
*
* This method is used to encapsulate multidomain support.
unset($info[self::ATTRIBUTE_USERPASSWORD]);
}
}
-
- /**
- * Returns the set of search operations supported by this object type.
- *
- * @return array An array of supported search operations.
- */
- static public function getSearchOperations()
- {
- return array(
- 'Horde_Kolab_Server_Object_Search_Guidforcn',
- );
- }
}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * An interface marking object class search operations.
- *
- * 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
- */
-
-/**
- * An interface marking object class search operations.
- *
- * Copyright 2008-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
- */
-interface Horde_Kolab_Server_Object_Search
-{
- /**
- * Return the refernce to the composite server.
- *
- * @return Horde_Kolab_Server_Composite
- */
- public function getComposite();
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return the mail addresses of the KolabInetOrgPersons with the given uid or
- * mail address and include all alias and delegate addresses.
- *
- * 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
- */
-
-/**
- * Return the mail addresses of the KolabInetOrgPersons with the given uid or
- * mail address and include all alias and delegate addresses.
- *
- * Copyright 2008-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_Object_Search_Addressesforuidormail
-extends Horde_Kolab_Server_Object_Search_Base
-{
-
- /**
- * The basic attribute search.
- *
- * @var Horde_Kolab_Server_Object_Search
- */
- private $_search;
-
- /**
- * Constructor
- *
- * @param Horde_Kolab_Server_Composite $composite A link to the composite
- * server handler.
- */
- public function __construct(Horde_Kolab_Server_Composite $composite)
- {
- $this->_composite = $composite;
- $this->_search = new Horde_Kolab_Server_Object_Search_Attributes(
- $this->getComposite()
- );
- }
-
- /**
- * Return the mail addresses of the KolabInetOrgPersons with the given uid
- * or mail address and include all alias and delegate addresses.
- *
- * @param string $uid The uid to search for.
- * @param string $mail The mail address to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchAddressesForUidOrMail($uid, $mail)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_And(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
- Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
- ),
- new Horde_Kolab_Server_Query_Element_Or(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Uid', $uid
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $mail
- )
- )
- );
- $search = new Horde_Kolab_Server_Object_Search_Constraint_Strict(
- $this->_search
- );
-
- $data = $search->searchAttributes(
- $criteria, array('Mail', 'Alias')
- );
-
- if (empty($data)) {
- return array();
- }
-
- $mail = $this->getComposite()->structure->getAttributeInternal(
- 'Mail'
- );
- $alias = $this->getComposite()->structure->getAttributeInternal(
- 'Alias'
- );
-
- if (isset($result[$alias])) {
- $addrs = array_merge($data[$mail], $data[$alias]);
- } else {
- $addrs = $data[$mail];
- }
-
- $criteria = new Horde_Kolab_Server_Query_Element_And(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
- Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Delegate', $data[$mail][0]
- )
- );
-
- $data = $this->_search->searchAttributes(
- $criteria, array('Mail', 'Alias')
- );
-
- if (!empty($data)) {
- foreach ($data as $adr) {
- if (isset($adr[$mail])) {
- $addrs = array_merge($addrs, $adr[$mail]);
- }
- if (isset($adr[$alias])) {
- $addrs = array_merge($addrs, $adr[$alias]);
- }
- }
- }
-
- $addrs = array_map('strtolower', $addrs);
-
- return $addrs;
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Basic attributes search.
- *
- * 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
- */
-
-/**
- * Basic attributes search.
- *
- * Copyright 2008-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_Object_Search_Attributes
-extends Horde_Kolab_Server_Object_Search_Base
-{
- /**
- * Perform the search.
- *
- * @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
- * @param array $attributes The attributes to
- * retrieve.
- *
- * @return mixed The search result.
- */
- public function searchAttributes(
- Horde_Kolab_Server_Query_Element $criteria,
- array $attributes
- ) {
- $params = array('attributes' => $attributes);
- return $this->getComposite()->structure->find($criteria, $params);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * An interface marking object class search operations.
- *
- * 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
- */
-
-/**
- * An interface marking object class search operations.
- *
- * Copyright 2008-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
- */
-abstract class Horde_Kolab_Server_Object_Search_Base
-implements Horde_Kolab_Server_Object_Search
-{
- /**
- * A link to the composite server handler.
- *
- * @var Horde_Kolab_Server_Composite
- */
- private $_composite;
-
- /**
- * Constructor
- *
- * @param Horde_Kolab_Server_Composite $composite A link to the composite
- * server handler.
- */
- public function __construct(Horde_Kolab_Server_Composite $composite)
- {
- $this->_composite = $composite;
- }
-
- /**
- * Return the refernce to the composite server.
- *
- * @return Horde_Kolab_Server_Composite
- */
- public function getComposite()
- {
- return $this->_composite;
- }
-
- /**
- * Identify the GUID(s) of the result entry(s).
- *
- * @param array $result The LDAP search result.
- *
- * @return boolean|array The GUID(s) or false if there was no result.
- */
- protected function guidFromResult($result)
- {
- if (empty($result)) {
- return false;
- }
- return array_keys($result);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Basic GUID search.
- *
- * 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
- */
-
-/**
- * Basic GUID search.
- *
- * Copyright 2008-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_Object_Search_Children
-extends Horde_Kolab_Server_Object_Search_Base
-{
- /**
- * Perform the search.
- *
- * @param string $parent_guid The guid of the parent.
- * @param string $objectclass The type of children to return.
- *
- * @return mixed The search result.
- */
- public function searchChildren($parent_guid, $objectclass)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass', $objectclass
- );
- $params = array(
- 'attributes' => Horde_Kolab_Server_Object_Top::ATTRIBUTE_GUID
- );
- $data = $this->_composite->server->findBelow(
- $criteria, $parent, $params
- );
- return self::guidFromResult($data);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return only a single search result.
- *
- * 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
- */
-
-/**
- * Return only a single search result.
- *
- * Copyright 2008-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_Object_Search_Constraint_Single
-implements Horde_Kolab_Server_Object_Search
-{
- /**
- * A link to the search.
- *
- * @var Horde_Kolab_Server_Object_Search
- */
- private $_search;
-
- /**
- * Constructor
- *
- * @param Horde_Kolab_Server_Search $search The search being restricted.
- */
- public function __construct(Horde_Kolab_Server_Object_Search $search)
- {
- $this->_search = $search;
- }
-
- /**
- * Return the refernce to the composite server.
- *
- * @return Horde_Kolab_Server_Composite
- */
- public function getComposite()
- {
- return $this->_search->getComposite();
- }
-
- /**
- * Delegate to the actual search operation.
- *
- * @param string $method The name of the called method.
- * @param array $args Arguments of the call.
- *
- * @return array The search result.
- */
- public function __call($method, $args)
- {
- $args = func_get_args();
- $result = call_user_func_array(array($this->_search, $method), $args);
- return array_pop($result);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Ensures that a search yields only a single return value.
- *
- * 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
- */
-
-/**
- * Ensures that a search yields only a single return value.
- *
- * Copyright 2008-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_Object_Search_Constraint_Strict
-implements Horde_Kolab_Server_Object_Search
-{
- /**
- * A link to the search.
- *
- * @var Horde_Kolab_Server_Search
- */
- private $_search;
-
- /**
- * Constructor
- *
- * @param Horde_Kolab_Server_Search $search The search being restricted.
- */
- public function __construct(Horde_Kolab_Server_Search $search)
- {
- $this->_search = $search;
- }
-
- /**
- * Return the refernce to the composite server.
- *
- * @return Horde_Kolab_Server_Composite
- */
- public function getComposite()
- {
- return $this->_search->getComposite();
- }
-
- /**
- * Delegate to the actual search operation.
- *
- * @param string $method The name of the called method.
- * @param array $args Arguments of the call.
- *
- * @return array The search result.
- */
- public function __call($method, $args)
- {
- $args = func_get_args();
- $result = call_user_func_array(array($this->_search, $method), $args);
- $result = call_user_func_array(array($this->_search, 'search'), $args);
- if (count($result) > 1) {
- throw new Horde_Kolab_Server_Exception(
- sprintf(
- "Found %s results when expecting only one!",
- count($result)
- ),
- Horde_Kolab_Server_Exception::SEARCH_CONSTRAINT_TOO_MANY
- );
- }
- return $result;
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Basic GUID search.
- *
- * 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
- */
-
-/**
- * Basic GUID search.
- *
- * Copyright 2008-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_Object_Search_Guid
-extends Horde_Kolab_Server_Object_Search_Base
-{
- /**
- * Perform the search.
- *
- * @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
- *
- * @return array The search result.
- */
- public function searchGuid(Horde_Kolab_Server_Query_Element $criteria)
- {
- $params = array(
- 'attributes' => 'Guid'
- );
- $data = $this->getComposite()->structure->find($criteria, $params);
- return self::guidFromResult($data);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return all KolabInetOrgPersons with the given alias address.
- *
- * 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
- */
-
-/**
- * Return all KolabInetOrgPersons with the given alias address.
- *
- * Copyright 2008-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_Object_Search_Guidforalias
-extends Horde_Kolab_Server_Object_Search_Restrictkolab
-{
- /**
- * Return all KolabInetOrgPersons with the given alias.
- *
- * @param string $alias The alias address to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForAlias($alias)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Alias', $alias
- );
- return parent::searchRestrictKolab($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Identify the GUID for the objects found with the given common name.
- *
- * 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
- */
-
-/**
- * Identify the GUID for the objects found with the given common name.
- *
- * Copyright 2008-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_Object_Search_Guidforcn
-extends Horde_Kolab_Server_Object_Search_Guid
-{
- /**
- * Identify the GUID for the objects found with the given common name.
- *
- * @param string $cn Search for objects with this common name.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForCn($cn)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Cn', $cn
- );
- return parent::searchGuid($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return the GUIDs of all KolabInetOrgPersons.
- *
- * 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
- */
-
-/**
- * Return the GUIDs of all KolabInetOrgPersons.
- *
- * Copyright 2008-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_Object_Search_Guidforkolabusers
-extends Horde_Kolab_Server_Object_Search_Guid
-{
- /**
- * Return the GUIDs of all KolabInetOrgPersons.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForKolabUsers()
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
- Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
- );
- return parent::searchGuid($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return all KolabInetOrgPersons with the given mail address.
- *
- * 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
- */
-
-/**
- * Return all KolabInetOrgPersons with the given mail address.
- *
- * Copyright 2008-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_Object_Search_Guidformail
-extends Horde_Kolab_Server_Object_Search_Restrictkolab
-{
- /**
- * Return all KolabInetOrgPersons with the given mail.
- *
- * @param string $mail The mail to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForMail($mail)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $mail
- );
- return parent::searchRestrictKolab($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return all KolabInetOrgPersons with the given mail or alias address.
- *
- * 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
- */
-
-/**
- * Return all KolabInetOrgPersons with the given mail or alias address.
- *
- * Copyright 2008-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_Object_Search_Guidformailoralias
-extends Horde_Kolab_Server_Object_Search_Restrictkolab
-{
- /**
- * Return all KolabInetOrgPersons with the given mail or alias address.
- *
- * @param string $mail The mail address to search for.
- * @param string $alias The alias address to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForMailOrAlias($mail, $alias)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Or(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $mail
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Alias', $alias
- )
- );
- return parent::searchRestrictKolab($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return all KolabInetOrgPersons with the given 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
- */
-
-/**
- * Return all KolabInetOrgPersons with the given uid.
- *
- * Copyright 2008-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_Object_Search_Guidforuid
-extends Horde_Kolab_Server_Object_Search_Restrictkolab
-{
- /**
- * Return all KolabInetOrgPersons with the given uid.
- *
- * @param string $uid The uid to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForUid($uid)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Equals(
- 'Uid', $uid
- );
- return parent::searchRestrictKolab($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return all KolabInetOrgPersons with the given uid or mail address.
- *
- * 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
- */
-
-/**
- * Return all KolabInetOrgPersons with the given uid or mail address.
- *
- * Copyright 2008-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_Object_Search_Guidforuidormail
-extends Horde_Kolab_Server_Object_Search_Restrictkolab
-{
- /**
- * Return all KolabInetOrgPersons with the given uid or mail address.
- *
- * @param string $id The uid or mail address to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForUidOrMail($id)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Or(
- array(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Uid', $id
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $id
- )
- )
- );
- return parent::searchRestrictKolab($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return all KolabInetOrgPersons with the given uid, mail or alias address.
- *
- * 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
- */
-
-/**
- * Return all KolabInetOrgPersons with the given uid, mail or alias address.
- *
- * Copyright 2008-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_Object_Search_Guidforuidormailoralias
-extends Horde_Kolab_Server_Object_Search_Restrictkolab
-{
- /**
- * Return all KolabInetOrgPersons with the given uid, mail or alias address.
- *
- * @param string $id The uid or mail address or alias address to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchGuidForUidOrMailOrAlias($id)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_Or(
- array(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Uid', $id
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $id
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Alias', $id
- )
- )
- );
- return parent::searchRestrictKolab($criteria);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Return the mail address of the KolabInetOrgPersons with the given uid or mail
- * address.
- *
- * 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
- */
-
-/**
- * Return the mail address of the KolabInetOrgPersons with the given uid or mail
- * address.
- *
- * Copyright 2008-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_Object_Search_Mailforuidormail
-extends Horde_Kolab_Server_Object_Search_Base
-{
-
- /**
- * The base attribute search.
- *
- * @var Horde_Kolab_Server_Object_Search
- */
- private $_search;
-
- /**
- * Constructor
- *
- * @param Horde_Kolab_Server_Composite $composite A link to the composite
- * server handler.
- */
- public function __construct(Horde_Kolab_Server_Composite $composite)
- {
- $this->_composite = $composite;
- $this->_search = new Horde_Kolab_Server_Object_Search_Constraint_Strict(
- new Horde_Kolab_Server_Object_Search_Attributes(
- $this->getComposite()
- )
- );
- }
-
- /**
- * Return the mail address of the KolabInetOrgPersons with the given uid or
- * mail address.
- *
- * @param string $uid The uid to search for.
- * @param string $mail The mail address to search for.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchMailForUidOrMail($uid, $mail)
- {
- $criteria = new Horde_Kolab_Server_Query_Element_And(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
- Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
- ),
- new Horde_Kolab_Server_Query_Element_Or(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Uid', $uid
- ),
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Mail', $mail
- )
- )
- );
- $data = $this->_search->searchAttributes($criteria, array('Mail'));
-
- $internal = $this->getComposite()->structure->getAttributeInternal(
- 'Mail'
- );
- if (!empty($data)) {
- return $data[$internal][0];
- } else {
- return false;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Restrict a search to KolabInetOrgPersons.
- *
- * 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
- */
-
-/**
- * Restrict a search to KolabInetOrgPersons.
- *
- * Copyright 2008-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_Object_Search_Restrictkolab
-extends Horde_Kolab_Server_Object_Search_Guid
-{
- /**
- * Restrict a search to KolabInetOrgPersons.
- *
- * @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
- *
- * @return array The GUID(s).
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function searchRestrictKolab(
- Horde_Kolab_Server_Query_Element $criteria
- ) {
- $criteria = new Horde_Kolab_Server_Query_Element_And(
- array(
- new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
- Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
- ),
- $criteria
- )
- );
- return parent::searchGuid($criteria);
- }
-}
\ No newline at end of file
* database.
*/
public static function getFilter();
-
- /**
- * Returns the set of search operations supported by this object type.
- *
- * @return array An array of supported search operations.
- */
- public static function getSearchOperations();
}
\ No newline at end of file
}
/**
- * Returns the set of search operations supported by this object type.
- *
- * @return array An array of supported search operations.
- */
- static public function getSearchOperations()
- {
- $searches = array(
- 'Horde_Kolab_Server_Object_Search_Guid',
- 'Horde_Kolab_Server_Object_Search_Attributes',
- 'Horde_Kolab_Server_Object_Search_Children',
- );
- return $searches;
- }
-
- /**
* Returns the set of actions supported by this object type.
*
* @return array An array of supported actions.
*
* @var Horde_Kolab_Server_Composite
*/
- protected $composite;
+ private $_composite;
/**
* Set the composite server reference for this object.
*/
public function setComposite(Horde_Kolab_Server_Composite $composite)
{
- $this->composite = $composite;
+ $this->_composite = $composite;
}
/**
public function fetch($uid = null, $type = null)
{
if (!isset($uid)) {
- $uid = $this->uid;
+ $guid = $this->_composite->server->getGuid();
}
if (empty($type)) {
- $type = $this->determineType($uid);
+ $type = $this->_composite->structure->determineType($guid);
}
- $object = &Horde_Kolab_Server_Object::factory($type, $uid, $this);
+ $object = &Horde_Kolab_Server_Object_Factory::factory(
+ $type, $guid, $this->_composite->server
+ );
return $object;
}
*/
public function __construct(
Horde_Kolab_Server_Query_Element $criteria,
- Horde_Kolab_Server_Structure $structure
+ Horde_Kolab_Server_Structure_Interface $structure
) {
$this->_criteria = $criteria;
$this->_structure = $structure;
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Result_Ldap implements Horde_Kolab_Server_Result
+class Horde_Kolab_Server_Result_Ldap implements Horde_Kolab_Server_Result
{
/**
* The search result.
+++ /dev/null
-<?php
-/**
- * A library for accessing the Kolab user database.
- *
- * 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
- */
-
-/**
- * Defines the interface of the search handler for a Kolab Server.
- *
- * Copyright 2008-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
- */
-interface Horde_Kolab_Server_Search
-{
- /**
- * Set the composite server reference for this object.
- *
- * @param Horde_Kolab_Server_Composite $composite A link to the composite
- * server handler.
- */
- public function setComposite(Horde_Kolab_Server_Composite $composite);
-
- /**
- * Returns the set of search operations supported by this server type.
- *
- * @return array An array of supported search operations.
- */
- public function getSearchOperations();
-
- /**
- * Capture undefined calls.
- *
- * @param string $method The name of the called method.
- * @param array $args Arguments of the call.
- *
- * @return NULL.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function __call($method, $args);
-}
\ No newline at end of file
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Search_Base implements Horde_Kolab_Server_Search
+class Horde_Kolab_Server_Search_Base
+implements Horde_Kolab_Server_Search_Interface
{
/**
* A link to the composite server handler.
private function _getSearchOperations()
{
$server_searches = array();
- foreach ($this->_composite->structure->getSupportedObjects() as $sobj) {
- $methods = get_class_methods($sobj);
- if (!in_array('getSearchOperations', $methods)) {
- continue;
+ foreach ($this->_composite->structure->getSearchOperations() as $search_class) {
+ if (!class_exists($search_class)) {
+ throw new Horde_Kolab_Server_Exception(
+ sprintf(
+ "%s::getSearchOperations specified non-existing class \"%s\"!",
+ get_class($this->_composite->structure),
+ $search_class
+ )
+ );
}
- $search_classes = call_user_func(array($sobj, 'getSearchOperations'));
- foreach ($search_classes as $search_class) {
- if (!class_exists($search_class)) {
- throw new Horde_Kolab_Server_Exception(
- sprintf(
- "%s::getSearchOperations specified non-existing class \"%s\"!",
- $sobj,
- $search_class
- )
- );
- }
- $methods = get_class_methods($search_class);
- unset($methods['getComposite']);
- unset($methods['__construct']);
- foreach ($methods as $method) {
- $server_searches[$method] = array('class' => $search_class);
- }
+ $methods = get_class_methods($search_class);
+ unset($methods['getComposite']);
+ unset($methods['__construct']);
+ foreach ($methods as $method) {
+ $server_searches[$method] = array('class' => $search_class);
}
}
return $server_searches;
{
if (in_array($method, array_keys($this->_searches))) {
$class = $this->_searches[$method]['class'];
- $search = new $class($this->_composite);
+ $search = new $class($this->_composite->structure);
return call_user_func_array(array($search, $method), $args);
}
throw new Horde_Kolab_Server_Exception(
--- /dev/null
+<?php
+/**
+ * A library for accessing the Kolab user database.
+ *
+ * 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
+ */
+
+/**
+ * Defines the interface of the search handler for a Kolab Server.
+ *
+ * Copyright 2008-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
+ */
+interface Horde_Kolab_Server_Search_Interface
+{
+ /**
+ * Set the composite server reference for this object.
+ *
+ * @param Horde_Kolab_Server_Composite $composite A link to the composite
+ * server handler.
+ */
+ public function setComposite(Horde_Kolab_Server_Composite $composite);
+
+ /**
+ * Returns the set of search operations supported by this server type.
+ *
+ * @return array An array of supported search operations.
+ */
+ public function getSearchOperations();
+
+ /**
+ * Capture undefined calls.
+ *
+ * @param string $method The name of the called method.
+ * @param array $args Arguments of the call.
+ *
+ * @return NULL.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function __call($method, $args);
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return the mail addresses of the KolabInetOrgPersons with the given uid or
+ * mail address and include all alias and delegate addresses.
+ *
+ * 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
+ */
+
+/**
+ * Return the mail addresses of the KolabInetOrgPersons with the given uid or
+ * mail address and include all alias and delegate addresses.
+ *
+ * Copyright 2008-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_Search_Operation_Addressesforuidormail
+extends Horde_Kolab_Server_Search_Operation_Base
+{
+
+ /**
+ * The basic attribute search.
+ *
+ * @var Horde_Kolab_Server_Search_Operation
+ */
+ private $_search;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Composite $composite A link to the composite
+ * server handler.
+ */
+ public function __construct(Horde_Kolab_Server_Composite $composite)
+ {
+ $this->_composite = $composite;
+ $this->_search = new Horde_Kolab_Server_Search_Operation_Attributes(
+ $this->getComposite()
+ );
+ }
+
+ /**
+ * Return the mail addresses of the KolabInetOrgPersons with the given uid
+ * or mail address and include all alias and delegate addresses.
+ *
+ * @param string $uid The uid to search for.
+ * @param string $mail The mail address to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchAddressesForUidOrMail($uid, $mail)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_And(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass',
+ Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
+ ),
+ new Horde_Kolab_Server_Query_Element_Or(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Uid', $uid
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Mail', $mail
+ )
+ )
+ );
+ $search = new Horde_Kolab_Server_Search_Operation_Constraint_Strict(
+ $this->_search
+ );
+
+ $data = $search->searchAttributes(
+ $criteria, array('Mail', 'Alias')
+ );
+
+ if (empty($data)) {
+ return array();
+ }
+
+ $mail = $this->getComposite()->structure->getAttributeInternal(
+ 'Mail'
+ );
+ $alias = $this->getComposite()->structure->getAttributeInternal(
+ 'Alias'
+ );
+
+ if (isset($result[$alias])) {
+ $addrs = array_merge($data[$mail], $data[$alias]);
+ } else {
+ $addrs = $data[$mail];
+ }
+
+ $criteria = new Horde_Kolab_Server_Query_Element_And(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass',
+ Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Delegate', $data[$mail][0]
+ )
+ );
+
+ $data = $this->_search->searchAttributes(
+ $criteria, array('Mail', 'Alias')
+ );
+
+ if (!empty($data)) {
+ foreach ($data as $adr) {
+ if (isset($adr[$mail])) {
+ $addrs = array_merge($addrs, $adr[$mail]);
+ }
+ if (isset($adr[$alias])) {
+ $addrs = array_merge($addrs, $adr[$alias]);
+ }
+ }
+ }
+
+ $addrs = array_map('strtolower', $addrs);
+
+ return $addrs;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Basic attributes search.
+ *
+ * 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
+ */
+
+/**
+ * Basic attributes search.
+ *
+ * Copyright 2008-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_Search_Operation_Attributes
+extends Horde_Kolab_Server_Search_Operation_Base
+{
+ /**
+ * Perform the search.
+ *
+ * @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
+ * @param array $attributes The attributes to
+ * retrieve.
+ *
+ * @return mixed The search result.
+ */
+ public function searchAttributes(
+ Horde_Kolab_Server_Query_Element $criteria,
+ array $attributes
+ ) {
+ $params = array('attributes' => $attributes);
+ return $this->getComposite()->structure->find($criteria, $params);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * An interface marking object class search operations.
+ *
+ * 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
+ */
+
+/**
+ * An interface marking object class search operations.
+ *
+ * Copyright 2008-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
+ */
+abstract class Horde_Kolab_Server_Search_Operation_Base
+implements Horde_Kolab_Server_Search_Operation_Interface
+{
+ /**
+ * A link to the server structure.
+ *
+ * @var Horde_Kolab_Server_Structure_Interface
+ */
+ private $_structure;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Structure_Interface $structure A link to the
+ * server
+ * structure.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Structure_Interface $structure
+ ) {
+ $this->_structure = $structure;
+ }
+
+ /**
+ * Return the reference to the server structure.
+ *
+ * @return Horde_Kolab_Server_Structure_Interface
+ */
+ public function getStructure()
+ {
+ return $this->_structure;
+ }
+
+ /**
+ * Identify the GUID(s) of the result entry(s).
+ *
+ * @param array $result The LDAP search result.
+ *
+ * @return boolean|array The GUID(s) or false if there was no result.
+ */
+ protected function guidFromResult(Horde_Kolab_Server_Result $result)
+ {
+ return array_keys($result->asArray());
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Basic GUID search.
+ *
+ * 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
+ */
+
+/**
+ * Basic GUID search.
+ *
+ * Copyright 2008-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_Search_Operation_Children
+extends Horde_Kolab_Server_Search_Operation_Base
+{
+ /**
+ * Perform the search.
+ *
+ * @param string $parent_guid The guid of the parent.
+ * @param string $objectclass The type of children to return.
+ *
+ * @return mixed The search result.
+ */
+ public function searchChildren($parent_guid, $objectclass)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass', $objectclass
+ );
+ $params = array(
+ 'attributes' => Horde_Kolab_Server_Object_Top::ATTRIBUTE_GUID
+ );
+ $data = $this->_composite->server->findBelow(
+ $criteria, $parent, $params
+ );
+ return self::guidFromResult($data);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return only a single search result.
+ *
+ * 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
+ */
+
+/**
+ * Return only a single search result.
+ *
+ * Copyright 2008-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_Search_Operation_Constraint_Single
+implements Horde_Kolab_Server_Search_Operation_Interface
+{
+ /**
+ * A link to the search.
+ *
+ * @var Horde_Kolab_Server_Search_Operation
+ */
+ private $_search;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Search $search The search being restricted.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Search_Operation_Interface $search
+ ) {
+ $this->_search = $search;
+ }
+
+ /**
+ * Return the reference to the server structure.
+ *
+ * @return Horde_Kolab_Server_Structure_Interface
+ */
+ public function getStructure()
+ {
+ return $this->_search->getStructure();
+ }
+
+ /**
+ * Delegate to the actual search operation.
+ *
+ * @param string $method The name of the called method.
+ * @param array $args Arguments of the call.
+ *
+ * @return array The search result.
+ */
+ public function __call($method, $args)
+ {
+ $args = func_get_args();
+ $result = call_user_func_array(array($this->_search, $method), $args);
+ return array_shift($result);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Ensures that a search yields only a single return value.
+ *
+ * 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
+ */
+
+/**
+ * Ensures that a search yields only a single return value.
+ *
+ * Copyright 2008-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_Search_Operation_Constraint_Strict
+implements Horde_Kolab_Server_Search_Operation_Interface
+{
+ /**
+ * A link to the search.
+ *
+ * @var Horde_Kolab_Server_Search
+ */
+ private $_search;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Search $search The search being restricted.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Search_Operation_Interface $search
+ ) {
+ $this->_search = $search;
+ }
+
+ /**
+ * Return the reference to the server structure.
+ *
+ * @return Horde_Kolab_Server_Structure_Interface
+ */
+ public function getStructure()
+ {
+ return $this->_search->getStructure();
+ }
+
+ /**
+ * Delegate to the actual search operation.
+ *
+ * @param string $method The name of the called method.
+ * @param array $args Arguments of the call.
+ *
+ * @return array The search result.
+ */
+ public function __call($method, $args)
+ {
+ $result = call_user_func_array(array($this->_search, $method), $args);
+ if (count($result) > 1) {
+ throw new Horde_Kolab_Server_Exception(
+ sprintf(
+ "Found %s results when expecting only one!",
+ count($result)
+ ),
+ Horde_Kolab_Server_Exception::SEARCH_CONSTRAINT_TOO_MANY
+ );
+ }
+ return array_shift($result);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Basic GUID search.
+ *
+ * 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
+ */
+
+/**
+ * Basic GUID search.
+ *
+ * Copyright 2008-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_Search_Operation_Guid
+extends Horde_Kolab_Server_Search_Operation_Base
+{
+ /**
+ * Perform the search.
+ *
+ * @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
+ *
+ * @return array The search result.
+ */
+ public function searchGuid(Horde_Kolab_Server_Query_Element $criteria)
+ {
+ $params = array(
+ 'attributes' => 'Guid'
+ );
+ $data = $this->getStructure()->find($criteria, $params);
+ return self::guidFromResult($data);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return all KolabInetOrgPersons with the given alias address.
+ *
+ * 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
+ */
+
+/**
+ * Return all KolabInetOrgPersons with the given alias address.
+ *
+ * Copyright 2008-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_Search_Operation_Guidforalias
+extends Horde_Kolab_Server_Search_Operation_Restrictkolab
+{
+ /**
+ * Return all KolabInetOrgPersons with the given alias.
+ *
+ * @param string $alias The alias address to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForAlias($alias)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Alias', $alias
+ );
+ return parent::searchRestrictKolab($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Identify the GUID for the objects found with the given common name.
+ *
+ * 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
+ */
+
+/**
+ * Identify the GUID for the objects found with the given common name.
+ *
+ * Copyright 2008-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_Search_Operation_Guidforcn
+extends Horde_Kolab_Server_Search_Operation_Guid
+{
+ /**
+ * Identify the GUID for the objects found with the given common name.
+ *
+ * @param string $cn Search for objects with this common name.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForCn($cn)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Cn', $cn
+ );
+ return parent::searchGuid($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return the GUIDs of all KolabInetOrgPersons.
+ *
+ * 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
+ */
+
+/**
+ * Return the GUIDs of all KolabInetOrgPersons.
+ *
+ * Copyright 2008-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_Search_Operation_Guidforkolabusers
+extends Horde_Kolab_Server_Search_Operation_Guid
+{
+ /**
+ * Return the GUIDs of all KolabInetOrgPersons.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForKolabUsers()
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass',
+ Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
+ );
+ return parent::searchGuid($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return all KolabInetOrgPersons with the given mail address.
+ *
+ * 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
+ */
+
+/**
+ * Return all KolabInetOrgPersons with the given mail address.
+ *
+ * Copyright 2008-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_Search_Operation_Guidformail
+extends Horde_Kolab_Server_Search_Operation_Restrictkolab
+{
+ /**
+ * Return all KolabInetOrgPersons with the given mail.
+ *
+ * @param string $mail The mail to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForMail($mail)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Mail', $mail
+ );
+ return parent::searchRestrictKolab($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return all KolabInetOrgPersons with the given mail or alias address.
+ *
+ * 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
+ */
+
+/**
+ * Return all KolabInetOrgPersons with the given mail or alias address.
+ *
+ * Copyright 2008-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_Search_Operation_Guidformailoralias
+extends Horde_Kolab_Server_Search_Operation_Restrictkolab
+{
+ /**
+ * Return all KolabInetOrgPersons with the given mail or alias address.
+ *
+ * @param string $mail The mail address to search for.
+ * @param string $alias The alias address to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForMailOrAlias($mail, $alias)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Or(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Mail', $mail
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Alias', $alias
+ )
+ );
+ return parent::searchRestrictKolab($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return all KolabInetOrgPersons with the given 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
+ */
+
+/**
+ * Return all KolabInetOrgPersons with the given uid.
+ *
+ * Copyright 2008-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_Search_Operation_Guidforuid
+extends Horde_Kolab_Server_Search_Operation_Restrictkolab
+{
+ /**
+ * Return all KolabInetOrgPersons with the given uid.
+ *
+ * @param string $uid The uid to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForUid($uid)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Uid', $uid
+ );
+ return parent::searchRestrictKolab($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return all KolabInetOrgPersons with the given uid or mail address.
+ *
+ * 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
+ */
+
+/**
+ * Return all KolabInetOrgPersons with the given uid or mail address.
+ *
+ * Copyright 2008-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_Search_Operation_Guidforuidormail
+implements Horde_Kolab_Server_Search_Operation_Interface
+{
+ /**
+ * A link to the search.
+ *
+ * @var Horde_Kolab_Server_Search
+ */
+ private $_search;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Structure_Interface $structure A link to the
+ * server
+ * structure.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Structure_Interface $structure
+ ) {
+ $this->_search = new Horde_Kolab_Server_Search_Operation_Constraint_Strict(
+ new Horde_Kolab_Server_Search_Operation_Restrictkolab(
+ $structure
+ )
+ );
+ }
+
+ /**
+ * Return the reference to the server structure.
+ *
+ * @return Horde_Kolab_Server_Structure_Interface
+ */
+ public function getStructure()
+ {
+ return $this->_search->getStructure();
+ }
+
+ /**
+ * Return all KolabInetOrgPersons with the given uid or mail address.
+ *
+ * @param string $id The uid or mail address to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForUidOrMail($id)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Or(
+ array(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Uid', $id
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Mail', $id
+ )
+ )
+ );
+ return $this->_search->searchRestrictKolab($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return all KolabInetOrgPersons with the given uid, mail or alias address.
+ *
+ * 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
+ */
+
+/**
+ * Return all KolabInetOrgPersons with the given uid, mail or alias address.
+ *
+ * Copyright 2008-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_Search_Operation_Guidforuidormailoralias
+extends Horde_Kolab_Server_Search_Operation_Restrictkolab
+{
+ /**
+ * Return all KolabInetOrgPersons with the given uid, mail or alias address.
+ *
+ * @param string $id The uid or mail address or alias address to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchGuidForUidOrMailOrAlias($id)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_Or(
+ array(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Uid', $id
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Mail', $id
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Alias', $id
+ )
+ )
+ );
+ return parent::searchRestrictKolab($criteria);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * An interface marking object class search operations.
+ *
+ * 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
+ */
+
+/**
+ * An interface marking object class search operations.
+ *
+ * Copyright 2008-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
+ */
+interface Horde_Kolab_Server_Search_Operation_Interface
+{
+ /**
+ * Return the reference to the server structure.
+ *
+ * @return Horde_Kolab_Server_Structure_Interface
+ */
+ public function getStructure();
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Return the mail address of the KolabInetOrgPersons with the given uid or mail
+ * address.
+ *
+ * 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
+ */
+
+/**
+ * Return the mail address of the KolabInetOrgPersons with the given uid or mail
+ * address.
+ *
+ * Copyright 2008-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_Search_Operation_Mailforuidormail
+extends Horde_Kolab_Server_Search_Operation_Base
+{
+
+ /**
+ * The base attribute search.
+ *
+ * @var Horde_Kolab_Server_Search_Operation
+ */
+ private $_search;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Composite $composite A link to the composite
+ * server handler.
+ */
+ public function __construct(Horde_Kolab_Server_Composite $composite)
+ {
+ $this->_composite = $composite;
+ $this->_search = new Horde_Kolab_Server_Search_Operation_Constraint_Strict(
+ new Horde_Kolab_Server_Search_Operation_Attributes(
+ $this->getComposite()
+ )
+ );
+ }
+
+ /**
+ * Return the mail address of the KolabInetOrgPersons with the given uid or
+ * mail address.
+ *
+ * @param string $uid The uid to search for.
+ * @param string $mail The mail address to search for.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchMailForUidOrMail($uid, $mail)
+ {
+ $criteria = new Horde_Kolab_Server_Query_Element_And(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass',
+ Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
+ ),
+ new Horde_Kolab_Server_Query_Element_Or(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Uid', $uid
+ ),
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Mail', $mail
+ )
+ )
+ );
+ $data = $this->_search->searchAttributes($criteria, array('Mail'));
+
+ $internal = $this->getComposite()->structure->getAttributeInternal(
+ 'Mail'
+ );
+ if (!empty($data)) {
+ return $data[$internal][0];
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Restrict a search to KolabInetOrgPersons.
+ *
+ * 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
+ */
+
+/**
+ * Restrict a search to KolabInetOrgPersons.
+ *
+ * Copyright 2008-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_Search_Operation_Restrictkolab
+extends Horde_Kolab_Server_Search_Operation_Guid
+{
+ /**
+ * Restrict a search to KolabInetOrgPersons.
+ *
+ * @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
+ *
+ * @return array The GUID(s).
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function searchRestrictKolab(
+ Horde_Kolab_Server_Query_Element $criteria
+ ) {
+ $criteria = new Horde_Kolab_Server_Query_Element_And(
+ array(
+ new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass',
+ Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
+ ),
+ $criteria
+ )
+ );
+ return parent::searchGuid($criteria);
+ }
+}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * A simple structural handler for a tree of objects.
- *
- * 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
- */
-
-/**
- * The interface definition for the handlers dealing with the Kolab Server
- * object tree structure.
- *
- * 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
- */
-interface Horde_Kolab_Server_Structure
-{
- /**
- * Finds object data matching a given set of criteria.
- *
- * @param Horde_Kolab_Server_Query_Element $criteria The criteria for the search.
- * @param array $params Additional search parameters.
- *
- * @return Horde_Kolab_Server_Result The result object.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function find(
- Horde_Kolab_Server_Query_Element $criteria,
- array $params = array()
- );
-
- /**
- * Finds all object data below a parent matching a given set of criteria.
- *
- * @param Horde_Kolab_Server_Query_Element $criteria The criteria for the search.
- * @param string $parent The parent to search below.
- * @param array $params Additional search parameters.
- *
- * @return Horde_Kolab_Server_Result The result object.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- public function findBelow(
- Horde_Kolab_Server_Query_Element $criteria,
- $parent,
- array $params = array()
- );
-
- /**
- * Set the composite server reference for this object.
- *
- * @param Horde_Kolab_Server_Composite $composite A link to the composite
- * server handler.
- *
- * @return NULL
- */
- public function setComposite(Horde_Kolab_Server_Composite $composite);
-
- /**
- * Returns the set of objects supported by this structure.
- *
- * @return array An array of supported objects.
- */
- public function getSupportedObjects();
-
- /**
- * Maps the external attribute name to its internal counterpart.
- *
- * @param string $external The external attribute name.
- *
- * @return string The internal attribute name.
- */
- public function getInternalAttribute($external);
-
- /**
- * Determine the type of an object by its tree position and other
- * parameters.
- *
- * @param string $guid The GUID of the object to examine.
- *
- * @return string The class name of the corresponding object type.
- *
- * @throws Horde_Kolab_Server_Exception If the object type is unknown.
- */
- public function determineType($guid);
-
- /**
- * Generates a UID for the given information.
- *
- * @param string $type The class name of the object to create.
- * @param string $id The id of the object.
- * @param array $info Any additional information about the object to create.
- *
- * @return string The GUID.
- *
- * @throws Horde_Kolab_Server_Exception If the given type is unknown.
- */
- public function generateServerGuid($type, $id, array $info);
-}
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-abstract class Horde_Kolab_Server_Structure_Base implements Horde_Kolab_Server_Structure
+abstract class Horde_Kolab_Server_Structure_Base
+implements Horde_Kolab_Server_Structure_Interface
{
/**
* A link to the composite server handler.
--- /dev/null
+<?php
+/**
+ * A simple structural handler for a tree of objects.
+ *
+ * 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
+ */
+
+/**
+ * The interface definition for the handlers dealing with the Kolab Server
+ * object tree structure.
+ *
+ * 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
+ */
+interface Horde_Kolab_Server_Structure_Interface
+{
+ /**
+ * Finds object data matching a given set of criteria.
+ *
+ * @param Horde_Kolab_Server_Query_Element $criteria The criteria for the search.
+ * @param array $params Additional search parameters.
+ *
+ * @return Horde_Kolab_Server_Result The result object.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function find(
+ Horde_Kolab_Server_Query_Element $criteria,
+ array $params = array()
+ );
+
+ /**
+ * Finds all object data below a parent matching a given set of criteria.
+ *
+ * @param Horde_Kolab_Server_Query_Element $criteria The criteria for the search.
+ * @param string $parent The parent to search below.
+ * @param array $params Additional search parameters.
+ *
+ * @return Horde_Kolab_Server_Result The result object.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function findBelow(
+ Horde_Kolab_Server_Query_Element $criteria,
+ $parent,
+ array $params = array()
+ );
+
+ /**
+ * Set the composite server reference for this object.
+ *
+ * @param Horde_Kolab_Server_Composite $composite A link to the composite
+ * server handler.
+ *
+ * @return NULL
+ */
+ public function setComposite(Horde_Kolab_Server_Composite $composite);
+
+ /**
+ * Returns the set of objects supported by this structure.
+ *
+ * @return array An array of supported objects.
+ */
+ public function getSupportedObjects();
+
+ /**
+ * Returns the set of search operations supported by this object type.
+ *
+ * @return array An array of supported search operations.
+ */
+ public function getSearchOperations();
+
+ /**
+ * Maps the external attribute name to its internal counterpart.
+ *
+ * @param string $external The external attribute name.
+ *
+ * @return string The internal attribute name.
+ */
+ public function getInternalAttribute($external);
+
+ /**
+ * Determine the type of an object by its tree position and other
+ * parameters.
+ *
+ * @param string $guid The GUID of the object to examine.
+ *
+ * @return string The class name of the corresponding object type.
+ *
+ * @throws Horde_Kolab_Server_Exception If the object type is unknown.
+ */
+ public function determineType($guid);
+
+ /**
+ * Generates a UID for the given information.
+ *
+ * @param string $type The class name of the object to create.
+ * @param string $id The id of the object.
+ * @param array $info Any additional information about the object to create.
+ *
+ * @return string The GUID.
+ *
+ * @throws Horde_Kolab_Server_Exception If the given type is unknown.
+ */
+ public function generateServerGuid($type, $id, array $info);
+}
}
/**
+ * Returns the set of search operations supported by this object type.
+ *
+ * @return array An array of supported search operations.
+ */
+ public function getSearchOperations()
+ {
+ $searches = array(
+ 'Horde_Kolab_Server_Search_Operation_Guid',
+ 'Horde_Kolab_Server_Search_Operation_Attributes',
+ 'Horde_Kolab_Server_Search_Operation_Children',
+ 'Horde_Kolab_Server_Search_Operation_Guidforcn',
+ 'Horde_Kolab_Server_Search_Operation_Guidforkolabusers',
+ 'Horde_Kolab_Server_Search_Operation_Guidforuid',
+ 'Horde_Kolab_Server_Search_Operation_Guidformail',
+ 'Horde_Kolab_Server_Search_Operation_Guidforuidormail',
+ 'Horde_Kolab_Server_Search_Operation_Guidforalias',
+ 'Horde_Kolab_Server_Search_Operation_Guidformailoralias',
+ 'Horde_Kolab_Server_Search_Operation_Guidforuidormailoralias',
+ 'Horde_Kolab_Server_Search_Operation_Mailforuidormail',
+ 'Horde_Kolab_Server_Search_Operation_Addressesforuidormail',
+ );
+ return $searches;
+ }
+
+ /**
* Determine the type of an object by its tree position and other
* parameters.
*
}
/**
+ * Returns the set of search operations supported by this object type.
+ *
+ * @return array An array of supported search operations.
+ */
+ public function getSearchOperations()
+ {
+ $searches = array(
+ 'Horde_Kolab_Server_Search_Operation_Guid',
+ 'Horde_Kolab_Server_Search_Operation_Attributes',
+ 'Horde_Kolab_Server_Search_Operation_Children',
+ 'Horde_Kolab_Server_Search_Operation_Guidforcn',
+ );
+ return $searches;
+ }
+
+ /**
* Determine the type of an object by its tree position and other
* parameters.
*
<file name="File.php" role="php" />
<file name="Mock.php" role="php" />
<dir name="Mock">
+ <file name="Ldap.php" role="php" />
<file name="Search.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Server/Connection/Mock -->
<file name="Simpleldap.php" role="php" />
<file name="Kolabsharedfolder.php" role="php" />
<file name="Organizationalperson.php" role="php" />
<file name="Person.php" role="php" />
- <file name="Search.php" role="php" />
- <dir name="Search">
- <file name="Addressesforuidormail.php" role="php" />
- <file name="Attributes.php" role="php" />
- <file name="Base.php" role="php" />
- <file name="Children.php" role="php" />
- <dir name="Constraint">
- <file name="Single.php" role="php" />
- <file name="Strict.php" role="php" />
- </dir> <!-- /lib/Horde/Kolab/Server/Object/Constraint -->
- <file name="Guid.php" role="php" />
- <file name="Guidforalias.php" role="php" />
- <file name="Guidforcn.php" role="php" />
- <file name="Guidforkolabusers.php" role="php" />
- <file name="Guidformailoralias.php" role="php" />
- <file name="Guidformail.php" role="php" />
- <file name="Guidforuidormailoralias.php" role="php" />
- <file name="Guidforuidormail.php" role="php" />
- <file name="Guidforuid.php" role="php" />
- <file name="Mailforuidormail.php" role="php" />
- <file name="Restrictkolab.php" role="php" />
- </dir> <!-- /lib/Horde/Kolab/Server/Object/Search -->
<file name="Searches.php" role="php" />
<file name="Top.php" role="php" />
<dir name="Kolab">
<dir name="Schema">
<file name="Base.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Server/Schema -->
- <file name="Search.php" role="php" />
<dir name="Search">
<file name="Base.php" role="php" />
+ <file name="Interface.php" role="php" />
+ <dir name="Operation">
+ <file name="Addressesforuidormail.php" role="php" />
+ <file name="Attributes.php" role="php" />
+ <file name="Base.php" role="php" />
+ <file name="Children.php" role="php" />
+ <dir name="Constraint">
+ <file name="Single.php" role="php" />
+ <file name="Strict.php" role="php" />
+ </dir> <!-- /lib/Horde/Kolab/Server/Search/Operation/Constraint -->
+ <file name="Guid.php" role="php" />
+ <file name="Guidforalias.php" role="php" />
+ <file name="Guidforcn.php" role="php" />
+ <file name="Guidforkolabusers.php" role="php" />
+ <file name="Guidformailoralias.php" role="php" />
+ <file name="Guidformail.php" role="php" />
+ <file name="Guidforuidormailoralias.php" role="php" />
+ <file name="Guidforuidormail.php" role="php" />
+ <file name="Guidforuid.php" role="php" />
+ <file name="Interface.php" role="php" />
+ <file name="Mailforuidormail.php" role="php" />
+ <file name="Restrictkolab.php" role="php" />
+ </dir> <!-- /lib/Horde/Kolab/Server/Search/Operation -->
</dir> <!-- /lib/Horde/Kolab/Server/Search -->
- <file name="Structure.php" role="php" />
<dir name="Structure">
<file name="Base.php" role="php" />
+ <file name="Interface.php" role="php" />
<file name="Kolab.php" role="php" />
<file name="Ldap.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Server/Structure -->
<dir name="Kolab">
<dir name="Server">
<file name="AllTests.php" role="test" />
- <dir name="Attribute">
- <file name="BaseTest.php" role="php" />
- <file name="ValueTest.php" role="php" />
- </dir> <!-- /test/Horde/Kolab/Server/Attribute -->
<file name="Autoload.php" role="test" />
<dir name="Class">
<dir name="Server">
+ <dir name="Connection">
+ <file name="MockTest.php" role="test" />
+ <file name="SimpleldapTest.php" role="php" />
+ <file name="SplittedldapTest.php" role="php" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Connection -->
<dir name="Factory">
<file name="CleanerTest.php" role="test" />
<file name="ConfigurationTest.php" role="test" />
<file name="StandardTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Server/Class/Server/Ldap -->
<file name="LoggedTest.php" role="test" />
+ <dir name="Object">
+ <dir name="Attribute">
+ <file name="BaseTest.php" role="php" />
+ <file name="ValueTest.php" role="php" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Object/Attribute -->
+ <file name="BaseTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Object -->
+ <dir name="Query">
+ <file name="ElementTest.php" role="test" />
+ <file name="LdapTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Query -->
<dir name="Result">
<file name="LdapTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Server/Class/Server/Result -->
</dir> <!-- /test/Horde/Kolab/Server/Class/Server/Structure -->
</dir> <!-- /test/Horde/Kolab/Server/Class/Server -->
</dir> <!-- /test/Horde/Kolab/Server/Class -->
- <dir name="Connection">
- <file name="MockTest.php" role="test" />
- <file name="SimpleldapTest.php" role="php" />
- <file name="SplittedldapTest.php" role="php" />
- </dir> <!-- /test/Horde/Kolab/Server/Connection -->
<dir name="Integration">
<file name="AddingObjectsTest.php" role="test" />
<file name="AdminTest.php" role="test" />
<file name="Kolabpop3accountTest.php" role="test" />
<file name="MockTest.php" role="test" />
<file name="ObjectTest.php" role="test" />
+ <file name="ObjectsTest.php" role="test" />
<file name="OrgPersonTest.php" role="test" />
<file name="PersonTest.php" role="test" />
<file name="Scenario.php" role="test" />
<file name="UserTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Server/Integration -->
<file name="LdapTestCase.php" role="test" />
- <dir name="Object">
- <file name="BaseTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Object -->
- <dir name="Objects">
- <file name="ServerTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Objects -->
- <dir name="Query">
- <file name="ElementTest.php" role="test" />
- <file name="LdapTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Query -->
</dir> <!-- /test/Horde/Kolab/Server -->
</dir> <!-- /test/Horde/Kolab -->
</dir> <!-- /test/Horde -->
<install name="lib/Horde/Kolab/Server/Connection.php" as="Horde/Kolab/Server/Connection.php" />
<install name="lib/Horde/Kolab/Server/Connection/File.php" as="Horde/Kolab/Server/Connection/File.php" />
<install name="lib/Horde/Kolab/Server/Connection/Mock.php" as="Horde/Kolab/Server/Connection/Mock.php" />
+ <install name="lib/Horde/Kolab/Server/Connection/Mock/Ldap.php" as="Horde/Kolab/Server/Connection/Mock/Ldap.php" />
<install name="lib/Horde/Kolab/Server/Connection/Mock/Search.php" as="Horde/Kolab/Server/Connection/Mock/Search.php" />
<install name="lib/Horde/Kolab/Server/Connection/Simpleldap.php" as="Horde/Kolab/Server/Connection/Simpleldap.php" />
<install name="lib/Horde/Kolab/Server/Connection/Splittedldap.php" as="Horde/Kolab/Server/Connection/Splittedldap.php" />
<install name="lib/Horde/Kolab/Server/Object/Kolab/User.php" as="Horde/Kolab/Server/Object/Kolab/User.php" />
<install name="lib/Horde/Kolab/Server/Object/Organizationalperson.php" as="Horde/Kolab/Server/Object/Organizationalperson.php" />
<install name="lib/Horde/Kolab/Server/Object/Person.php" as="Horde/Kolab/Server/Object/Person.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search.php" as="Horde/Kolab/Server/Object/Search.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Addressesforuidormail.php" as="Horde/Kolab/Server/Object/Search/Addressesforuidormail.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Attributes.php" as="Horde/Kolab/Server/Object/Search/Attributes.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Base.php" as="Horde/Kolab/Server/Object/Search/Base.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Children.php" as="Horde/Kolab/Server/Object/Search/Children.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Constraint/Single.php" as="Horde/Kolab/Server/Object/Search/Constraint/Single.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Constraint/Strict.php" as="Horde/Kolab/Server/Object/Search/Constraint/Strict.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guid.php" as="Horde/Kolab/Server/Object/Search/Guid.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidforalias.php" as="Horde/Kolab/Server/Object/Search/Guidforalias.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidforcn.php" as="Horde/Kolab/Server/Object/Search/Guidforcn.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidforkolabusers.php" as="Horde/Kolab/Server/Object/Search/Guidforkolabusers.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidformailoralias.php" as="Horde/Kolab/Server/Object/Search/Guidformailoralias.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidformail.php" as="Horde/Kolab/Server/Object/Search/Guidformail.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidforuidormailoralias.php" as="Horde/Kolab/Server/Object/Search/Guidforuidormailoralias.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidforuidormail.php" as="Horde/Kolab/Server/Object/Search/Guidforuidormail.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Guidforuid.php" as="Horde/Kolab/Server/Object/Search/Guidforuid.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Mailforuidormail.php" as="Horde/Kolab/Server/Object/Search/Mailforuidormail.php" />
- <install name="lib/Horde/Kolab/Server/Object/Search/Restrictkolab.php" as="Horde/Kolab/Server/Object/Search/Restrictkolab.php" />
<install name="lib/Horde/Kolab/Server/Object/Searches.php" as="Horde/Kolab/Server/Object/Searches.php" />
<install name="lib/Horde/Kolab/Server/Object/Top.php" as="Horde/Kolab/Server/Object/Top.php" />
<install name="lib/Horde/Kolab/Server/Objects.php" as="Horde/Kolab/Server/Objects.php" />
<install name="lib/Horde/Kolab/Server/Result/Ldap.php" as="Horde/Kolab/Server/Result/Ldap.php" />
<install name="lib/Horde/Kolab/Server/Schema.php" as="Horde/Kolab/Server/Schema.php" />
<install name="lib/Horde/Kolab/Server/Schema/Base.php" as="Horde/Kolab/Server/Schema/Base.php" />
- <install name="lib/Horde/Kolab/Server/Search.php" as="Horde/Kolab/Server/Search.php" />
<install name="lib/Horde/Kolab/Server/Search/Base.php" as="Horde/Kolab/Server/Search/Base.php" />
- <install name="lib/Horde/Kolab/Server/Structure.php" as="Horde/Kolab/Server/Structure.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Interface.php" as="Horde/Kolab/Server/Search/Interface.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Addressesforuidormail.php" as="Horde/Kolab/Server/Search/Operation/Addressesforuidormail.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Attributes.php" as="Horde/Kolab/Server/Search/Operation/Attributes.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Base.php" as="Horde/Kolab/Server/Search/Operation/Base.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Children.php" as="Horde/Kolab/Server/Search/Operation/Children.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Constraint/Single.php" as="Horde/Kolab/Server/Search/Operation/Constraint/Single.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Constraint/Strict.php" as="Horde/Kolab/Server/Search/Operation/Constraint/Strict.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guid.php" as="Horde/Kolab/Server/Search/Operation/Guid.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidforalias.php" as="Horde/Kolab/Server/Search/Operation/Guidforalias.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidforcn.php" as="Horde/Kolab/Server/Search/Operation/Guidforcn.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidforkolabusers.php" as="Horde/Kolab/Server/Search/Operation/Guidforkolabusers.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidformailoralias.php" as="Horde/Kolab/Server/Search/Operation/Guidformailoralias.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidformail.php" as="Horde/Kolab/Server/Search/Operation/Guidformail.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidforuidormailoralias.php" as="Horde/Kolab/Server/Search/Operation/Guidforuidormailoralias.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidforuidormail.php" as="Horde/Kolab/Server/Search/Operation/Guidforuidormail.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Guidforuid.php" as="Horde/Kolab/Server/Search/Operation/Guidforuid.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Interface.php" as="Horde/Kolab/Server/Search/Operation/Interface.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Mailforuidormail.php" as="Horde/Kolab/Server/Search/Operation/Mailforuidormail.php" />
+ <install name="lib/Horde/Kolab/Server/Search/Operation/Restrictkolab.php" as="Horde/Kolab/Server/Search/Operation/Restrictkolab.php" />
<install name="lib/Horde/Kolab/Server/Structure/Base.php" as="Horde/Kolab/Server/Structure/Base.php" />
+ <install name="lib/Horde/Kolab/Server/Structure/Interface.php" as="Horde/Kolab/Server/Structure/Interface.php" />
<install name="lib/Horde/Kolab/Server/Structure/Kolab.php" as="Horde/Kolab/Server/Structure/Kolab.php" />
<install name="lib/Horde/Kolab/Server/Structure/Ldap.php" as="Horde/Kolab/Server/Structure/Ldap.php" />
<install name="test/Horde/Kolab/Server/AllTests.php" as="Horde/Kolab/Server/AllTests.php" />
- <install name="test/Horde/Kolab/Server/Attribute/BaseTest.php" as="Horde/Kolab/Server/Attribute/BaseTest.php" />
- <install name="test/Horde/Kolab/Server/Attribute/ValueTest.php" as="Horde/Kolab/Server/Attribute/ValueTest.php" />
<install name="test/Horde/Kolab/Server/Autoload.php" as="Horde/Kolab/Server/Autoload.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php" as="Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Object/Attribute/ValueTest.php" as="Horde/Kolab/Server/Class/Server/Object/Attribute/ValueTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Connection/MockTest.php" as="Horde/Kolab/Server/Class/Server/Connection/MockTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Connection/SimpleldapTest.php" as="Horde/Kolab/Server/Class/Server/Connection/SimpleldapTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Connection/SplittedldapTest.php" as="Horde/Kolab/Server/Class/Server/Connection/SplittedldapTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php" as="Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php" as="Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php" as="Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Ldap/FilteredTest.php" as="Horde/Kolab/Server/Class/Server/Ldap/FilteredTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Ldap/StandardTest.php" as="Horde/Kolab/Server/Class/Server/Ldap/StandardTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/LoggedTest.php" as="Horde/Kolab/Server/Class/Server/LoggedTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php" as="Horde/Kolab/Server/Class/Server/Object/BaseTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Query/ElementTest.php" as="Horde/Kolab/Server/Class/Server/Query/ElementTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php" as="Horde/Kolab/Server/Class/Server/Query/LdapTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Result/LdapTest.php" as="Horde/Kolab/Server/Class/Server/Result/LdapTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Search/BaseTest.php" as="Horde/Kolab/Server/Class/Server/Search/BaseTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php" as="Horde/Kolab/Server/Class/Server/Structure/KolabTest.php" />
<install name="test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php" as="Horde/Kolab/Server/Class/Server/Structure/LdapTest.php" />
- <install name="test/Horde/Kolab/Server/Connection/MockTest.php" as="Horde/Kolab/Server/Connection/MockTest.php" />
- <install name="test/Horde/Kolab/Server/Connection/SimpleldapTest.php" as="Horde/Kolab/Server/Connection/SimpleldapTest.php" />
- <install name="test/Horde/Kolab/Server/Connection/SplittedldapTest.php" as="Horde/Kolab/Server/Connection/SplittedldapTest.php" />
<install name="test/Horde/Kolab/Server/Integration/AddingObjectsTest.php" as="Horde/Kolab/Server/Integration/AddingObjectsTest.php" />
<install name="test/Horde/Kolab/Server/Integration/AdminTest.php" as="Horde/Kolab/Server/Integration/AdminTest.php" />
<install name="test/Horde/Kolab/Server/Integration/DistListHandlingTest.php" as="Horde/Kolab/Server/Integration/DistListHandlingTest.php" />
<install name="test/Horde/Kolab/Server/Integration/Kolabpop3accountTest.php" as="Horde/Kolab/Server/Integration/Kolabpop3accountTest.php" />
<install name="test/Horde/Kolab/Server/Integration/MockTest.php" as="Horde/Kolab/Server/Integration/MockTest.php" />
<install name="test/Horde/Kolab/Server/Integration/ObjectTest.php" as="Horde/Kolab/Server/Integration/ObjectTest.php" />
+ <install name="test/Horde/Kolab/Server/Integration/ObjectsTest.php" as="Horde/Kolab/Server/Integration/ObjectsTest.php" />
<install name="test/Horde/Kolab/Server/Integration/OrgPersonTest.php" as="Horde/Kolab/Server/Integration/OrgPersonTest.php" />
<install name="test/Horde/Kolab/Server/Integration/PersonTest.php" as="Horde/Kolab/Server/Integration/PersonTest.php" />
<install name="test/Horde/Kolab/Server/Integration/Scenario.php" as="Horde/Kolab/Server/Integration/Scenario.php" />
<install name="test/Horde/Kolab/Server/Integration/UserHandlingTest.php" as="Horde/Kolab/Server/Integration/UserHandlingTest.php" />
<install name="test/Horde/Kolab/Server/Integration/UserTest.php" as="Horde/Kolab/Server/Integration/UserTest.php" />
<install name="test/Horde/Kolab/Server/LdapTestCase.php" as="Horde/Kolab/Server/LdapTestCase.php" />
- <install name="test/Horde/Kolab/Server/Object/BaseTest.php" as="Horde/Kolab/Server/Object/BaseTest.php" />
- <install name="test/Horde/Kolab/Server/Objects/ServerTest.php" as="Horde/Kolab/Server/Objects/ServerTest.php" />
- <install name="test/Horde/Kolab/Server/Query/ElementTest.php" as="Horde/Kolab/Server/Query/ElementTest.php" />
- <install name="test/Horde/Kolab/Server/Query/LdapTest.php" as="Horde/Kolab/Server/Query/LdapTest.php" />
</filelist>
</phprelease>
<changelog>
+++ /dev/null
-<?php
-/**
- * Test the base attribute.
- *
- * 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
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../TestCase.php';
-
-/**
- * Test the base attribute.
- *
- * 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_Attribute_BaseTest extends Horde_Kolab_Server_TestCase
-{
- public function setUp()
- {
- $this->object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->composite = $this->getMockedComposite();
- }
-
- public function testMethodConstructHasParameterObjectTheObjectOwningTheAttributeAndParameterCompositeWhichIsTheLinkToTheServer()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, '');
- }
-
- public function testMethodConstructHasParameterStringTheNameOfTheAttribute()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- }
-
- public function testMethodGetobjectReturnsObjectAssociatedWithThisAttribute()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, '');
- $this->assertType('Horde_Kolab_Server_Object', $attribute->getObject());
- }
-
- public function testMethodGetnameReturnsStringTheNameOfTheAttribute()
- {
- $this->composite->structure->expects($this->exactly(1))
- ->method('getInternalAttribute')
- ->with('name')
- ->will($this->returnValue('name'));
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $this->assertEquals('name', $attribute->getInternalName());
- }
-
- public function testMethodIsemptyHasParameterArrayDataValues()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $attribute->isEmpty(array());
- }
-
- public function testMethodIsemptyReturnsFalseIfTheValueIndicatedByTheAttributeNameIsNotEmptyInTheDataArray()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name', 'name');
- $this->assertFalse($attribute->isEmpty(array('name' => 'HELLO')));
- }
-
- public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsMissingInTheDataArray()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $this->assertTrue($attribute->isEmpty(array()));
- }
-
- public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsStringEmptyInTheDataArray()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $this->assertTrue($attribute->isEmpty(array('name' => '')));
- }
-
- public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsNullInTheDataArray()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $this->assertTrue($attribute->isEmpty(array('name' => null)));
- }
-
- public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsEmptyArrayInTheDataArray()
- {
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $this->assertTrue($attribute->isEmpty(array('name' => array())));
- }
-}
-
-class Attribute_Mock extends Horde_Kolab_Server_Object_Attribute_Base
-{
- public function value() {}
- public function update(array $changes) {}
- public function consume(array &$changes) {}
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the value attribute.
- *
- * 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
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the value attribute.
- *
- * 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_Attribute_ValueTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->composite = $this->getMock(
- 'Horde_Kolab_Server_Composite', array(), array(), '', false
- );
-
- $this->markTestIncomplete('Needs to be fixed');
- }
-
- public function testMethodValueHasResultArrayTheValuesOfTheAttribute()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will($this->returnValue(array(1, 2)));
- $this->assertEquals(array(1, 2), $attribute->value());
- }
-
- public function testMethodConsumeHasParameterArrayData()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $data = array();
- $attribute->consume($data);
- }
-
- public function testMethodConsumeHasPostconditionThatTheAttributeValueHasBeenRemovedFromTheDataArray()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name', 'name'
- );
- $data = array('name' => 'test');
- $attribute->consume($data);
- $this->assertEquals(array(), $data);
- }
-
- public function testMethodChangesHasParameterArrayData()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(false));
- $data = array();
- $attribute->update($data);
- }
-
- public function testMethodChangesHasResultArrayEmptyIfTheObjectDoesNotExistAndThereAreNoChangesToTheAttribute()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(false));
- $data = array();
- $this->assertEquals(array(), $attribute->update($data));
- }
-
- public function testMethodChangesHasResultArrayWithAddedValuesIfTheObjectDoesNotExistAndThereAreChangesToTheAttribute()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name', 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(false));
- $data = array('name' => 'a');
- $this->assertEquals(
- array(array('name' => array('a'))),
- $attribute->update($data)
- );
- }
-
- public function testMethodChangesHasResultArrayWithAddedValuesIfTheObjectExistsButHadNoValueForTheAttributeAndThereAreNoChangesToTheAttribute()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(true));
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will(
- $this->throwException(
- new Horde_Kolab_Server_Exception_Novalue('')
- )
- );
- $data = array();
- $this->assertEquals(array(), $attribute->update($data));
- }
-
- public function testMethodChangesHasResultArrayWithAddedValuesIfTheObjectExistsButHadNoValueForTheAttributeAndThereAreChangesToTheAttribute()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(true));
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will(
- $this->throwException(
- new Horde_Kolab_Server_Exception_Novalue('')
- )
- );
- $data = array('name' => 'a');
- $this->assertEquals(
- array('add' => array('name' => array('a'))),
- $attribute->update($data)
- );
- }
-
- public function testMethodChangesHasResultArrayWithDeletedValuesIfTheObjectExistsAndHadAValueForTheAttributeAndTheNewValueIsEmpty()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(true));
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will($this->returnValue(array('a')));
- $data = array('name' => null);
- $this->assertEquals(
- array('delete' => array('name' => array('a'))),
- $attribute->update($data)
- );
- }
-
- public function testMethodChangesHasResultArrayWithReplacedValuesIfTheObjectExistsAndHadASingleValueForTheAttributeAndTheNewValueHasASingleNewValue()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(true));
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will($this->returnValue(array('a')));
- $data = array('name' => array('b'));
- $this->assertEquals(
- array('replace' => array('name' => array('b'))),
- $attribute->update($data)
- );
- }
-
- public function testMethodChangesHasResultArrayEmptyIfTheObjectExistsAndHadASingleValueForTheAttributeAndTheNewValueHasASingleNewValueAndBothAreEqual()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(true));
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will($this->returnValue(array('a')));
- $data = array('name' => array('a'));
- $this->assertEquals(array(), $attribute->update($data));
- }
-
- public function testMethodChangesHasResultArrayWithAddedAndDeletedValuesIfTheObjectExistsAndHadValuesForTheAttributeAndNewValuesHaveBeenProvided()
- {
- $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
- $this->object, $this->composite, 'name'
- );
- $this->object->expects($this->once())
- ->method('exists')
- ->with()
- ->will($this->returnValue(true));
- $this->object->expects($this->once())
- ->method('getInternal')
- ->with('name')
- ->will($this->returnValue(array('a', 'c')));
- $data = array('name' => array('b', 'c', 'd'));
- $this->assertEquals(
- array(
- 'add' => array('name' => array('b', 'd')),
- 'delete' => array('name' => array('a'))
- ),
- $attribute->update($data)
- );
- }
-}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the cleanup decorator for the server.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../Autoload.php';
+
+/**
+ * Test the cleanup decorator for the server.
+ *
+ * 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_CleanerTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->server = $this->getMock('Horde_Kolab_Server');
+ $this->cleaner = new Horde_Kolab_Server_Cleaner($this->server);
+ }
+
+ public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('base', $this->cleaner->getBaseGuid());
+ }
+
+ public function testMethodGetuidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getGuid')
+ ->will($this->returnValue('guid'));
+ $this->assertEquals('guid', $this->cleaner->getGuid());
+ }
+
+ public function testMethodConnectguidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('connectGuid')
+ ->with('user', 'pass');
+ $this->cleaner->connectGuid('user', 'pass');
+ }
+
+ public function testMethodReadHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array()));
+ $this->assertEquals(array(), $this->cleaner->read('guid'));
+ }
+
+ public function testMethodReadattributesHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('readAttributes')
+ ->with('guid', array('a'))
+ ->will($this->returnValue(array()));
+ $this->assertEquals(
+ array(), $this->cleaner->readAttributes('guid', array('a'))
+ );
+ }
+
+ public function testMethodFindHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result');
+ $query = $this->getMock(
+ 'Horde_Kolab_Server_Query_Element', array(), array(), '', false
+ );
+ $this->server->expects($this->exactly(1))
+ ->method('find')
+ ->with($query)
+ ->will($this->returnValue($result));
+ $this->assertType(
+ 'Horde_Kolab_Server_Result',
+ $this->cleaner->find($query)
+ );
+ }
+
+ public function testMethodFindbelowHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result');
+ $query = $this->getMock(
+ 'Horde_Kolab_Server_Query_Element', array(), array(), '', false
+ );
+ $this->server->expects($this->exactly(1))
+ ->method('findBelow')
+ ->with($query, 'none')
+ ->will($this->returnValue($result));
+ $this->assertType(
+ 'Horde_Kolab_Server_Result',
+ $this->cleaner->findBelow($query, 'none')
+ );
+ }
+
+ public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->server->expects($this->exactly(1))
+ ->method('save')
+ ->with($object, array('a' => 'a'));
+ $this->cleaner->save($object, array('a' => 'a'));
+ }
+
+ public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->server->expects($this->exactly(1))
+ ->method('add')
+ ->with($object, array('a' => 'a'));
+ $this->cleaner->add($object, array('a' => 'a'));
+ }
+
+ public function testMethodDeleteHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('delete')
+ ->with('a');
+ $this->cleaner->delete('a');
+ }
+
+ public function testMethodRenameHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('rename')
+ ->with('a', 'b');
+ $this->cleaner->rename('a', 'b');
+ }
+
+ public function testMethodGetschemaHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getSchema');
+ $this->cleaner->getSchema();
+ }
+
+ public function testMethodGetparentguidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getParentGuid')
+ ->will($this->returnValue('parent'));
+ $this->assertEquals('parent', $this->cleaner->getParentGuid('child'));
+ }
+
+ public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsRememberedAndDeletedOnDestruction()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $object->expects($this->exactly(1))
+ ->method('getGuid')
+ ->will($this->returnValue('a'));
+ $this->server->expects($this->exactly(1))
+ ->method('add')
+ ->with($object, array('a' => 'a'));
+ $this->server->expects($this->exactly(1))
+ ->method('delete')
+ ->with('a');
+ $this->cleaner->add($object, array('a' => 'a'));
+ unset($this->cleaner);
+ }
+
+ public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsNotDeletedOnDestructionIfItWasDeletedBefore()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $object->expects($this->exactly(1))
+ ->method('getGuid')
+ ->will($this->returnValue('a'));
+ $this->server->expects($this->exactly(1))
+ ->method('add')
+ ->with($object, array('a' => 'a'));
+ $this->server->expects($this->exactly(1))
+ ->method('delete')
+ ->with('a');
+ $this->cleaner->add($object, array('a' => 'a'));
+ $this->cleaner->delete('a');
+ unset($this->cleaner);
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the composite server.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../TestCase.php';
+
+/**
+ * Test the composite server.
+ *
+ * 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_CompositeTest extends Horde_Kolab_Server_TestCase
+{
+ public function testMethodGetReturnsServerElement()
+ {
+ $composite = $this->getMockedComposite();
+ $this->assertType('Horde_Kolab_Server', $composite->server);
+ $this->assertType('Horde_Kolab_Server_Objects', $composite->objects);
+ $this->assertType('Horde_Kolab_Server_Structure_Interface', $composite->structure);
+ $this->assertType('Horde_Kolab_Server_Search_Interface', $composite->search);
+ $this->assertType('Horde_Kolab_Server_Schema', $composite->schema);
+ try {
+ $a = $composite->something;
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals(
+ 'Attribute something not supported!', $e->getMessage()
+ );
+ }
+ }
+
+ public function testMethodConnectHasPostconditionThatTheServerIsBound()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->server->expects($this->exactly(2))
+ ->method('connectGuid');
+ $composite->search->expects($this->exactly(1))
+ ->method('__call')
+ ->with('searchGuidForUidOrMail', array('user'));
+ $composite->connect('user', 'pass');
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the test driver.
+ *
+ * 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__) . '/../../../../LdapTestCase.php';
+
+/**
+ * Test the test backend.
+ *
+ * Copyright 2008-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_Connection_Mock_LdapTest
+extends Horde_Kolab_Server_LdapTestCase
+{
+ /**
+ * Test parsing of LDAP filters.
+ *
+ * @return NULL
+ */
+ public function testFilterParse()
+ {
+ $this->skipIfNoLdap();
+
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(array(), array());
+
+ $a = $conn->parse('(a=b)');
+ $this->assertEquals(array('att' => 'a', 'log' => '=', 'val' => 'b'),
+ $a);
+
+ $a = $conn->parse('(&(a=b)(c=d))');
+ $this->assertEquals(array('op' => '&', 'sub' => array(
+ array('att' => 'a', 'log' => '=', 'val' => 'b'),
+ array('att' => 'c', 'log' => '=', 'val' => 'd'),
+ )), $a);
+
+ $a = $conn->parse('(&(a=1)(|(b=2)(c=3)))');
+ $this->assertEquals(array('op' => '&', 'sub' => array(
+ array('att' => 'a', 'log' => '=', 'val' => '1'),
+ array('op' => '|', 'sub' =>
+ array(
+ array('att' => 'b', 'log' => '=', 'val' => '2'),
+ array('att' => 'c', 'log' => '=', 'val' => '3'),
+ )))), $a);
+
+ $a = $conn->parseSub('(!(x=2))(b=1)');
+ $this->assertEquals(array(array('op' => '!', 'sub' =>
+ array(
+ array('att' => 'x', 'log' => '=', 'val' => '2'),
+ )
+ ),
+ array('att' => 'b', 'log' => '=', 'val' => '1'),
+ ), $a);
+
+ $a = $conn->parse('(&(!(x=2))(b=1))');
+ $this->assertEquals(array('op' => '&', 'sub' => array(
+ array('op' => '!', 'sub' =>
+ array(
+ array('att' => 'x', 'log' => '=', 'val' => '2'),
+ )
+ ),
+ array('att' => 'b', 'log' => '=', 'val' => '1'),
+ )), $a);
+
+ }
+
+ /**
+ * Test searching in the simulated LDAP data.
+ *
+ * @return NULL
+ */
+ public function testSearch()
+ {
+ $this->skipIfNoLdap();
+
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array(
+ 'cn=a' => array(
+ 'dn' => 'cn=a',
+ 'data' => array(
+ 'a' => '1',
+ 'b' => '1',
+ 'c' => '1',
+ )
+ ),
+ 'cn=b' => array(
+ 'dn' => 'cn=b',
+ 'data' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'c' => '2',
+ )
+ ),
+ 'cn=c' => array(
+ 'dn' => 'cn=c',
+ 'data' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'c' => '3',
+ )
+ ),
+ 'cn=d' => array(
+ 'dn' => 'cn=d',
+ 'data' => array(
+ 'a' => '2',
+ 'b' => '2',
+ 'c' => '1',
+ )
+ ),
+ )
+ );
+ $conn->bind();
+
+ $a = $conn->search(null, '(c=1)');
+ $this->assertEquals(
+ array(
+ 'cn=a' => array(
+ 'a' => '1',
+ 'b' => '1',
+ 'c' => '1',
+ 'dn' => 'cn=a',
+ ),
+ 'cn=d' => array(
+ 'a' => '2',
+ 'b' => '2',
+ 'c' => '1',
+ 'dn' => 'cn=d',
+ ),
+ ),
+ $a->as_struct()
+ );
+
+ $a = $conn->search(null, '(c=3)');
+ $this->assertEquals(
+ array(
+ 'cn=c' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'c' => '3',
+ 'dn' => 'cn=c',
+ ),
+ ),
+ $a->as_struct()
+ );
+
+ $a = $conn->search(null, '(c=3)', array('attributes' => array('a')));
+ $this->assertEquals(
+ array(
+ 'cn=c' => array(
+ 'a' => '1',
+ 'dn' => 'cn=c',
+ ),
+ ),
+ $a->as_struct()
+ );
+
+ $a = $conn->search(null, '(&(a=1)(b=2))', array('attributes' => array('a', 'b')));
+ $this->assertEquals(
+ array(
+ 'cn=b' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'dn' => 'cn=b',
+ ),
+ 'cn=c' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'dn' => 'cn=c',
+ ),
+ ),
+ $a->as_struct()
+ );
+
+ $a = $conn->search(null, '(&(b=2))', array('attributes' => array('b')));
+ $this->assertEquals(
+ array(
+ 'cn=b' => array(
+ 'b' => '2',
+ 'dn' => 'cn=b',
+ ),
+ 'cn=c' => array(
+ 'b' => '2',
+ 'dn' => 'cn=c',
+ ),
+ 'cn=d' => array(
+ 'b' => '2',
+ 'dn' => 'cn=d',
+ ),
+ ),
+ $a->as_struct()
+ );
+
+ $a = $conn->search(null, '(!(b=2))', array('attributes' => array('a', 'b')));
+ $this->assertEquals(
+ array(
+ 'cn=a' => array(
+ 'a' => '1',
+ 'b' => '1',
+ 'dn' => 'cn=a',
+ ),
+ ),
+ $a->as_struct()
+ );
+
+ $a = $conn->search(null, '(&(!(x=2))(b=1))', array('attributes' => array('b')));
+ $this->assertEquals(
+ array(
+ 'cn=a' => array(
+ 'b' => '1',
+ 'dn' => 'cn=a',
+ ),
+ ),
+ $a->as_struct()
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Test the handler for a mock connection.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the handler for a mock connection.
+ *
+ * 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_Connection_MockTest
+extends PHPUnit_Framework_TestCase
+{
+ public function testMethodConstructHasParameterMockldapConnection()
+ {
+ $ldap = $this->getMock(
+ 'Horde_Kolab_Server_Connection_Mock_Ldap',
+ array(), array(), '', false, false
+ );
+ $conn = new Horde_Kolab_Server_Connection_Mock($ldap);
+ }
+
+ public function testMethodConstructHasPostconditionThatTheGivenServerWasStored()
+ {
+ $ldap = $this->getMock(
+ 'Horde_Kolab_Server_Connection_Mock_Ldap',
+ array(), array(), '', false, false
+ );
+ $conn = new Horde_Kolab_Server_Connection_Mock($ldap);
+ $this->assertSame($ldap, $conn->getRead());
+ }
+
+ public function testMethodGetreadHasResultMockldapTheHandledConnection()
+ {
+ $ldap = $this->getMock(
+ 'Horde_Kolab_Server_Connection_Mock_Ldap',
+ array(), array(), '', false, false
+ );
+ $conn = new Horde_Kolab_Server_Connection_Mock($ldap);
+ $this->assertType('Horde_Kolab_Server_Connection_Mock_Ldap', $conn->getRead());
+ }
+
+ public function testMethodGetwriteHasResultMockldapTheHandledConnection()
+ {
+ $ldap = $this->getMock(
+ 'Horde_Kolab_Server_Connection_Mock_Ldap',
+ array(), array(), '', false, false
+ );
+ $conn = new Horde_Kolab_Server_Connection_Mock($ldap);
+ $this->assertSame($conn->getWrite(), $conn->getRead());
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the handler for a simple LDAP setup without read-only slaves.
+ *
+ * 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__) . '/../../../LdapTestCase.php';
+
+/**
+ * Test the handler for a simple LDAP setup without read-only slaves.
+ *
+ * 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_Connection_SimpleldapTest
+extends Horde_Kolab_Server_LdapTestCase
+{
+ public function testMethodConstructHasParameterNetldap2Connection()
+ {
+ $ldap = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
+ }
+
+ public function testMethodConstructHasPostconditionThatTheGivenServerWasStored()
+ {
+ $ldap = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
+ $this->assertSame($ldap, $conn->getRead());
+ }
+
+ public function testMethodGetreadHasResultNetldap2TheHandledConnection()
+ {
+ $ldap = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
+ $this->assertType('Net_LDAP2', $conn->getRead());
+ }
+
+ public function testMethodGetwriteHasResultNetldap2TheHandledConnection()
+ {
+ $ldap = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
+ $this->assertSame($conn->getWrite(), $conn->getRead());
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the handler for a LDAP master/slave setup.
+ *
+ * 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__) . '/../../../LdapTestCase.php';
+
+/**
+ * Test the handler for a LDAP master/slave setup.
+ *
+ * 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_Connection_SplittedldapTest
+extends Horde_Kolab_Server_LdapTestCase
+{
+ public function testMethodConstructHasParameterNetldap2ReadConnectionAndParameterNetldap2WriteConnection()
+ {
+ $ldap_read = $this->getMock('Net_LDAP2');
+ $ldap_write = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
+ }
+
+ public function testMethodConstructHasPostconditionThatTheGivenServersWereStored()
+ {
+ $ldap_read = $this->getMock('Net_LDAP2');
+ $ldap_write = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
+ $this->assertSame($ldap_read, $conn->getRead());
+ $this->assertSame($ldap_write, $conn->getWrite());
+ }
+
+ public function testMethodGetreadHasResultNetldap2TheHandledConnection()
+ {
+ $ldap_read = $this->getMock('Net_LDAP2');
+ $ldap_write = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
+ $this->assertType('Net_LDAP2', $conn->getRead());
+ $this->assertType('Net_LDAP2', $conn->getWrite());
+ }
+
+ public function testMethodGetwriteHasResultNetldap2TheHandledConnection()
+ {
+ $ldap_read = $this->getMock('Net_LDAP2');
+ $ldap_write = $this->getMock('Net_LDAP2');
+ $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
+ $this->assertFalse($conn->getWrite() === $conn->getRead());
+ }
+}
array('basedn' => '')
);
$this->assertType(
- 'Horde_Kolab_Server_Structure',
+ 'Horde_Kolab_Server_Structure_Interface',
$factory->getStructure()
);
}
array('basedn' => '')
);
$this->assertType(
- 'Horde_Kolab_Server_Search',
+ 'Horde_Kolab_Server_Search_Interface',
$factory->getSearch()
);
}
public function testMethodGetconnectionHasResultConnectionmock()
{
$factory = new Horde_Kolab_Server_Factory_Conn_Mock();
- $factory->setConfiguration(array('basedn' => 'test'));
+ $factory->setConfiguration(
+ array(
+ 'basedn' => 'test',
+ 'data' => array()
+ )
+ );
$this->assertType(
'Horde_Kolab_Server_Connection_Mock',
$factory->getConnection()
parent::setUp();
$this->factory = $this->getMock('Horde_Kolab_Server_Factory_Conn');
$this->objects = $this->getMock('Horde_Kolab_Server_Objects');
- $this->structure = $this->getMock('Horde_Kolab_Server_Structure');
- $this->search = $this->getMock('Horde_Kolab_Server_Search');
+ $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface');
+ $this->search = $this->getMock('Horde_Kolab_Server_Search_Interface');
$this->schema = $this->getMock('Horde_Kolab_Server_Schema');
}
{
$factory = $this->_getFactory(array());
$this->assertType(
- 'Horde_Kolab_Server_Search',
+ 'Horde_Kolab_Server_Search_Interface',
$factory->getSearch()
);
}
--- /dev/null
+<?php
+/**
+ * Test the base attribute.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../TestCase.php';
+
+/**
+ * Test the base attribute.
+ *
+ * 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_Object_Attribute_BaseTest
+extends Horde_Kolab_Server_TestCase
+{
+ public function setUp()
+ {
+ $this->object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->composite = $this->getMockedComposite();
+ }
+
+ public function testMethodConstructHasParameterObjectTheObjectOwningTheAttributeAndParameterCompositeWhichIsTheLinkToTheServer()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, '');
+ }
+
+ public function testMethodConstructHasParameterStringTheNameOfTheAttribute()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ }
+
+ public function testMethodGetobjectReturnsObjectAssociatedWithThisAttribute()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, '');
+ $this->assertType('Horde_Kolab_Server_Object', $attribute->getObject());
+ }
+
+ public function testMethodGetnameReturnsStringTheNameOfTheAttribute()
+ {
+ $this->composite->structure->expects($this->exactly(1))
+ ->method('getInternalAttribute')
+ ->with('name')
+ ->will($this->returnValue('name'));
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $this->assertEquals('name', $attribute->getInternalName());
+ }
+
+ public function testMethodIsemptyHasParameterArrayDataValues()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute->isEmpty(array());
+ }
+
+ public function testMethodIsemptyReturnsFalseIfTheValueIndicatedByTheAttributeNameIsNotEmptyInTheDataArray()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name', 'name');
+ $this->assertFalse($attribute->isEmpty(array('name' => 'HELLO')));
+ }
+
+ public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsMissingInTheDataArray()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $this->assertTrue($attribute->isEmpty(array()));
+ }
+
+ public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsStringEmptyInTheDataArray()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $this->assertTrue($attribute->isEmpty(array('name' => '')));
+ }
+
+ public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsNullInTheDataArray()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $this->assertTrue($attribute->isEmpty(array('name' => null)));
+ }
+
+ public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsEmptyArrayInTheDataArray()
+ {
+ $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $this->assertTrue($attribute->isEmpty(array('name' => array())));
+ }
+}
+
+class Attribute_Mock extends Horde_Kolab_Server_Object_Attribute_Base
+{
+ public function value() {}
+ public function update(array $changes) {}
+ public function consume(array &$changes) {}
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the value attribute.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the value attribute.
+ *
+ * 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_Object_Attribute_ValueTest
+extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->composite = $this->getMock(
+ 'Horde_Kolab_Server_Composite', array(), array(), '', false
+ );
+
+ $this->markTestIncomplete('Needs to be fixed');
+ }
+
+ public function testMethodValueHasResultArrayTheValuesOfTheAttribute()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will($this->returnValue(array(1, 2)));
+ $this->assertEquals(array(1, 2), $attribute->value());
+ }
+
+ public function testMethodConsumeHasParameterArrayData()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $data = array();
+ $attribute->consume($data);
+ }
+
+ public function testMethodConsumeHasPostconditionThatTheAttributeValueHasBeenRemovedFromTheDataArray()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name', 'name'
+ );
+ $data = array('name' => 'test');
+ $attribute->consume($data);
+ $this->assertEquals(array(), $data);
+ }
+
+ public function testMethodChangesHasParameterArrayData()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(false));
+ $data = array();
+ $attribute->update($data);
+ }
+
+ public function testMethodChangesHasResultArrayEmptyIfTheObjectDoesNotExistAndThereAreNoChangesToTheAttribute()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(false));
+ $data = array();
+ $this->assertEquals(array(), $attribute->update($data));
+ }
+
+ public function testMethodChangesHasResultArrayWithAddedValuesIfTheObjectDoesNotExistAndThereAreChangesToTheAttribute()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name', 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(false));
+ $data = array('name' => 'a');
+ $this->assertEquals(
+ array(array('name' => array('a'))),
+ $attribute->update($data)
+ );
+ }
+
+ public function testMethodChangesHasResultArrayWithAddedValuesIfTheObjectExistsButHadNoValueForTheAttributeAndThereAreNoChangesToTheAttribute()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(true));
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will(
+ $this->throwException(
+ new Horde_Kolab_Server_Exception_Novalue('')
+ )
+ );
+ $data = array();
+ $this->assertEquals(array(), $attribute->update($data));
+ }
+
+ public function testMethodChangesHasResultArrayWithAddedValuesIfTheObjectExistsButHadNoValueForTheAttributeAndThereAreChangesToTheAttribute()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(true));
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will(
+ $this->throwException(
+ new Horde_Kolab_Server_Exception_Novalue('')
+ )
+ );
+ $data = array('name' => 'a');
+ $this->assertEquals(
+ array('add' => array('name' => array('a'))),
+ $attribute->update($data)
+ );
+ }
+
+ public function testMethodChangesHasResultArrayWithDeletedValuesIfTheObjectExistsAndHadAValueForTheAttributeAndTheNewValueIsEmpty()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(true));
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will($this->returnValue(array('a')));
+ $data = array('name' => null);
+ $this->assertEquals(
+ array('delete' => array('name' => array('a'))),
+ $attribute->update($data)
+ );
+ }
+
+ public function testMethodChangesHasResultArrayWithReplacedValuesIfTheObjectExistsAndHadASingleValueForTheAttributeAndTheNewValueHasASingleNewValue()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(true));
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will($this->returnValue(array('a')));
+ $data = array('name' => array('b'));
+ $this->assertEquals(
+ array('replace' => array('name' => array('b'))),
+ $attribute->update($data)
+ );
+ }
+
+ public function testMethodChangesHasResultArrayEmptyIfTheObjectExistsAndHadASingleValueForTheAttributeAndTheNewValueHasASingleNewValueAndBothAreEqual()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(true));
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will($this->returnValue(array('a')));
+ $data = array('name' => array('a'));
+ $this->assertEquals(array(), $attribute->update($data));
+ }
+
+ public function testMethodChangesHasResultArrayWithAddedAndDeletedValuesIfTheObjectExistsAndHadValuesForTheAttributeAndNewValuesHaveBeenProvided()
+ {
+ $attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $this->object, $this->composite, 'name'
+ );
+ $this->object->expects($this->once())
+ ->method('exists')
+ ->with()
+ ->will($this->returnValue(true));
+ $this->object->expects($this->once())
+ ->method('getInternal')
+ ->with('name')
+ ->will($this->returnValue(array('a', 'c')));
+ $data = array('name' => array('b', 'c', 'd'));
+ $this->assertEquals(
+ array(
+ 'add' => array('name' => array('b', 'd')),
+ 'delete' => array('name' => array('a'))
+ ),
+ $attribute->update($data)
+ );
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the base object.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../TestCase.php';
+
+/**
+ * Test the base object.
+ *
+ * Copyright 2008-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_Object_BaseTest extends Horde_Kolab_Server_TestCase
+{
+ public function setUp()
+ {
+ }
+
+ public function testMethodConstructHasParameterCompositeWhichIsTheLinkToTheServer()
+ {
+ $composite = $this->getComposite();
+ $object = new Object_Mock($composite, '');
+ }
+
+ public function testMethodConstructHasParameterStringTheGuidOfTheObject()
+ {
+ $composite = $this->getComposite();
+ $object = new Object_Mock($composite, 'guid');
+ }
+
+ public function testGetguidHasResultStringGuidTheObjectIdOnTheServer()
+ {
+ $composite = $this->getComposite();
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertEquals('guid', $object->getGuid());
+ }
+
+ public function testGetguidThrowsExceptionIfGuidHasNotBeenSetYet()
+ {
+ $composite = $this->getComposite();
+ $object = new Object_Mock($composite);
+ try {
+ $this->assertEquals('newGuid', $object->getGuid());
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals(
+ 'Uninitialized object is missing GUID!', $e->getMessage()
+ );
+ }
+ }
+
+ public function testGetexternalattributesHasResultArrayTheExternalAttributesSupportedByTheObject()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getExternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('external')));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertEquals(array('external'), $object->getExternalAttributes());
+ }
+
+ public function testGetinternalattributesHasResultArrayTheInternalAttributesSupportedByTheObject()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('internal' => 'Internal')));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertEquals(array('internal' => 'Internal'), $object->getInternalAttributes());
+ }
+
+ public function testGetinternalattributesHasResultBooleanFalseIfTheGuidIsNotSpecified()
+ {
+ $composite = $this->getMockedComposite();
+ $object = new Object_Mock($composite);
+ $this->assertFalse($object->exists());
+ }
+
+ public function testGetinternalattributesHasResultBooleanFalseIfTheServerReturnedAnError()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('internal' => 'Internal')));
+ $composite->server->expects($this->once())
+ ->method('readAttributes')
+ ->with('guid', array('internal'))
+ ->will($this->throwException(new Horde_Kolab_Server_Exception('')));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertFalse($object->exists());
+ }
+
+ public function testGetinternalattributesHasResultBooleanTrueIfTheServerReturnedData()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('internal' => 'Internal')));
+ $composite->server->expects($this->once())
+ ->method('readAttributes')
+ ->with('guid', array('internal'))
+ ->will($this->returnValue(array('a' => 'a')));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertTrue($object->exists());
+ }
+
+ public function testReadinternalHasResultArrayDataTheInternalObjectData()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('internal' => 'Internal')));
+ $composite->server->expects($this->once())
+ ->method('readAttributes')
+ ->with('guid', array('internal'))
+ ->will($this->returnValue(array('internal' => 'test')));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertEquals(
+ array('internal' => 'test'), $object->readInternal()
+ );
+ }
+
+ public function testGetinternalHasResultArrayTheDataOfTheRequestedAttribute()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->exactly(2))
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('internal' => 'Internal')));
+ $composite->server->expects($this->once())
+ ->method('readAttributes')
+ ->with('guid', array('internal'))
+ ->will($this->returnValue(array('internal' => array('test'))));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertEquals(
+ array('test'), $object->getInternal('internal')
+ );
+ }
+
+ public function testGetinternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('internal' => 'Internal')));
+ $object = new Object_Mock($composite, 'guid');
+ try {
+ $object->getInternal('test');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Attribute "test" not supported!', $e->getMessage());
+ }
+ }
+
+ public function testGetinternalThrowsExceptionIfTheRequestedAttributeHasNoValue()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->exactly(2))
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will(
+ $this->returnValue(
+ array('internal' => 'Internal', 'test' => 'Test')
+ )
+ );
+ $composite->server->expects($this->once())
+ ->method('readAttributes')
+ ->with('guid', array('internal', 'test'))
+ ->will($this->returnValue(array('internal' => array('test'))));
+ $object = new Object_Mock($composite, 'guid');
+ try {
+ $object->getInternal('test');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception_Novalue $e) {
+ $this->assertEquals('No value for attribute "test"!', $e->getMessage());
+ }
+ }
+
+ public function testGetexternalHasResultArrayTheDataOfTheRequestedAttribute()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->structure->expects($this->exactly(1))
+ ->method('getInternalAttribute')
+ ->with('Objectclass')
+ ->will($this->returnValue('objectClass'));
+ $composite->schema->expects($this->exactly(1))
+ ->method('getExternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('Objectclass')));
+ $composite->schema->expects($this->exactly(2))
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('objectClass' => 'Objectclass')));
+ $composite->server->expects($this->once())
+ ->method('readAttributes')
+ ->with('guid', array('objectClass'))
+ ->will($this->returnValue(array('objectClass' => array('test'))));
+ $object = new Object_Mock($composite, 'guid');
+ $this->assertEquals(
+ array('test'), $object->getExternal('Objectclass')
+ );
+ }
+
+ public function testGetexternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getExternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('external')));
+ $object = new Object_Mock($composite, 'guid');
+ try {
+ $object->getExternal('test');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Attribute "Test" not supported!', $e->getMessage());
+ }
+ }
+
+ public function testGetexternalThrowsExceptionIfTheRequestedClassDoesNotExist()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->once())
+ ->method('getExternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will($this->returnValue(array('Test')));
+ $object = new Object_Mock($composite, 'guid');
+ try {
+ $object->getExternal('test');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Attribute "Test" not supported!', $e->getMessage());
+ }
+ }
+
+ public function testDeleteHasPostconditionThatTheObjectWasDeletedOnTheServer()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->server->expects($this->once())
+ ->method('delete')
+ ->with('guid');
+ $object = new Object_Mock($composite, 'guid');
+ $object->delete();
+ }
+
+ public function testSaveHasParameterArrayTheDataToSave()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->schema->expects($this->exactly(3))
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ 'Horde_Kolab_Server_Object_Attribute_Objectclass'
+ )
+ )
+ );
+ $composite->server->expects($this->exactly(2))
+ ->method('readAttributes')
+ ->with('guid', array('objectClass'))
+ ->will($this->returnValue(array('objectClass' => array('test'))));
+ $object = new Object_Mock($composite, 'guid');
+ $object->save(array());
+ }
+
+ public function testSaveHasPostconditionThatTheObjectWasAddedToTheServerIfItDidNotExistBefore()
+ {
+ $composite = $this->getMockedComposite();
+ $composite->structure->expects($this->exactly(1))
+ ->method('getInternalAttribute')
+ ->with('Objectclass')
+ ->will($this->returnValue('objectClass'));
+ $composite->schema->expects($this->exactly(1))
+ ->method('getInternalAttributes')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ 'Horde_Kolab_Server_Object_Attribute_Objectclass'
+ )
+ )
+ );
+ $composite->structure->expects($this->exactly(1))
+ ->method('generateServerGuid')
+ ->with(
+ 'Object_Mock', null,
+ array('objectClass' => array('top')))
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ 'Horde_Kolab_Server_Object_Attribute_Objectclass'
+ )
+ )
+ );
+ $composite->server->expects($this->exactly(1))
+ ->method('add')
+ ->with($this->isInstanceOf('Horde_Kolab_Server_Object'), array('objectClass' => array('top')));
+ $object = new Object_Mock($composite);
+ $object->save(array('Objectclass' => 'top'));
+ }
+}
+
+class Object_Mock extends Horde_Kolab_Server_Object_Base
+{
+ public function getActions() {}
+ static public function getFilter() {}
+ public function generateId(array &$info) {}
+ public function prepareObjectInformation(array &$info) {}
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the LDAP query elements.
+ *
+ * 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__) . '/../../../Autoload.php';
+
+/**
+ * Test the LDAP query elements.
+ *
+ * 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_Query_ElementTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->writer = $this->getMock(
+ 'Horde_Kolab_Server_Query_Ldap', array(), array(), '', false
+ );
+ }
+
+ public function testClassAndMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertAnd')
+ ->will($this->returnValue('converted'));
+ $and = new Horde_Kolab_Server_Query_Element_And(array());
+ $this->assertEquals('converted', $and->convert($this->writer));
+ }
+
+ public function testClassApproxMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertApprox')
+ ->will($this->returnValue('converted'));
+ $approx = new Horde_Kolab_Server_Query_Element_Approx('', '');
+ $this->assertEquals('converted', $approx->convert($this->writer));
+ }
+
+ public function testClassBeginsMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertBegins')
+ ->will($this->returnValue('converted'));
+ $begins = new Horde_Kolab_Server_Query_Element_Begins('', '');
+ $this->assertEquals('converted', $begins->convert($this->writer));
+ }
+
+ public function testClassContainsMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertContains')
+ ->will($this->returnValue('converted'));
+ $contains = new Horde_Kolab_Server_Query_Element_Contains('', '');
+ $this->assertEquals('converted', $contains->convert($this->writer));
+ }
+
+ public function testClassEndsMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertEnds')
+ ->will($this->returnValue('converted'));
+ $ends = new Horde_Kolab_Server_Query_Element_Ends('', '');
+ $this->assertEquals('converted', $ends->convert($this->writer));
+ }
+
+ public function testClassEqualsMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertEquals')
+ ->will($this->returnValue('converted'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('', '');
+ $this->assertEquals('converted', $equals->convert($this->writer));
+ }
+
+ public function testClassGreaterMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertGreater')
+ ->will($this->returnValue('converted'));
+ $greater = new Horde_Kolab_Server_Query_Element_Greater('', '');
+ $this->assertEquals('converted', $greater->convert($this->writer));
+ }
+
+ public function testClassLessMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertLess')
+ ->will($this->returnValue('converted'));
+ $less = new Horde_Kolab_Server_Query_Element_Less('', '');
+ $this->assertEquals('converted', $less->convert($this->writer));
+ }
+
+ public function testClassNotMethodConstructHasPostconditionThatTheElementWasSavedAsArray()
+ {
+ $less = new Horde_Kolab_Server_Query_Element_Less('', '');
+ $not = new Horde_Kolab_Server_Query_Element_Not($less);
+ $this->assertType('array', $not->getElements());
+ }
+
+ public function testClassNotMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertNot')
+ ->will($this->returnValue('converted'));
+ $less = new Horde_Kolab_Server_Query_Element_Less('', '');
+ $not = new Horde_Kolab_Server_Query_Element_Not($less);
+ $this->assertEquals('converted', $not->convert($this->writer));
+ }
+
+ public function testClassOrMethodConvertHasResultMixedTheConvertedElement()
+ {
+ $this->writer->expects($this->exactly(1))
+ ->method('convertOr')
+ ->will($this->returnValue('converted'));
+ $or = new Horde_Kolab_Server_Query_Element_Or(array());
+ $this->assertEquals('converted', $or->convert($this->writer));
+ }
+
+ public function testClassGroupMethodConstructHasParameterArrayElements()
+ {
+ $or = new Horde_Kolab_Server_Query_Element_Or(array());
+ }
+
+ public function testClassGroupMethodConstructHasPostconditionThatTheElementsWereSaved()
+ {
+ $or = new Horde_Kolab_Server_Query_Element_Or(array());
+ $this->assertEquals(array(), $or->getElements());
+ }
+
+ /**
+ * @expectedException Exception
+ */
+ public function testClassGroupMethodGetnameThrowsException()
+ {
+ $or = new Horde_Kolab_Server_Query_Element_Or(array());
+ $or->getName();
+ }
+
+ /**
+ * @expectedException Exception
+ */
+ public function testClassGroupMethodGetvalueThrowsException()
+ {
+ $or = new Horde_Kolab_Server_Query_Element_Or(array());
+ $or->getValue();
+ }
+
+ public function testClassGroupMethodGetelementsHasResultArrayTheGroupElements()
+ {
+ $or = new Horde_Kolab_Server_Query_Element_Or(array());
+ $this->assertEquals(array(), $or->getElements());
+ }
+
+ public function testClassSingleMethodConstructHasParameterStringName()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('name', '');
+ }
+
+ public function testClassSingleMethodConstructHasParameterStringValue()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('', 'value');
+ }
+
+ public function testClassSingleMethodConstructHasPostconditionThatNameAndValueWereSaved()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('name', 'value');
+ $this->assertEquals('name', $equals->getName());
+ $this->assertEquals('value', $equals->getValue());
+ }
+
+ public function testClassSingleMethodGetnameHasResultStringTheName()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('name', '');
+ $this->assertEquals('name', $equals->getName());
+ }
+
+ public function testClassSingleMethodGetvalueHasResultStringTheValue()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('', 'value');
+ $this->assertEquals('value', $equals->getValue());
+ }
+
+ /**
+ * @expectedException Exception
+ */
+ public function testClassSingleMethodGetelementsThrowsException()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('', '');
+ $equals->getElements();
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the LDAP query handler.
+ *
+ * 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__) . '/../../../LdapTestCase.php';
+
+/**
+ * Test the LDAP query handler.
+ *
+ * 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_Query_LdapTest extends Horde_Kolab_Server_LdapTestCase
+{
+ public function setUp()
+ {
+ $this->skipIfNoLdap();
+ $this->structure = $this->getMock(
+ 'Horde_Kolab_Server_Structure_Interface'
+ );
+ }
+
+
+ public function testMethodConstructHasParameterQueryelementTheQueryCriteria()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure);
+ }
+
+ public function testMethodConstructHasPostconditionThatTheQueryCriteriaWereSaved()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('equals'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure);
+ $this->assertEquals(
+ '(equals=equals)',
+ (string) $query
+ );
+ }
+
+ public function testMethodTostringHasResultStringTheQuery()
+ {
+ $this->structure->expects($this->exactly(2))
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('internal'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains');
+ $or = new Horde_Kolab_Server_Query_Element_Or(array($equals, $contains));
+ $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
+ $this->assertEquals(
+ '(|(internal=equals)(internal=contains))',
+ (string) $query
+ );
+ }
+
+ public function testMethodConvertequealsHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('equals'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure);
+ $this->assertEquals(
+ '(equals=equals)',
+ $query->convertEquals($equals)->asString()
+ );
+ }
+
+ public function testMethodConvertbeginsHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('begins'));
+ $begins = new Horde_Kolab_Server_Query_Element_Begins('begins', 'begins');
+ $query = new Horde_Kolab_Server_Query_Ldap($begins, $this->structure);
+ $this->assertEquals(
+ '(begins=begins*)',
+ $query->convertBegins($begins)->asString()
+ );
+ }
+
+ public function testMethodConvertendsHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('ends'));
+ $ends = new Horde_Kolab_Server_Query_Element_Ends('ends', 'ends');
+ $query = new Horde_Kolab_Server_Query_Ldap($ends, $this->structure);
+ $this->assertEquals(
+ '(ends=*ends)',
+ $query->convertEnds($ends)->asString()
+ );
+ }
+
+ public function testMethodConvertcontainsHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('contains'));
+ $contains = new Horde_Kolab_Server_Query_Element_Contains('contains', 'contains');
+ $query = new Horde_Kolab_Server_Query_Ldap($contains, $this->structure);
+ $this->assertEquals(
+ '(contains=*contains*)',
+ $query->convertContains($contains)->asString()
+ );
+ }
+
+ public function testMethodConvertlessHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('less'));
+ $less = new Horde_Kolab_Server_Query_Element_Less('less', 'less');
+ $query = new Horde_Kolab_Server_Query_Ldap($less, $this->structure);
+ $this->assertEquals(
+ '(less<less)',
+ $query->convertLess($less)->asString()
+ );
+ }
+
+ public function testMethodConvertgreaterHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('greater'));
+ $greater = new Horde_Kolab_Server_Query_Element_Greater('greater', 'greater');
+ $query = new Horde_Kolab_Server_Query_Ldap($greater, $this->structure);
+ $this->assertEquals(
+ '(greater>greater)',
+ $query->convertGreater($greater)->asString()
+ );
+ }
+
+ public function testMethodConvertapproxHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('approx'));
+ $approx = new Horde_Kolab_Server_Query_Element_Approx('approx', 'approx');
+ $query = new Horde_Kolab_Server_Query_Ldap($approx, $this->structure);
+ $this->assertEquals(
+ '(approx~=approx)',
+ $query->convertApprox($approx)->asString()
+ );
+ }
+
+ public function testMethodConvertnotHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->once())
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('equals'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $not = new Horde_Kolab_Server_Query_Element_Not($equals, $this->structure);
+ $query = new Horde_Kolab_Server_Query_Ldap($not, $this->structure);
+ $this->assertEquals(
+ '(!(equals=equals))',
+ $query->convertNot($not)->asString()
+ );
+ }
+
+ public function testMethodConvertandHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->exactly(2))
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('internal'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains');
+ $and = new Horde_Kolab_Server_Query_Element_And(array($equals, $contains));
+ $query = new Horde_Kolab_Server_Query_Ldap($and, $this->structure);
+ $this->assertEquals(
+ '(&(internal=equals)(internal=contains))',
+ $query->convertAnd($and)->asString()
+ );
+ }
+
+ public function testMethodConvertorHasResultNetldapfilter()
+ {
+ $this->structure->expects($this->exactly(2))
+ ->method('getInternalAttribute')
+ ->will($this->returnValue('internal'));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains');
+ $or = new Horde_Kolab_Server_Query_Element_Or(array($equals, $contains));
+ $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
+ $this->assertEquals(
+ '(|(internal=equals)(internal=contains))',
+ $query->convertOr($or)->asString()
+ );
+ }
+
+ public function testMethodConvertorThrowsExceptionIfLessThanTwoElementsWereProvided()
+ {
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
+ $or = new Horde_Kolab_Server_Query_Element_Or(array($equals));
+ $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
+
+ /** Hide strict errors from the Net_LDAP2 library */
+ $error_reporting = error_reporting();
+ error_reporting($error_reporting & ~E_STRICT);
+
+ try {
+ $query->convertOr($or)->asString();
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals(Horde_Kolab_Server_Exception::INVALID_QUERY, $e->getCode());
+ }
+
+ /** Reactivate original error reporting */
+ error_reporting($error_reporting);
+ }
+}
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
- ->method('getSupportedObjects')
+ ->method('getSearchOperations')
->will($this->returnValue(array()));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
- ->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Dummy')));
+ ->method('getSearchOperations')
+ ->will($this->returnValue(array('Object_Search')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
$this->assertEquals(
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
- ->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Search_Fail')));
+ ->method('getSearchOperations')
+ ->will($this->returnValue(array('Object_Search_NoSuchClass')));
$search = new Horde_Kolab_Server_Search_Base();
try {
$search->setComposite($composite);
} catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals(
- 'Object_Search_Fail::getSearchOperations specified non-existing class "Does_Not_Exist"!',
+ $this->assertContains(
+ 'getSearchOperations specified non-existing class "Object_Search_NoSuchClass"!',
$e->getMessage()
);
}
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
- ->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Dummy')));
+ ->method('getSearchOperations')
+ ->will($this->returnValue(array('Object_Search')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
$this->assertEquals(1, $search->call());
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
- ->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Dummy')));
+ ->method('getSearchOperations')
+ ->will($this->returnValue(array('Object_Search')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
$search->call('a');
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
- ->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Dummy')));
+ ->method('getSearchOperations')
+ ->will($this->returnValue(array('Object_Search')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
try {
{
self::$calls = 0;
}
-}
-
-class Object_Search_Fail
-{
- static public function getSearchOperations()
- {
- return array('Does_Not_Exist');
- }
-}
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the guid search operation.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the guid search operation.
+ *
+ * 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_GuidTest
+extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface');
+ }
+
+ public function testMethodConstructHasParameterStructure()
+ {
+ $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
+ }
+
+ public function testMethodConstructHasPostconditionThatTheServerStructureGetsStored()
+ {
+ $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
+ $this->assertSame($this->structure, $search->getStructure());
+ }
+
+ public function testMethodGetStructureHasResultStructureTheStructureAssociatedWithThisSearch()
+ {
+ $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
+ $this->assertType('Horde_Kolab_Server_Structure_Interface', $search->getStructure());
+ }
+
+ public function testMethodSearchguidHasResultArrayTheGuidsOfTheSearchResult()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result');
+ $result->expects($this->once())
+ ->method('asArray')
+ ->will($this->returnValue(array('a' => 'a')));
+ $this->structure->expects($this->once())
+ ->method('find')
+ ->with(
+ $this->isInstanceOf('Horde_Kolab_Server_Query_Element'),
+ array('attributes' => 'Guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element');
+ $this->assertEquals(array('a'), $search->searchGuid($criteria));
+ }
+
+ public function testMethodSearchguidHasResultArrayEmptyIfTheSearchReturnedNoResults()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result');
+ $result->expects($this->once())
+ ->method('asArray')
+ ->will($this->returnValue(array()));
+ $this->structure->expects($this->once())
+ ->method('find')
+ ->with(
+ $this->isInstanceOf('Horde_Kolab_Server_Query_Element'),
+ array('attributes' => 'Guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element');
+ $this->assertEquals(array(), $search->searchGuid($criteria));
+ }
+}
$server,
$this->getMock('Horde_Kolab_Server_Objects'),
new Horde_Kolab_Server_Structure_Kolab(),
- $this->getMock('Horde_Kolab_Server_Search'),
+ $this->getMock('Horde_Kolab_Server_Search_Interface'),
$this->getMock('Horde_Kolab_Server_Schema')
);
}
$server,
$this->getMock('Horde_Kolab_Server_Objects'),
new Horde_Kolab_Server_Structure_Ldap(),
- $this->getMock('Horde_Kolab_Server_Search'),
+ $this->getMock('Horde_Kolab_Server_Search_Interface'),
$this->getMock('Horde_Kolab_Server_Schema')
);
}
+++ /dev/null
-<?php
-/**
- * Test the test driver.
- *
- * 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__) . '/../LdapTestCase.php';
-
-/**
- * Test the test backend.
- *
- * Copyright 2008-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_Connection_MockTest
-extends Horde_Kolab_Server_LdapTestCase
-{
- /**
- * Test parsing of LDAP filters.
- *
- * @return NULL
- */
- public function testFilterParse()
- {
- $this->skipIfNoLdap();
-
- $conn = new Horde_Kolab_Server_Connection_Mock(array());
-
- $a = $conn->parse('(a=b)');
- $this->assertEquals(array('att' => 'a', 'log' => '=', 'val' => 'b'),
- $a);
-
- $a = $conn->parse('(&(a=b)(c=d))');
- $this->assertEquals(array('op' => '&', 'sub' => array(
- array('att' => 'a', 'log' => '=', 'val' => 'b'),
- array('att' => 'c', 'log' => '=', 'val' => 'd'),
- )), $a);
-
- $a = $conn->parse('(&(a=1)(|(b=2)(c=3)))');
- $this->assertEquals(array('op' => '&', 'sub' => array(
- array('att' => 'a', 'log' => '=', 'val' => '1'),
- array('op' => '|', 'sub' =>
- array(
- array('att' => 'b', 'log' => '=', 'val' => '2'),
- array('att' => 'c', 'log' => '=', 'val' => '3'),
- )))), $a);
-
- $a = $conn->parseSub('(!(x=2))(b=1)');
- $this->assertEquals(array(array('op' => '!', 'sub' =>
- array(
- array('att' => 'x', 'log' => '=', 'val' => '2'),
- )
- ),
- array('att' => 'b', 'log' => '=', 'val' => '1'),
- ), $a);
-
- $a = $conn->parse('(&(!(x=2))(b=1))');
- $this->assertEquals(array('op' => '&', 'sub' => array(
- array('op' => '!', 'sub' =>
- array(
- array('att' => 'x', 'log' => '=', 'val' => '2'),
- )
- ),
- array('att' => 'b', 'log' => '=', 'val' => '1'),
- )), $a);
-
- }
-
- /**
- * Test searching in the simulated LDAP data.
- *
- * @return NULL
- */
- public function testSearch()
- {
- $this->skipIfNoLdap();
-
- $conn = new Horde_Kolab_Server_Connection_Mock(
- array(
- 'data' =>
- array(
- 'cn=a' => array(
- 'dn' => 'cn=a',
- 'data' => array(
- 'a' => '1',
- 'b' => '1',
- 'c' => '1',
- )
- ),
- 'cn=b' => array(
- 'dn' => 'cn=b',
- 'data' => array(
- 'a' => '1',
- 'b' => '2',
- 'c' => '2',
- )
- ),
- 'cn=c' => array(
- 'dn' => 'cn=c',
- 'data' => array(
- 'a' => '1',
- 'b' => '2',
- 'c' => '3',
- )
- ),
- 'cn=d' => array(
- 'dn' => 'cn=d',
- 'data' => array(
- 'a' => '2',
- 'b' => '2',
- 'c' => '1',
- )
- ),
- )
- )
- );
-
- $a = $conn->search(null, '(c=1)');
- $this->assertEquals(
- array(
- 'cn=a' => array(
- 'a' => '1',
- 'b' => '1',
- 'c' => '1',
- 'dn' => 'cn=a',
- ),
- 'cn=d' => array(
- 'a' => '2',
- 'b' => '2',
- 'c' => '1',
- 'dn' => 'cn=d',
- ),
- ),
- $a->as_struct()
- );
-
- $a = $conn->search(null, '(c=3)');
- $this->assertEquals(
- array(
- 'cn=c' => array(
- 'a' => '1',
- 'b' => '2',
- 'c' => '3',
- 'dn' => 'cn=c',
- ),
- ),
- $a->as_struct()
- );
-
- $a = $conn->search(null, '(c=3)', array('attributes' => array('a')));
- $this->assertEquals(
- array(
- 'cn=c' => array(
- 'a' => '1',
- 'dn' => 'cn=c',
- ),
- ),
- $a->as_struct()
- );
-
- $a = $conn->search(null, '(&(a=1)(b=2))', array('attributes' => array('a', 'b')));
- $this->assertEquals(
- array(
- 'cn=b' => array(
- 'a' => '1',
- 'b' => '2',
- 'dn' => 'cn=b',
- ),
- 'cn=c' => array(
- 'a' => '1',
- 'b' => '2',
- 'dn' => 'cn=c',
- ),
- ),
- $a->as_struct()
- );
-
- $a = $conn->search(null, '(&(b=2))', array('attributes' => array('b')));
- $this->assertEquals(
- array(
- 'cn=b' => array(
- 'b' => '2',
- 'dn' => 'cn=b',
- ),
- 'cn=c' => array(
- 'b' => '2',
- 'dn' => 'cn=c',
- ),
- 'cn=d' => array(
- 'b' => '2',
- 'dn' => 'cn=d',
- ),
- ),
- $a->as_struct()
- );
-
- $a = $conn->search(null, '(!(b=2))', array('attributes' => array('a', 'b')));
- $this->assertEquals(
- array(
- 'cn=a' => array(
- 'a' => '1',
- 'b' => '1',
- 'dn' => 'cn=a',
- ),
- ),
- $a->as_struct()
- );
-
- $a = $conn->search(null, '(&(!(x=2))(b=1))', array('attributes' => array('b')));
- $this->assertEquals(
- array(
- 'cn=a' => array(
- 'b' => '1',
- 'dn' => 'cn=a',
- ),
- ),
- $a->as_struct()
- );
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Test the handler for a simple LDAP setup without read-only slaves.
- *
- * 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__) . '/../LdapTestCase.php';
-
-/**
- * Test the handler for a simple LDAP setup without read-only slaves.
- *
- * 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_Connection_SimpleldapTest
-extends Horde_Kolab_Server_LdapTestCase
-{
- public function testMethodConstructHasParameterNetldap2Connection()
- {
- $ldap = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
- }
-
- public function testMethodConstructHasPostconditionThatTheGivenServerWasStored()
- {
- $ldap = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
- $this->assertSame($ldap, $conn->getRead());
- }
-
- public function testMethodGetreadHasResultNetldap2TheHandledConnection()
- {
- $ldap = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
- $this->assertType('Net_LDAP2', $conn->getRead());
- }
-
- public function testMethodGetwriteHasResultNetldap2TheHandledConnection()
- {
- $ldap = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Simpleldap($ldap);
- $this->assertSame($conn->getWrite(), $conn->getRead());
- }
-}
+++ /dev/null
-<?php
-/**
- * Test the handler for a LDAP master/slave setup.
- *
- * 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__) . '/../LdapTestCase.php';
-
-/**
- * Test the handler for a LDAP master/slave setup.
- *
- * 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_Connection_SplittedldapTest
-extends Horde_Kolab_Server_LdapTestCase
-{
- public function testMethodConstructHasParameterNetldap2ReadConnectionAndParameterNetldap2WriteConnection()
- {
- $ldap_read = $this->getMock('Net_LDAP2');
- $ldap_write = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
- }
-
- public function testMethodConstructHasPostconditionThatTheGivenServersWereStored()
- {
- $ldap_read = $this->getMock('Net_LDAP2');
- $ldap_write = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
- $this->assertSame($ldap_read, $conn->getRead());
- $this->assertSame($ldap_write, $conn->getWrite());
- }
-
- public function testMethodGetreadHasResultNetldap2TheHandledConnection()
- {
- $ldap_read = $this->getMock('Net_LDAP2');
- $ldap_write = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
- $this->assertType('Net_LDAP2', $conn->getRead());
- $this->assertType('Net_LDAP2', $conn->getWrite());
- }
-
- public function testMethodGetwriteHasResultNetldap2TheHandledConnection()
- {
- $ldap_read = $this->getMock('Net_LDAP2');
- $ldap_write = $this->getMock('Net_LDAP2');
- $conn = new Horde_Kolab_Server_Connection_Splittedldap($ldap_read, $ldap_write);
- $this->assertFalse($conn->getWrite() === $conn->getRead());
- }
-}
--- /dev/null
+<?php
+/**
+ * Test the server class.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Tests for the main server class.
+ *
+ * Copyright 2008-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_Integration_ObjectsTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->markTestIncomplete('Needs to be fixed');
+ }
+
+ /**
+ * Provide a mock server.
+ *
+ * @return Horde_Kolab_Server The mock server.
+ */
+ protected function getMockServer()
+ {
+ $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+ $config = new stdClass;
+ $config->driver = 'none';
+ $injector->setInstance('Horde_Kolab_Server_Config', $config);
+ $injector->bindFactory('Horde_Kolab_Server_Structure',
+ 'Horde_Kolab_Server_Factory',
+ 'getStructure');
+ $injector->bindFactory('Horde_Kolab_Server',
+ 'Horde_Kolab_Server_Factory',
+ 'getServer');
+ return $injector->getInstance('Horde_Kolab_Server');
+ }
+
+ /**
+ * The generating a uid for an object.
+ *
+ * @return NULL
+ */
+ public function testGenerateUid()
+ {
+ $ks = $this->getMockServer();
+ $user = new Horde_Kolab_Server_Object($ks, null, null);
+ $this->assertEquals(preg_replace('/[0-9a-f]*/', '', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)), '');
+ }
+
+ /**
+ * Test creating the server object.
+ *
+ * @return NULL
+ */
+ public function testCreation()
+ {
+ try {
+ $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+ $config = new stdClass;
+ $config->driver = 'dummy';
+ $injector->setInstance('Horde_Kolab_Server_Config', $config);
+ $injector->bindFactory('Horde_Kolab_Server_Structure',
+ 'Horde_Kolab_Server_Factory',
+ 'getStructure');
+ $injector->bindFactory('Horde_Kolab_Server',
+ 'Horde_Kolab_Server_Factory',
+ 'getServer');
+ Horde_Kolab_Server_Factory::getServer($injector);
+ $this->assertFail('No error!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Server type definition "Horde_Kolab_Server_Dummy" missing.',
+ $e->getMessage());
+ }
+ }
+
+ /**
+ * The base class provides no abilities for reading data. So it
+ * should mainly return error. But it should be capable of
+ * returning a dummy Kolab user object.
+ *
+ * @return NULL
+ */
+ public function testFetch()
+ {
+ $ks = $this->getMockServer();
+ $user = $ks->fetch('test');
+ $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
+
+ $ks = $this->getMockServer();
+ $user = $ks->fetch();
+ $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
+ }
+
+ /**
+ * Test listing objects.
+ *
+ * @return NULL
+ */
+ public function testList()
+ {
+ $ks = $this->getMockServer();
+ $hash = $ks->listHash('Horde_Kolab_Server_Object');
+ $this->assertEquals($hash, array());
+
+ $ks = $this->getMockServer();
+ $hash = $ks->listHash('Horde_Kolab_Server_Object');
+ $this->assertEquals($hash, array());
+ }
+
+}
+++ /dev/null
-<?php
-/**
- * Test the base object.
- *
- * 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
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../TestCase.php';
-
-/**
- * Test the base object.
- *
- * Copyright 2008-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_Object_BaseTest extends Horde_Kolab_Server_TestCase
-{
- public function setUp()
- {
- }
-
- public function testMethodConstructHasParameterCompositeWhichIsTheLinkToTheServer()
- {
- $composite = $this->getComposite();
- $object = new Object_Mock($composite, '');
- }
-
- public function testMethodConstructHasParameterStringTheGuidOfTheObject()
- {
- $composite = $this->getComposite();
- $object = new Object_Mock($composite, 'guid');
- }
-
- public function testGetguidHasResultStringGuidTheObjectIdOnTheServer()
- {
- $composite = $this->getComposite();
- $object = new Object_Mock($composite, 'guid');
- $this->assertEquals('guid', $object->getGuid());
- }
-
- public function testGetguidThrowsExceptionIfGuidHasNotBeenSetYet()
- {
- $composite = $this->getComposite();
- $object = new Object_Mock($composite);
- try {
- $this->assertEquals('newGuid', $object->getGuid());
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals(
- 'Uninitialized object is missing GUID!', $e->getMessage()
- );
- }
- }
-
- public function testGetexternalattributesHasResultArrayTheExternalAttributesSupportedByTheObject()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getExternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('external')));
- $object = new Object_Mock($composite, 'guid');
- $this->assertEquals(array('external'), $object->getExternalAttributes());
- }
-
- public function testGetinternalattributesHasResultArrayTheInternalAttributesSupportedByTheObject()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('internal' => 'Internal')));
- $object = new Object_Mock($composite, 'guid');
- $this->assertEquals(array('internal' => 'Internal'), $object->getInternalAttributes());
- }
-
- public function testGetinternalattributesHasResultBooleanFalseIfTheGuidIsNotSpecified()
- {
- $composite = $this->getMockedComposite();
- $object = new Object_Mock($composite);
- $this->assertFalse($object->exists());
- }
-
- public function testGetinternalattributesHasResultBooleanFalseIfTheServerReturnedAnError()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('internal' => 'Internal')));
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('internal'))
- ->will($this->throwException(new Horde_Kolab_Server_Exception('')));
- $object = new Object_Mock($composite, 'guid');
- $this->assertFalse($object->exists());
- }
-
- public function testGetinternalattributesHasResultBooleanTrueIfTheServerReturnedData()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('internal' => 'Internal')));
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('internal'))
- ->will($this->returnValue(array('a' => 'a')));
- $object = new Object_Mock($composite, 'guid');
- $this->assertTrue($object->exists());
- }
-
- public function testReadinternalHasResultArrayDataTheInternalObjectData()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('internal' => 'Internal')));
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('internal'))
- ->will($this->returnValue(array('internal' => 'test')));
- $object = new Object_Mock($composite, 'guid');
- $this->assertEquals(
- array('internal' => 'test'), $object->readInternal()
- );
- }
-
- public function testGetinternalHasResultArrayTheDataOfTheRequestedAttribute()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->exactly(2))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('internal' => 'Internal')));
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('internal'))
- ->will($this->returnValue(array('internal' => array('test'))));
- $object = new Object_Mock($composite, 'guid');
- $this->assertEquals(
- array('test'), $object->getInternal('internal')
- );
- }
-
- public function testGetinternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('internal' => 'Internal')));
- $object = new Object_Mock($composite, 'guid');
- try {
- $object->getInternal('test');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Attribute "test" not supported!', $e->getMessage());
- }
- }
-
- public function testGetinternalThrowsExceptionIfTheRequestedAttributeHasNoValue()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->exactly(2))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will(
- $this->returnValue(
- array('internal' => 'Internal', 'test' => 'Test')
- )
- );
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('internal', 'test'))
- ->will($this->returnValue(array('internal' => array('test'))));
- $object = new Object_Mock($composite, 'guid');
- try {
- $object->getInternal('test');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception_Novalue $e) {
- $this->assertEquals('No value for attribute "test"!', $e->getMessage());
- }
- }
-
- public function testGetexternalHasResultArrayTheDataOfTheRequestedAttribute()
- {
- $composite = $this->getMockedComposite();
- $composite->structure->expects($this->exactly(1))
- ->method('getInternalAttribute')
- ->with('Objectclass')
- ->will($this->returnValue('objectClass'));
- $composite->schema->expects($this->exactly(1))
- ->method('getExternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('Objectclass')));
- $composite->schema->expects($this->exactly(2))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('objectClass' => 'Objectclass')));
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('objectClass'))
- ->will($this->returnValue(array('objectClass' => array('test'))));
- $object = new Object_Mock($composite, 'guid');
- $this->assertEquals(
- array('test'), $object->getExternal('Objectclass')
- );
- }
-
- public function testGetexternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getExternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('external')));
- $object = new Object_Mock($composite, 'guid');
- try {
- $object->getExternal('test');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Attribute "Test" not supported!', $e->getMessage());
- }
- }
-
- public function testGetexternalThrowsExceptionIfTheRequestedClassDoesNotExist()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getExternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will($this->returnValue(array('Test')));
- $object = new Object_Mock($composite, 'guid');
- try {
- $object->getExternal('test');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Attribute "Test" not supported!', $e->getMessage());
- }
- }
-
- public function testDeleteHasPostconditionThatTheObjectWasDeletedOnTheServer()
- {
- $composite = $this->getMockedComposite();
- $composite->server->expects($this->once())
- ->method('delete')
- ->with('guid');
- $object = new Object_Mock($composite, 'guid');
- $object->delete();
- }
-
- public function testSaveHasParameterArrayTheDataToSave()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->exactly(3))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- 'Horde_Kolab_Server_Object_Attribute_Objectclass'
- )
- )
- );
- $composite->server->expects($this->exactly(2))
- ->method('readAttributes')
- ->with('guid', array('objectClass'))
- ->will($this->returnValue(array('objectClass' => array('test'))));
- $object = new Object_Mock($composite, 'guid');
- $object->save(array());
- }
-
- public function testSaveHasPostconditionThatTheObjectWasAddedToTheServerIfItDidNotExistBefore()
- {
- $composite = $this->getMockedComposite();
- $composite->structure->expects($this->exactly(1))
- ->method('getInternalAttribute')
- ->with('Objectclass')
- ->will($this->returnValue('objectClass'));
- $composite->schema->expects($this->exactly(1))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'))
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- 'Horde_Kolab_Server_Object_Attribute_Objectclass'
- )
- )
- );
- $composite->structure->expects($this->exactly(1))
- ->method('generateServerGuid')
- ->with(
- 'Object_Mock', null,
- array('objectClass' => array('top')))
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- 'Horde_Kolab_Server_Object_Attribute_Objectclass'
- )
- )
- );
- $composite->server->expects($this->exactly(1))
- ->method('add')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object'), array('objectClass' => array('top')));
- $object = new Object_Mock($composite);
- $object->save(array('Objectclass' => 'top'));
- }
-}
-
-class Object_Mock extends Horde_Kolab_Server_Object_Base
-{
- public function getActions() {}
- static public function getFilter() {}
- public function generateId(array &$info) {}
- public function prepareObjectInformation(array &$info) {}
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the server class.
- *
- * 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
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Tests for the main server class.
- *
- * Copyright 2008-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_Objects_ServerTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->markTestIncomplete('Needs to be fixed');
- }
-
- /**
- * Provide a mock server.
- *
- * @return Horde_Kolab_Server The mock server.
- */
- protected function getMockServer()
- {
- $injector = new Horde_Injector(new Horde_Injector_TopLevel());
- $config = new stdClass;
- $config->driver = 'none';
- $injector->setInstance('Horde_Kolab_Server_Config', $config);
- $injector->bindFactory('Horde_Kolab_Server_Structure',
- 'Horde_Kolab_Server_Factory',
- 'getStructure');
- $injector->bindFactory('Horde_Kolab_Server',
- 'Horde_Kolab_Server_Factory',
- 'getServer');
- return $injector->getInstance('Horde_Kolab_Server');
- }
-
- /**
- * The generating a uid for an object.
- *
- * @return NULL
- */
- public function testGenerateUid()
- {
- $ks = $this->getMockServer();
- $user = new Horde_Kolab_Server_Object($ks, null, null);
- $this->assertEquals(preg_replace('/[0-9a-f]*/', '', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)), '');
- }
-
- /**
- * Test creating the server object.
- *
- * @return NULL
- */
- public function testCreation()
- {
- try {
- $injector = new Horde_Injector(new Horde_Injector_TopLevel());
- $config = new stdClass;
- $config->driver = 'dummy';
- $injector->setInstance('Horde_Kolab_Server_Config', $config);
- $injector->bindFactory('Horde_Kolab_Server_Structure',
- 'Horde_Kolab_Server_Factory',
- 'getStructure');
- $injector->bindFactory('Horde_Kolab_Server',
- 'Horde_Kolab_Server_Factory',
- 'getServer');
- Horde_Kolab_Server_Factory::getServer($injector);
- $this->assertFail('No error!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Server type definition "Horde_Kolab_Server_Dummy" missing.',
- $e->getMessage());
- }
- }
-
- /**
- * The base class provides no abilities for reading data. So it
- * should mainly return error. But it should be capable of
- * returning a dummy Kolab user object.
- *
- * @return NULL
- */
- public function testFetch()
- {
- $ks = $this->getMockServer();
- $user = $ks->fetch('test');
- $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
-
- $ks = $this->getMockServer();
- $user = $ks->fetch();
- $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
- }
-
- /**
- * Test listing objects.
- *
- * @return NULL
- */
- public function testList()
- {
- $ks = $this->getMockServer();
- $hash = $ks->listHash('Horde_Kolab_Server_Object');
- $this->assertEquals($hash, array());
-
- $ks = $this->getMockServer();
- $hash = $ks->listHash('Horde_Kolab_Server_Object');
- $this->assertEquals($hash, array());
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Test the LDAP query elements.
- *
- * 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__) . '/../Autoload.php';
-
-/**
- * Test the LDAP query elements.
- *
- * 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_Query_ElementTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->writer = $this->getMock(
- 'Horde_Kolab_Server_Query_Ldap', array(), array(), '', false
- );
- }
-
- public function testClassAndMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertAnd')
- ->will($this->returnValue('converted'));
- $and = new Horde_Kolab_Server_Query_Element_And(array());
- $this->assertEquals('converted', $and->convert($this->writer));
- }
-
- public function testClassApproxMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertApprox')
- ->will($this->returnValue('converted'));
- $approx = new Horde_Kolab_Server_Query_Element_Approx('', '');
- $this->assertEquals('converted', $approx->convert($this->writer));
- }
-
- public function testClassBeginsMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertBegins')
- ->will($this->returnValue('converted'));
- $begins = new Horde_Kolab_Server_Query_Element_Begins('', '');
- $this->assertEquals('converted', $begins->convert($this->writer));
- }
-
- public function testClassContainsMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertContains')
- ->will($this->returnValue('converted'));
- $contains = new Horde_Kolab_Server_Query_Element_Contains('', '');
- $this->assertEquals('converted', $contains->convert($this->writer));
- }
-
- public function testClassEndsMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertEnds')
- ->will($this->returnValue('converted'));
- $ends = new Horde_Kolab_Server_Query_Element_Ends('', '');
- $this->assertEquals('converted', $ends->convert($this->writer));
- }
-
- public function testClassEqualsMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertEquals')
- ->will($this->returnValue('converted'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('', '');
- $this->assertEquals('converted', $equals->convert($this->writer));
- }
-
- public function testClassGreaterMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertGreater')
- ->will($this->returnValue('converted'));
- $greater = new Horde_Kolab_Server_Query_Element_Greater('', '');
- $this->assertEquals('converted', $greater->convert($this->writer));
- }
-
- public function testClassLessMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertLess')
- ->will($this->returnValue('converted'));
- $less = new Horde_Kolab_Server_Query_Element_Less('', '');
- $this->assertEquals('converted', $less->convert($this->writer));
- }
-
- public function testClassNotMethodConstructHasPostconditionThatTheElementWasSavedAsArray()
- {
- $less = new Horde_Kolab_Server_Query_Element_Less('', '');
- $not = new Horde_Kolab_Server_Query_Element_Not($less);
- $this->assertType('array', $not->getElements());
- }
-
- public function testClassNotMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertNot')
- ->will($this->returnValue('converted'));
- $less = new Horde_Kolab_Server_Query_Element_Less('', '');
- $not = new Horde_Kolab_Server_Query_Element_Not($less);
- $this->assertEquals('converted', $not->convert($this->writer));
- }
-
- public function testClassOrMethodConvertHasResultMixedTheConvertedElement()
- {
- $this->writer->expects($this->exactly(1))
- ->method('convertOr')
- ->will($this->returnValue('converted'));
- $or = new Horde_Kolab_Server_Query_Element_Or(array());
- $this->assertEquals('converted', $or->convert($this->writer));
- }
-
- public function testClassGroupMethodConstructHasParameterArrayElements()
- {
- $or = new Horde_Kolab_Server_Query_Element_Or(array());
- }
-
- public function testClassGroupMethodConstructHasPostconditionThatTheElementsWereSaved()
- {
- $or = new Horde_Kolab_Server_Query_Element_Or(array());
- $this->assertEquals(array(), $or->getElements());
- }
-
- /**
- * @expectedException Exception
- */
- public function testClassGroupMethodGetnameThrowsException()
- {
- $or = new Horde_Kolab_Server_Query_Element_Or(array());
- $or->getName();
- }
-
- /**
- * @expectedException Exception
- */
- public function testClassGroupMethodGetvalueThrowsException()
- {
- $or = new Horde_Kolab_Server_Query_Element_Or(array());
- $or->getValue();
- }
-
- public function testClassGroupMethodGetelementsHasResultArrayTheGroupElements()
- {
- $or = new Horde_Kolab_Server_Query_Element_Or(array());
- $this->assertEquals(array(), $or->getElements());
- }
-
- public function testClassSingleMethodConstructHasParameterStringName()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('name', '');
- }
-
- public function testClassSingleMethodConstructHasParameterStringValue()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('', 'value');
- }
-
- public function testClassSingleMethodConstructHasPostconditionThatNameAndValueWereSaved()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('name', 'value');
- $this->assertEquals('name', $equals->getName());
- $this->assertEquals('value', $equals->getValue());
- }
-
- public function testClassSingleMethodGetnameHasResultStringTheName()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('name', '');
- $this->assertEquals('name', $equals->getName());
- }
-
- public function testClassSingleMethodGetvalueHasResultStringTheValue()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('', 'value');
- $this->assertEquals('value', $equals->getValue());
- }
-
- /**
- * @expectedException Exception
- */
- public function testClassSingleMethodGetelementsThrowsException()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('', '');
- $equals->getElements();
- }
-}
+++ /dev/null
-<?php
-/**
- * Test the LDAP query handler.
- *
- * 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__) . '/../LdapTestCase.php';
-
-/**
- * Test the LDAP query handler.
- *
- * 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_Query_LdapTest extends Horde_Kolab_Server_LdapTestCase
-{
- public function setUp()
- {
- $this->skipIfNoLdap();
- $this->structure = $this->getMock('Horde_Kolab_Server_Structure');
- }
-
-
- public function testMethodConstructHasParameterQueryelementTheQueryCriteria()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure);
- }
-
- public function testMethodConstructHasPostconditionThatTheQueryCriteriaWereSaved()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('equals'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure);
- $this->assertEquals(
- '(equals=equals)',
- (string) $query
- );
- }
-
- public function testMethodTostringHasResultStringTheQuery()
- {
- $this->structure->expects($this->exactly(2))
- ->method('getInternalAttribute')
- ->will($this->returnValue('internal'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains');
- $or = new Horde_Kolab_Server_Query_Element_Or(array($equals, $contains));
- $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
- $this->assertEquals(
- '(|(internal=equals)(internal=contains))',
- (string) $query
- );
- }
-
- public function testMethodConvertequealsHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('equals'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure);
- $this->assertEquals(
- '(equals=equals)',
- $query->convertEquals($equals)->asString()
- );
- }
-
- public function testMethodConvertbeginsHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('begins'));
- $begins = new Horde_Kolab_Server_Query_Element_Begins('begins', 'begins');
- $query = new Horde_Kolab_Server_Query_Ldap($begins, $this->structure);
- $this->assertEquals(
- '(begins=begins*)',
- $query->convertBegins($begins)->asString()
- );
- }
-
- public function testMethodConvertendsHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('ends'));
- $ends = new Horde_Kolab_Server_Query_Element_Ends('ends', 'ends');
- $query = new Horde_Kolab_Server_Query_Ldap($ends, $this->structure);
- $this->assertEquals(
- '(ends=*ends)',
- $query->convertEnds($ends)->asString()
- );
- }
-
- public function testMethodConvertcontainsHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('contains'));
- $contains = new Horde_Kolab_Server_Query_Element_Contains('contains', 'contains');
- $query = new Horde_Kolab_Server_Query_Ldap($contains, $this->structure);
- $this->assertEquals(
- '(contains=*contains*)',
- $query->convertContains($contains)->asString()
- );
- }
-
- public function testMethodConvertlessHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('less'));
- $less = new Horde_Kolab_Server_Query_Element_Less('less', 'less');
- $query = new Horde_Kolab_Server_Query_Ldap($less, $this->structure);
- $this->assertEquals(
- '(less<less)',
- $query->convertLess($less)->asString()
- );
- }
-
- public function testMethodConvertgreaterHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('greater'));
- $greater = new Horde_Kolab_Server_Query_Element_Greater('greater', 'greater');
- $query = new Horde_Kolab_Server_Query_Ldap($greater, $this->structure);
- $this->assertEquals(
- '(greater>greater)',
- $query->convertGreater($greater)->asString()
- );
- }
-
- public function testMethodConvertapproxHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('approx'));
- $approx = new Horde_Kolab_Server_Query_Element_Approx('approx', 'approx');
- $query = new Horde_Kolab_Server_Query_Ldap($approx, $this->structure);
- $this->assertEquals(
- '(approx~=approx)',
- $query->convertApprox($approx)->asString()
- );
- }
-
- public function testMethodConvertnotHasResultNetldapfilter()
- {
- $this->structure->expects($this->once())
- ->method('getInternalAttribute')
- ->will($this->returnValue('equals'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $not = new Horde_Kolab_Server_Query_Element_Not($equals, $this->structure);
- $query = new Horde_Kolab_Server_Query_Ldap($not, $this->structure);
- $this->assertEquals(
- '(!(equals=equals))',
- $query->convertNot($not)->asString()
- );
- }
-
- public function testMethodConvertandHasResultNetldapfilter()
- {
- $this->structure->expects($this->exactly(2))
- ->method('getInternalAttribute')
- ->will($this->returnValue('internal'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains');
- $and = new Horde_Kolab_Server_Query_Element_And(array($equals, $contains));
- $query = new Horde_Kolab_Server_Query_Ldap($and, $this->structure);
- $this->assertEquals(
- '(&(internal=equals)(internal=contains))',
- $query->convertAnd($and)->asString()
- );
- }
-
- public function testMethodConvertorHasResultNetldapfilter()
- {
- $this->structure->expects($this->exactly(2))
- ->method('getInternalAttribute')
- ->will($this->returnValue('internal'));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains');
- $or = new Horde_Kolab_Server_Query_Element_Or(array($equals, $contains));
- $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
- $this->assertEquals(
- '(|(internal=equals)(internal=contains))',
- $query->convertOr($or)->asString()
- );
- }
-
- public function testMethodConvertorThrowsExceptionIfLessThanTwoElementsWereProvided()
- {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $or = new Horde_Kolab_Server_Query_Element_Or(array($equals));
- $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
-
- /** Hide strict errors from the Net_LDAP2 library */
- $error_reporting = error_reporting();
- error_reporting($error_reporting & ~E_STRICT);
-
- try {
- $query->convertOr($or)->asString();
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals(Horde_Kolab_Server_Exception::INVALID_QUERY, $e->getCode());
- }
-
- /** Reactivate original error reporting */
- error_reporting($error_reporting);
- }
-}
'Horde_Kolab_Server_Objects', array(), array(), '', false
),
$this->getMock(
- 'Horde_Kolab_Server_Structure', array(), array(), '', false
+ 'Horde_Kolab_Server_Structure_Interface', array(), array(), '', false
),
$this->getMock(
- 'Horde_Kolab_Server_Search', array(), array(), '', false
+ 'Horde_Kolab_Server_Search_Interface', array(), array(), '', false
),
$this->getMock(
'Horde_Kolab_Server_Schema', array(), array(), '', false