/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- );
+ public function find($query, 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.
+ * @param string $query The LDAP search query
+ * @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()
- );
+ public function findBelow($query, $parent, array $params = array());
/**
* Modify existing object data.
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
+ public function find($query, array $params = array())
+ {
return $this->_server->find($criteria, $params);
}
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
+ public function findBelow($query, $parent, array $params = array())
+ {
return $this->_server->findBelow($criteria, $parent, $params);
}
{
/** Bind anonymously first. */
$this->server->connectGuid();
- $guid = $this->search->getGuidForUser($user);
+ $guid = $this->search->searchGuidForUidOrMail($user);
$this->server->connectGuid($guid, $pass);
}
}
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
- return $this->findBelow($criteria, $this->_base_dn, $params);
+ public function find($query, array $params = array())
+ {
+ return $this->findBelow($query, $this->_base_dn, $params);
}
/**
*/
class Horde_Kolab_Server_Ldap_Changes
{
-
/**
* The object to be modified.
*
$attributes = array_merge(array_keys($old), array_keys($new));
foreach ($attributes as $attribute) {
if (!isset($old[$attribute])) {
- $cs['add'][] = array($attribute => $new[$attribute]);
+ $cs['add'][$attribute] = $new[$attribute];
continue;
}
if (!isset($new[$attribute])) {
continue;
}
if (count($new[$attribute]) == 1
- && count($old[$attribute]) == 1) {
+ && count($old[$attribute]) == 1
+ ) {
if ($new[$attribute][0] == $old[$attribute][0]) {
continue;
} else {
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
- $query = new Horde_Kolab_Server_Query_Ldap($criteria);
- $query_string = (string) $query;
- $query_string = '(&(' . $this->_filter . ')' . $query_string . ')';
- return $this->_search($query_string, $params, $parent);
+ public function findBelow($query, $parent, array $params = array())
+ {
+ $query = '(&(' . $this->_filter . ')' . $query . ')';
+ return $this->_search($query, $params, $parent);
}
}
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
- $query = new Horde_Kolab_Server_Query_Ldap($criteria);
+ public function findBelow($query, $parent, array $params = array())
+ {
return $this->_search((string) $query, $params, $parent);
}
}
*/
public function getGuid()
{
- $this->_server->getGuid();
+ return $this->_server->getGuid();
}
/**
*/
public function getBaseGuid()
{
- $this->_server->getBaseGuid();
+ return $this->_server->getBaseGuid();
}
/**
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
- return $this->_server->find($criteria, $params);
+ public function find($query, array $params = array())
+ {
+ return $this->_server->find($query, $params);
}
/**
* 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.
+ * @param string $query The LDAP search query
+ * @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()
- ) {
- return $this->_server->findBelow($criteria, $parent, $params);
+ public function findBelow($query, $parent, array $params = array())
+ {
+ return $this->_server->findBelow($query, $parent, $params);
}
/**
/**
* Finds object data matching a given set of criteria.
*
- * @param array $criteria The criteria for the search.
- * @param array $params Additional search parameters.
+ * @param string $query The LDAP search query
+ * @param array $params Additional search parameters.
*
* @return array The result array.
*
* @throws Horde_Kolab_Server_Exception
*/
- public function find(
- Horde_Kolab_Server_Query_Element $criteria,
- array $params = array()
- ) {
+ public function find($query, array $params = array())
+ {
$criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this);
$data = $this->_server->find($criteria, $params);
$this->unmapAttributes($data);
/**
* Finds all object data below a parent matching a given set of criteria.
*
- * @param array $criteria The criteria for the search.
- * @param string $parent The parent to search below.
- * @param array $params Additional search parameters.
+ * @param string $query The LDAP search query
+ * @param string $parent The parent to search below.
+ * @param array $params Additional search parameters.
*
* @return array The result array.
*
* @throws Horde_Kolab_Server_Exception
*/
- public function findBelow(
- Horde_Kolab_Server_Query_Element $criteria,
- $parent,
- array $params = array()
- ) {
+ public function findBelow($query, $parent, array $params = array())
+ {
$criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this);
$data = $this->_server->findBelow($criteria, $parent, $params);
$this->unmapAttributes($data);
public function __construct(
Horde_Kolab_Server_Object $object,
Horde_Kolab_Server_Composite $composite,
- $internal,
- $external = null
+ $external
) {
- $this->_internal = $internal;
$this->_object = $object;
$this->_composite = $composite;
$this->_external = $external;
+
+ $this->_internal = $this->_composite->structure->getInternalAttribute(
+ $this->_external
+ );
}
/**
class Horde_Kolab_Server_Object_Attribute_Objectclass
extends Horde_Kolab_Server_Object_Attribute_Decorator
{
- /** The internal attribute name */
- const INTERNAL = 'objectClass';
-
/**
* Constructor
*
$this->_attribute = new Horde_Kolab_Server_Object_Attribute_Required(
new Horde_Kolab_Server_Object_Attribute_Locked(
new Horde_Kolab_Server_Object_Attribute_Value(
- $object, $composite, self::INTERNAL, 'Objectclass'
+ $object, $composite, 'Objectclass'
)
)
);
static public function getSearchOperations()
{
$searches = array(
- 'gidForSearch',
- 'getGroups',
+/* 'gidForSearch', */
+/* 'getGroups', */
);
return $searches;
}
static public function getSearchOperations()
{
$searches = array(
- 'accountsForMail',
+/* 'accountsForMail', */
);
return $searches;
}
static public function getSearchOperations()
{
$searches = array(
- 'gidForMail',
- 'memberOfGroupAddress',
- 'getGroupAddresses',
+/* 'gidForMail', */
+/* 'memberOfGroupAddress', */
+/* 'getGroupAddresses', */
);
return $searches;
}
*/
class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Object_Inetorgperson
{
- /** Define attributes specific to this object type */
-
- /** Alias mail addresses */
- const ATTRIBUTE_ALIAS = 'alias';
-
- /** Delegates for this person */
- const ATTRIBUTE_DELEGATE = 'kolabDelegate';
-
- /** Marker for a deleted object */
- const ATTRIBUTE_DELETED = 'kolabDeleteFlag';
+ /** The specific object class of this object type */
+ const OBJECTCLASS_KOLABINETORGPERSON = 'kolabInetOrgPerson';
- /** How many days of the free/busy future should be calculated in advance? */
- const ATTRIBUTE_FBFUTURE = 'kolabFreeBusyFuture';
+ /** Define attributes specific to this object type */
/**
- * The home server of this person. It identifies the correct machine in a
- * master/slave setup.
+ * The attributes defined for this class.
+ *
+ * @var array
*/
- const ATTRIBUTE_HOMESERVER = 'kolabHomeServer';
-
- /** The free/busy server of this person */
- const ATTRIBUTE_FREEBUSYHOST = 'kolabFreeBusyServer';
-
- /** The host that keeps the IMAP mail store of this person */
- const ATTRIBUTE_IMAPHOST = 'kolabImapServer';
-
- /** The invitation policy for this person */
- const ATTRIBUTE_IPOLICY = 'kolabInvitationPolicy';
-
- /** The salutation of this person. */
- const ATTRIBUTE_SALUTATION = 'kolabSalutation';
-
- /** Persons gender */
- const ATTRIBUTE_GENDER = 'gender';
-
- /** The marital status */
- const ATTRIBUTE_MARITALSTATUS = 'kolabMaritalStatus';
-
- /** The home fax number */
- const ATTRIBUTE_HOMEFAX = 'homeFacsimileTelephoneNumber';
-
- /** The german tax ID */
- const ATTRIBUTE_GERMANTAXID = 'germanTaxId';
-
- /** The country of residence */
- const ATTRIBUTE_COUNTRY = 'c';
-
- /** The IMAP quota */
- const ATTRIBUTE_QUOTA = 'cyrus-userquota';
-
- /** Allowed recipients for this person */
- const ATTRIBUTE_ALLOWEDRECIPIENTS = 'kolabAllowSMTPRecipient';
-
- /** Allowed senders for this person */
- const ATTRIBUTE_ALLOWEDFROM = 'kolabAllowSMTPFrom';
-
- /** The date of birth */
- const ATTRIBUTE_DATEOFBIRTH = 'apple-birthday';
-
- /** The date of birth as Horde_Date */
- const ATTRDATE_DATEOFBIRTH = 'apple-birthdayDate';
-
- /** The place of birth */
- const ATTRIBUTE_PLACEOFBIRTH = 'birthPlace';
-
- /** Birth name */
- const ATTRIBUTE_BIRTHNAME = 'birthName';
-
- /** Pseudonym */
- const ATTRIBUTE_PSEUDONYM = 'pseudonym';
-
- /** Country of citizenship */
- const ATTRIBUTE_COUNTRYCITIZENSHIP = 'countryOfCitizenship';
-
- /** Legal form (if the person is a legal entity) */
- const ATTRIBUTE_LEGALFORM = 'legalForm';
-
- /** Registered capital (if the person is a legal entity) */
- const ATTRIBUTE_REGISTEREDCAPITAL = 'tradeRegisterRegisteredCapital';
-
- /** URI for bylaw (if the person is a legal entity) */
- const ATTRIBUTE_BYLAWURI = 'bylawURI';
-
- /** Date of incorporation (if the person is a legal entity) */
- const ATTRIBUTE_DATEOFINCORPORATION = 'dateOfIncorporation';
-
- /** Legal representative (if the person is a legal entity) */
- const ATTRIBUTE_LEGALREPRESENTATIVE = 'legalRepresentative';
-
- /** Commercial procuration (if the person is a legal entity) */
- const ATTRIBUTE_COMMERCIALPROCURATION = 'commercialProcuration';
-
- /** Legal representation policy (if the person is a legal entity) */
- const ATTRIBUTE_LEGALREPRESENTATIONPOLICY = 'legalRepresentationPolicy';
-
- /** Acting deputy (if the person is a legal entity) */
- const ATTRIBUTE_ACTINGDEPUTY = 'actingDeputy';
-
- /** VAT number (if the person is a legal entity) */
- const ATTRIBUTE_VATNUMBER = 'VATNumber';
-
- /** Additional legal relationships (if the person is a legal entity) */
- const ATTRIBUTE_OTHERLEGAL = 'otherLegalRelationship';
-
- /** Is this entity in liquidation? (if the person is a legal entity) */
- const ATTRIBUTE_INLIQUIDATION = 'inLiquidation';
-
- /** Type of entity as given by the trade register (if the person is a legal entity) */
- const ATTRIBUTE_TRTYPE = 'tradeRegisterType';
-
- /** Location of entity as given by the trade register (if the person is a legal entity) */
- const ATTRIBUTE_TRLOCATION = 'tradeRegisterLocation';
-
- /** Identifier of entity as given by the trade register (if the person is a legal entity) */
- const ATTRIBUTE_TRIDENTIFIER = 'tradeRegisterIdentifier';
-
- /** URI of entity as given by the trade register (if the person is a legal entity) */
- const ATTRIBUTE_TRURI = 'tradeRegisterURI';
-
- /** Date of last change in the trade register (if the person is a legal entity) */
- const ATTRIBUTE_TRLASTCHANGED = 'tradeRegisterLastChangedDate';
-
- /** Subdomain for this person */
- const ATTRIBUTE_DC = 'domainComponent';
+ static public $attributes = array(
+ 'alias', 'kolabDelegate', 'kolabDeleteFlag', 'kolabFreeBusyFuture',
+ 'kolabHomeServer', 'kolabFreeBusyServer', 'kolabImapServer',
+ 'kolabInvitationPolicy', 'kolabSalutation', 'gender',
+ 'kolabMaritalStatus', 'homeFacsimileTelephoneNumber', 'germanTaxId',
+ 'c', 'cyrus-userquota', 'kolabAllowSMTPRecipient', 'kolabAllowSMTPFrom',
+ 'apple-birthday', 'apple-birthdayDate', 'birthPlace', 'birthName',
+ 'pseudonym', 'countryOfCitizenship', 'legalForm',
+ 'tradeRegisterRegisteredCapital', 'bylawURI', 'dateOfIncorporation',
+ 'legalRepresentative', 'commercialProcuration',
+ 'legalRepresentationPolicy', 'actingDeputy', 'VATNumber',
+ 'otherLegalRelationship', 'inLiquidation', 'tradeRegisterType',
+ 'tradeRegisterLocation', 'tradeRegisterIdentifier', 'tradeRegisterURI',
+ 'tradeRegisterLastChangedDate', 'domainComponent',
+ );
- /** The specific object class of this object type */
- const OBJECTCLASS_KOLABINETORGPERSON = 'kolabInetOrgPerson';
/**
* A structure to initialize the attribute structure for this class.
*/
public static function getFilter()
{
- $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_OC,
- 'op' => '=',
- 'test' => self::OBJECTCLASS_KOLABINETORGPERSON),
- ),
+ $filter = new Horde_Kolab_Server_Query_Element_Equals(
+ 'Objectclass',
+ self::OBJECTCLASS_KOLABINETORGPERSON
);
- return $criteria;
+ return $filter;
}
/**
static public function getSearchOperations()
{
$searches = array(
- 'uidForSearch',
- 'uidForId',
- 'uidForMail',
- 'uidForIdOrMail',
- 'uidForAlias',
- 'uidForMailOrAlias',
- 'uidForIdOrMailOrAlias',
- 'mailForIdOrMail',
- 'addrsForIdOrMail',
+ '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;
}
/**
- * Identify the kolab UID for the first object found using the specified
- * search criteria.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param array $criteria The search parameters as array.
- * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
- *
- * @return boolean|string|array The UID(s) or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForSearch($server, $criteria,
- $restrict = 0)
- {
- $users = array('field' => self::ATTRIBUTE_OC,
- 'op' => '=',
- 'test' => self::OBJECTCLASS_KOLABINETORGPERSON);
- if (!empty($criteria)) {
- $criteria = array('AND' => array($users, $criteria));
- } else {
- $criteria = array('AND' => array($users));
- }
- return self::basicUidForSearch($server, $criteria, $restrict);
- }
-
- /**
- * Identify the UID for the first object found with the given ID.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $id Search for objects with this ID.
- * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
- *
- * @return mixed The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForId($server, $id,
- $restrict = 0)
- {
- $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_SID,
- 'op' => '=',
- 'test' => $id),
- ),
- );
- return self::uidForSearch($server, $criteria, $restrict);
- }
-
- /**
- * Identify the UID for the first user found with the given mail.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $mail Search for users with this mail address.
- * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
- *
- * @return mixed The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForMail($server, $mail,
- $restrict = 0)
- {
- $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_MAIL,
- 'op' => '=',
- 'test' => $mail),
- ),
- );
- return self::uidForSearch($server, $criteria, $restrict);
- }
-
- /**
- * Identify the UID for the first object found with the given ID or mail.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $id Search for objects with this uid/mail.
- *
- * @return string|boolean The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForIdOrMail($server, $id)
- {
- $criteria = array('OR' =>
- array(
- array('field' => self::ATTRIBUTE_SID,
- 'op' => '=',
- 'test' => $id),
- array('field' => self::ATTRIBUTE_MAIL,
- 'op' => '=',
- 'test' => $id),
- ),
- );
- return self::uidForSearch($server, $criteria);
- }
-
- /**
- * Identify the UID for the first object found with the given alias.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $mail Search for objects with this mail alias.
- * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
- *
- * @return mixed The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForAlias($server, $mail,
- $restrict = 0)
- {
- $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_ALIAS,
- 'op' => '=',
- 'test' => $mail),
- ),
- );
- return self::uidForSearch($server, $criteria, $restrict);
- }
-
-
- /**
- * Identify the UID for the first object found with the given mail
- * address or alias.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $mail Search for objects with this mail address
- * or alias.
- *
- * @return string|boolean The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForMailOrAlias($server, $mail)
- {
- $criteria = array('OR' =>
- array(
- array('field' => self::ATTRIBUTE_ALIAS,
- 'op' => '=',
- 'test' => $mail),
- array('field' => self::ATTRIBUTE_MAIL,
- 'op' => '=',
- 'test' => $mail),
- )
- );
- return self::uidForSearch($server, $criteria);
- }
-
- /**
- * Identify the UID for the first object found with the given ID,
- * mail or alias.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $id Search for objects with this ID/mail/alias.
- *
- * @return string|boolean The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForIdOrMailOrAlias($server, $id)
- {
- $criteria = array('OR' =>
- array(
- array('field' => self::ATTRIBUTE_ALIAS,
- 'op' => '=',
- 'test' => $id),
- array('field' => self::ATTRIBUTE_MAIL,
- 'op' => '=',
- 'test' => $id),
- array('field' => self::ATTRIBUTE_SID,
- 'op' => '=',
- 'test' => $id),
- ),
- );
- return self::uidForSearch($server, $criteria);
- }
-
- /**
- * Identify the primary mail attribute for the first object found
- * with the given ID or mail.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $id Search for objects with this ID/mail.
- *
- * @return mixed The mail address or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function mailForIdOrMail($server, $id)
- {
- $criteria = array('AND' =>
- array(
- array('field' => self::ATTRIBUTE_OC,
- 'op' => '=',
- 'test' => self::OBJECTCLASS_KOLABINETORGPERSON),
- array('OR' =>
- array(
- array('field' => self::ATTRIBUTE_SID,
- 'op' => '=',
- 'test' => $id),
- array('field' => self::ATTRIBUTE_MAIL,
- 'op' => '=',
- 'test' => $id),
- ),
- ),
- ),
- );
-
- $data = self::attrsForSearch($server, $criteria, array(self::ATTRIBUTE_MAIL),
- self::RESULT_STRICT);
- if (!empty($data)) {
- return $data[self::ATTRIBUTE_MAIL][0];
- } else {
- return false;
- }
- }
-
- /**
- * Returns a list of allowed email addresses for the given user.
- *
- * @param Horde_Kolab_Server $server The server to query.
- * @param string $id Search for objects with this ID/mail.
- *
- * @return array An array of allowed mail addresses.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function addrsForIdOrMail($server, $id)
- {
- $criteria = array('AND' =>
- array(
- array('field' => self::ATTRIBUTE_OC,
- 'op' => '=',
- 'test' => self::OBJECTCLASS_KOLABINETORGPERSON),
- array('OR' =>
- array(
- array('field' => self::ATTRIBUTE_SID,
- 'op' => '=',
- 'test' => $id),
- array('field' => self::ATTRIBUTE_MAIL,
- 'op' => '=',
- 'test' => $id),
- ),
- ),
- ),
- );
-
- $result = self::attrsForSearch($server, $criteria,
- array(self::ATTRIBUTE_MAIL,
- self::ATTRIBUTE_ALIAS),
- self::RESULT_STRICT);
- if (isset($result[self::ATTRIBUTE_ALIAS])) {
- $addrs = array_merge((array) $result[self::ATTRIBUTE_MAIL],
- (array) $result[self::ATTRIBUTE_ALIAS]);
- } else {
- $addrs = $result[self::ATTRIBUTE_MAIL];
- }
-
- if (empty($result)) {
- return array();
- }
- $criteria = array('AND' =>
- array(
- array('field' => self::ATTRIBUTE_OC,
- 'op' => '=',
- 'test' => self::OBJECTCLASS_KOLABINETORGPERSON),
- array('field' => self::ATTRIBUTE_DELEGATE,
- 'op' => '=',
- 'test' => $result[self::ATTRIBUTE_MAIL][0]),
- ),
- );
-
- $result = self::attrsForSearch($server, $criteria,
- array(self::ATTRIBUTE_MAIL,
- self::ATTRIBUTE_ALIAS),
- self::RESULT_MANY);
- if (!empty($result)) {
- foreach ($result as $adr) {
- if (isset($adr[self::ATTRIBUTE_MAIL])) {
- $addrs = array_merge((array) $addrs, (array) $adr[self::ATTRIBUTE_MAIL]);
- }
- if (isset($adr[self::ATTRIBUTE_ALIAS])) {
- $addrs = array_merge((array) $addrs, (array) $adr[self::ATTRIBUTE_ALIAS]);
- }
- }
- }
-
- $addrs = array_map('strtolower', $addrs);
-
- return $addrs;
- }
-
- /**
* Returns the server url of the given type for this user.
*
* This method is used to encapsulate multidomain support.
static public function getSearchOperations()
{
$searches = array(
- 'pop3AccountsForMail',
+/* 'pop3AccountsForMail', */
);
return $searches;
}
static public function getSearchOperations()
{
return array(
- 'uidForCn',
+ 'Horde_Kolab_Server_Object_Search_Guidforcn',
);
}
-
- /**
- * Identify the UID for the first object found with the given common name.
- *
- * @param Horde_Kolab_Server $server The server to search.
- * @param string $cn Search for objects with this
- * common name.
- * @param int $restrict A Horde_Kolab_Server::RESULT_*
- * result restriction.
- *
- * @return mixed The UID or false if there was no result.
- *
- * @throws Horde_Kolab_Server_Exception
- */
- static public function uidForCn($server, $cn,
- $restrict = 0)
- {
- $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_CN,
- 'op' => '=',
- 'test' => $cn),
- ),
- );
- return self::basicUidForSearch($server, $criteria, $restrict);
- }
-
}
\ No newline at end of file
interface Horde_Kolab_Server_Object_Search
{
/**
- * Perform the search.
+ * Return the refernce to the composite server.
*
- * @return mixed The search result.
+ * @return Horde_Kolab_Server_Composite
*/
- public function search();
+ 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
*
* @return mixed The search result.
*/
- public function search()
- {
- $criteria = func_get_arg(0);
- $attributes = func_get_arg(1);
-
+ public function searchAttributes(
+ Horde_Kolab_Server_Query_Element $criteria,
+ array $attributes
+ ) {
$params = array('attributes' => $attributes);
- return $this->_composite->server->find($criteria, $params);
+ return $this->getComposite()->structure->find($criteria, $params);
}
}
\ No newline at end of file
{
$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).
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Object_Search_Children
-extends 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.
- * @param string $objectclass The type of children
- * to return.
+ * @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 search()
+ public function searchChildren($parent_guid, $objectclass)
{
- $criteria = func_get_arg(0);
- $objectclass = func_get_arg(1);
-
- $criteria = new Horde_Kolab_Server_Query_Element_And(
- array(
- new Horde_Kolab_Server_Query_Element_Equals(
- Horde_Kolab_Server_Object_Top::ATTRIBUTE_OC,
- $objectclass
- ),
- $criteria
- )
+ $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 parent::search($criteria);
+ return self::guidFromResult($data);
}
}
\ No newline at end of file
/**
* A link to the search.
*
- * @var Horde_Kolab_Server_Search
+ * @var Horde_Kolab_Server_Object_Search
*/
private $_search;
*
* @param Horde_Kolab_Server_Search $search The search being restricted.
*/
- public function __construct(Horde_Kolab_Server_Search $search)
+ public function __construct(Horde_Kolab_Server_Object_Search $search)
{
$this->_search = $search;
}
/**
- * Perform the search.
+ * Return the refernce to the composite server.
*
- * @return mixed The search result.
+ * @return Horde_Kolab_Server_Composite
*/
- public function search()
+ 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, 'search'), $args);
+ $result = call_user_func_array(array($this->_search, $method), $args);
return array_pop($result);
}
}
\ No newline at end of file
}
/**
- * Perform the search.
+ * Return the refernce to the composite server.
*
- * @return mixed The search result.
+ * @return Horde_Kolab_Server_Composite
*/
- public function search()
+ 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(
*
* @param Horde_Kolab_Server_Query_Element $criteria The search criteria.
*
- * @return mixed The search result.
+ * @return array The search result.
*/
- public function search()
+ public function searchGuid(Horde_Kolab_Server_Query_Element $criteria)
{
- $criteria = func_get_arg(0);
-
$params = array(
- 'attributes' => Horde_Kolab_Server_Object_Top::ATTRIBUTE_GUID
+ 'attributes' => 'Guid'
);
- $data = $this->_composite->server->find($criteria, $params);
+ $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
static public function getSearchOperations()
{
$searches = array(
- 'Guid',
- 'Attributes',
- 'Children',
+ 'Horde_Kolab_Server_Object_Search_Guid',
+ 'Horde_Kolab_Server_Object_Search_Attributes',
+ 'Horde_Kolab_Server_Object_Search_Children',
);
return $searches;
}
private $_criteria;
/**
+ * The db structure.
+ *
+ * @var Horde_Kolab_Server_Structure
+ */
+ private $_structure;
+
+ /**
* Constructor.
*
* @param array $criteria The query criteria.
*/
- public function __construct(Horde_Kolab_Server_Query_Element $criteria)
- {
- $this->_criteria = $criteria;
+ public function __construct(
+ Horde_Kolab_Server_Query_Element $criteria,
+ Horde_Kolab_Server_Structure $structure
+ ) {
+ $this->_criteria = $criteria;
+ $this->_structure = $structure;
}
/**
*/
public function __toString()
{
- $filter = $this->_criteria->convert($this);
- return $filter->asString();
+ try {
+ $filter = $this->_criteria->convert($this);
+ $result = $filter->asString();
+ return $result;
+ } catch (Horde_Kolab_Server_Exception $e) {
+ return '';
+ }
}
/**
$operator
) {
$result = Net_LDAP2_Filter::create(
- $single->getName(), $operator, $single->getValue()
+ $this->_structure->getInternalAttribute($single->getName()),
+ $operator,
+ $single->getValue()
);
$this->_handleError($result);
return $result;
$server_searches = array();
foreach ($this->_composite->structure->getSupportedObjects() as $sobj) {
$methods = get_class_methods($sobj);
- if (in_array('getSearchOperations', $methods)) {
- $searches = call_user_func(array($sobj, 'getSearchOperations'));
- foreach ($searches as $search) {
- if (in_array($search, $methods)) {
- $server_searches[$search] = array('class' => $sobj);
- } else {
+ if (!in_array('getSearchOperations', $methods)) {
+ continue;
+ }
+ $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(
- "Class \"%s\" does not support method \"%s\"!",
+ "%s::getSearchOperations specified non-existing class \"%s\"!",
$sobj,
- $search
- );
- }
+ $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);
}
}
}
public function __call($method, $args)
{
if (in_array($method, array_keys($this->_searches))) {
- array_unshift($args, $this->_composite);
- return call_user_func_array(
- array(
- $this->_searches[$method]['class'], $method
- ),
- $args
- );
+ $class = $this->_searches[$method]['class'];
+ $search = new $class($this->_composite);
+ return call_user_func_array(array($search, $method), $args);
}
throw new Horde_Kolab_Server_Exception(
sprintf(
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
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.
*
*
* @var Horde_Kolab_Server_Composite
*/
- protected $composite;
+ private $_composite;
+
+ /**
+ * 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()
+ ) {
+ $query = new Horde_Kolab_Server_Query_Ldap($criteria, $this);
+ return $this->_composite->server->find(
+ (string) $query, $params
+ );
+ }
+
+ /**
+ * 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()
+ ) {
+ $query = new Horde_Kolab_Server_Query_Ldap($criteria, $this);
+ return $this->_composite->server->findBelow(
+ (string) $query, $parent, $params
+ );
+ }
/**
* Set the composite server reference for this object.
*/
public function setComposite(Horde_Kolab_Server_Composite $composite)
{
- $this->composite = $composite;
+ $this->_composite = $composite;
+ }
+
+ /**
+ * Get the composite server reference for this object.
+ *
+ * @return Horde_Kolab_Server_Composite A link to the composite server
+ * handler.
+ */
+ public function getComposite()
+ {
+ return $this->_composite;
}
}
return parent::_determineType($guid, $ocs);
}
- $groups = $this->composite->search->getGroups($guid);
+ $groups = $this->getComposite()->search->getGroups($guid);
if (!empty($groups)) {
- $base = $this->composite->server->getBaseGuid();
+ $base = $this->getComposite()->server->getBaseGuid();
if (in_array('cn=admin,cn=internal,' . $base, $groups)) {
return 'Horde_Kolab_Server_Object_Kolab_Administrator';
}
} catch (Horde_Kolab_Server_Exception $e) {
}
}
- if ($oc == 'top') {
- return 'Horde_Kolab_Server_Object';
- }
throw new Horde_Kolab_Server_Exception(
sprintf("Unknown object type for GUID %s.", $guid),
Horde_Kolab_Server_Exception::SYSTEM
*/
public function generateServerGuid($type, $id, array $info)
{
- return sprintf('%s,%s', $id, $this->composite->server->getBaseGuid());
+ return sprintf('%s,%s', $id, $this->getComposite()->server->getBaseGuid());
}
/**
*/
protected function getObjectClasses($guid)
{
- $object = $this->composite->server->read(
+ $object = $this->getComposite()->server->read(
$guid, array('objectClass')
);
if (!isset($object['objectClass'])) {
);
return $result;
}
+
+ /**
+ * 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)
+ {
+ switch ($external) {
+ case 'Objectclass':
+ return 'objectClass';
+ case 'Guid':
+ return 'dn';
+ case 'Uid':
+ return 'uid';
+ case 'Mail':
+ return 'mail';
+ default:
+ throw new Horde_Kolab_Server_Exception(
+ sprintf('Undefined internal attribute "%s"', $external)
+ );
+ }
+ }
}
<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" />
<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" />
<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="Factory">
+ <file name="CleanerTest.php" role="test" />
+ <file name="ConfigurationTest.php" role="test" />
+ <dir name="Conn">
+ <file name="ConfigurationTest.php" role="test" />
+ <file name="InjectorTest.php" role="test" />
+ <file name="LdapTest.php" role="test" />
+ <file name="MockTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Factory/Conn -->
+ <file name="ConstructorTest.php" role="test" />
+ <file name="InjectorTest.php" role="test" />
+ <file name="KolabTest.php" role="test" />
+ <file name="LoggedTest.php" role="test" />
+ <file name="MappedTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Factory -->
+ <file name="LdapTest.php" role="test" />
+ <dir name="Ldap">
+ <file name="FilteredTest.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="Result">
+ <file name="LdapTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Result -->
+ <dir name="Search">
+ <file name="BaseTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Server/Class/Server/Search -->
+ <dir name="Structure">
+ <file name="KolabTest.php" role="test" />
+ <file name="LdapTest.php" role="test" />
+ </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="UserHandlingTest.php" role="test" />
<file name="UserTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Server/Integration -->
- <file name="LdapBase.php" role="test" />
+ <file name="LdapTestCase.php" role="test" />
<dir name="Object">
<file name="BaseTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Server/Object -->
<file name="ElementTest.php" role="test" />
<file name="LdapTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Server/Query -->
- <dir name="Result">
- <file name="LdapTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Result -->
- <dir name="Search">
- <file name="SearchTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Search -->
- <dir name="Server">
- <file name="FactoryTest.php" role="test" />
- <file name="FilteredTest.php" role="test" />
- <file name="LdapTest.php" role="test" />
- <file name="LoggedTest.php" role="test" />
- <file name="StandardTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Server -->
- <dir name="Structure">
- <file name="KolabTest.php" role="test" />
- <file name="LdapTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Server/Structure -->
</dir> <!-- /test/Horde/Kolab/Server -->
</dir> <!-- /test/Horde/Kolab -->
</dir> <!-- /test/Horde -->
<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/Attributes.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="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/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/Factory/Conn/InjectorTest.php" as="Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php" as="Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php" as="Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php" as="Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php" as="Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php" as="Horde/Kolab/Server/Class/Server/Factory/KolabTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php" as="Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php" as="Horde/Kolab/Server/Class/Server/Factory/MappedTest.php" />
+ <install name="test/Horde/Kolab/Server/Class/Server/LdapTest.php" as="Horde/Kolab/Server/Class/Server/LdapTest.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/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/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/LdapBase.php" as="Horde/Kolab/Server/LdapBase.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" />
- <install name="test/Horde/Kolab/Server/Result/LdapTest.php" as="Horde/Kolab/Server/Result/LdapTest.php" />
- <install name="test/Horde/Kolab/Server/Search/SearchTest.php" as="Horde/Kolab/Server/Search/SearchTest.php" />
- <install name="test/Horde/Kolab/Server/Server/FactoryTest.php" as="Horde/Kolab/Server/Server/FactoryTest.php" />
- <install name="test/Horde/Kolab/Server/Server/FilteredTest.php" as="Horde/Kolab/Server/Server/FilteredTest.php" />
- <install name="test/Horde/Kolab/Server/Server/LdapTest.php" as="Horde/Kolab/Server/Server/LdapTest.php" />
- <install name="test/Horde/Kolab/Server/Server/LoggedTest.php" as="Horde/Kolab/Server/Server/LoggedTest.php" />
- <install name="test/Horde/Kolab/Server/Server/StandardTest.php" as="Horde/Kolab/Server/Server/StandardTest.php" />
- <install name="test/Horde/Kolab/Server/Structure/KolabTest.php" as="Horde/Kolab/Server/Structure/KolabTest.php" />
- <install name="test/Horde/Kolab/Server/Structure/LdapTest.php" as="Horde/Kolab/Server/Structure/LdapTest.php" />
</filelist>
</phprelease>
<changelog>
/**
* Prepare the test setup.
*/
-require_once dirname(__FILE__) . '/../Autoload.php';
+require_once dirname(__FILE__) . '/../TestCase.php';
/**
* Test the base attribute.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.
* @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 PHPUnit_Framework_TestCase
+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->getMock(
- 'Horde_Kolab_Server_Composite', array(), array(), '', false
- );
+ $this->composite = $this->getMockedComposite();
}
public function testMethodConstructHasParameterObjectTheObjectOwningTheAttributeAndParameterCompositeWhichIsTheLinkToTheServer()
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());
}
/**
* Test the value attribute.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../../../Autoload.php';
+require_once dirname(__FILE__) . '/../../../LdapTestCase.php';
/**
* Test the configuration based server factory.
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Class_Server_Factory_ConfigurationTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Server_LdapTestCase
{
public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration()
{
--- /dev/null
+<?php
+/**
+ * Test the configuration based connection factory.
+ *
+ * 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 configuration based connection factory.
+ *
+ * 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_Factory_Conn_ConfigurationTest
+extends Horde_Kolab_Server_LdapTestCase
+{
+ public function testMethodConstructHasParameterArrayConfiguration()
+ {
+ $factory = new Horde_Kolab_Server_Factory_Conn_Configuration(
+ array('basedn' => 'a')
+ );
+ }
+
+ public function testMethodConstructHasPostconditionThatTheConfigurationWasSaved()
+ {
+ $factory = new Horde_Kolab_Server_Factory_Conn_Configuration(
+ array('basedn' => 'a')
+ );
+ $this->assertEquals(array('basedn' => 'a'), $factory->getConfiguration());
+ }
+
+ public function testMethodConstructHasResultArrayTheConfiguration()
+ {
+ $factory = new Horde_Kolab_Server_Factory_Conn_Configuration(
+ array('basedn' => 'a')
+ );
+ $this->assertType('array', $factory->getConfiguration());
+ }
+
+ public function testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet()
+ {
+ $factory = new Horde_Kolab_Server_Factory_Conn_Configuration(
+ array('mock' => true)
+ );
+ $this->assertType('Horde_Kolab_Server_Connection_Mock', $factory->getConnection());
+ }
+
+ public function testMethodGetconnectionHasResultMockConnectionIfConfiguredThatWay()
+ {
+ $this->testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet();
+ }
+
+ public function testMethodGetconnectionHasResultLdapConnectionIfConfiguredThatWay()
+ {
+ $factory = new Horde_Kolab_Server_Factory_Conn_Configuration(
+ array('basedn' => 'a')
+ );
+ $this->assertType('Horde_Kolab_Server_Connection_Simpleldap', $factory->getConnection());
+ }
+}
\ No newline at end of file
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../../../../Autoload.php';
+require_once dirname(__FILE__) . '/../../../../LdapTestCase.php';
/**
* Test the ldap connection factory.
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Class_Server_Factory_Conn_LdapTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Server_LdapTestCase
{
public function testMethodSetconfigurationHasPostconditionThatTheServerParameterWasRewritten()
{
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../../../Autoload.php';
+require_once dirname(__FILE__) . '/../../../LdapTestCase.php';
/**
* Test the mapping server factory.
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Class_Server_Factory_ConstructorTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Server_LdapTestCase
{
public function setUp()
{
+ 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');
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../../../Autoload.php';
+require_once dirname(__FILE__) . '/../../../LdapTestCase.php';
/**
* Test the injector based server factory.
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Class_Server_Factory_InjectorTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Server_LdapTestCase
{
private function _getFactory(array $configuration = array())
{
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../../../Autoload.php';
+require_once dirname(__FILE__) . '/../../../LdapTestCase.php';
/**
* Test the default Kolab server factory.
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
class Horde_Kolab_Server_Class_Server_Factory_KolabTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Server_LdapTestCase
{
public function setUp()
{
+ parent::setUp();
$this->conn_factory = $this->getMock('Horde_Kolab_Server_Factory_Conn');
$this->connection = $this->getMock('Horde_Kolab_Server_Connection');
}
--- /dev/null
+<?php
+/**
+ * Test the LDAP changeset 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the LDAP changeset 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_Ldap_ChangesTest extends PHPUnit_Framework_TestCase
+{
+ public function testMethodConstructHasParameterServerobject()
+ {
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $this->getMock('Horde_Kolab_Server_Object'), array()
+ );
+ }
+
+ public function testMethodConstructHasParameterArrayDataToBeStored()
+ {
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $this->getMock('Horde_Kolab_Server_Object'),
+ array('store' => 'value')
+ );
+ }
+
+ public function testMethodGetchangesetHasResultArrayEmptyIfOldAndNewDatasetsWereEmpty()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array()));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array()
+ );
+ $this->assertEquals(array(), $changes->getChangeset());
+ }
+
+ public function testMethodGetchangesetHasResultArrayEmptyIfOldAndNewDatasetsWereEqual()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array('a' => array('a'))));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array('a' => array('a'))
+ );
+ $this->assertEquals(array(), $changes->getChangeset());
+ }
+
+ public function testMethodGetchangesetHasResultArrayNewAttributesInNewDatasetAsAdded()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array()));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array('new' => 'a')
+ );
+ $this->assertEquals(
+ array(
+ 'add' => array(
+ 'new' => 'a'
+ )
+ ),
+ $changes->getChangeset()
+ );
+ }
+
+ public function testMethodGetchangesetHasResultArrayMissingValuesInNewDatasetAsDeleted()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array('old' => 'a')));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array()
+ );
+ $this->assertEquals(
+ array(
+ 'delete' => array(
+ 'old'
+ )
+ ),
+ $changes->getChangeset()
+ );
+ }
+
+ public function testMethodGetchangesetHasResultArraySingleValuesWithDifferencesAsReplaced()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array('value' => 'a')));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array('value' => 'b')
+ );
+ $this->assertEquals(
+ array(
+ 'replace' => array(
+ 'value' => 'b'
+ )
+ ),
+ $changes->getChangeset()
+ );
+ }
+
+ public function testMethodGetchangesetHasResultArrayTheNewValuesAsAdded()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array('value' => array('a', 'b', 'c'))));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array('value' => array('a', 'b', 'c', 'd'))
+ );
+ $this->assertEquals(
+ array(
+ 'add' => array(
+ 'value' => array('d')
+ )
+ ),
+ $changes->getChangeset()
+ );
+ }
+
+ public function testMethodGetchangesetHasResultArrayTheRemovedValuesAsDeleted()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array('value' => array('a', 'b', 'c'))));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array('value' => array('b', 'c'))
+ );
+ $this->assertEquals(
+ array(
+ 'delete' => array(
+ 'value' => array('a')
+ )
+ ),
+ $changes->getChangeset()
+ );
+ }
+
+ public function testMethodGetchangesetHasResultArrayTheNewValuesAsAddedAndTheRemovedValuesAsDeleted()
+ {
+ $object = $this->getMock('Horde_Kolab_Server_Object');
+ $object->expects($this->once())
+ ->method('readInternal')
+ ->will($this->returnValue(array('value' => array('a', 'b', 'c'))));
+ $changes = new Horde_Kolab_Server_Ldap_Changes(
+ $object, array('value' => array('b', 'c', 'd'))
+ );
+ $this->assertEquals(
+ array(
+ 'add' => array(
+ 'value' => array('d')
+ ),
+ 'delete' => array(
+ 'value' => array('a')
+ )
+ ),
+ $changes->getChangeset()
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the filtered LDAP 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 filtered LDAP driver.
+ *
+ * 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_Ldap_FilteredTest extends Horde_Kolab_Server_LdapTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->ldap_read = $this->getMock('Net_LDAP2');
+ $this->ldap_write = $this->getMock('Net_LDAP2');
+ $connection = new Horde_Kolab_Server_Connection_Splittedldap(
+ $this->ldap_read,
+ $this->ldap_write
+ );
+
+ $this->server = new Horde_Kolab_Server_Ldap_Filtered(
+ $connection,
+ 'base',
+ 'filter'
+ );
+ }
+
+ private function getSearchResultMock()
+ {
+ $result = $this->getMock(
+ 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
+ );
+ $result->expects($this->any())
+ ->method('as_struct')
+ ->will($this->returnValue(array(array('dn' => 'test'))));
+ $result->expects($this->any())
+ ->method('count')
+ ->will($this->returnValue(1));
+ return $result;
+ }
+
+ public function testMethodFindbelowHasParameterQueryelementTheSearchCriteria()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('', '(&(filter)(equals=equals))', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->findBelow('(equals=equals)', '');
+ }
+
+ public function testMethodFindbelowHasParameterStringParent()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('parent', '(&(filter)(equals=equals))', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->findBelow('(equals=equals)', 'parent', array());
+ }
+
+ public function testMethodFindbelowHasParameterArrayAdditionalParameters()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('', '(&(filter)(equals=equals))', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->findBelow('(equals=equals)', '', array());
+ }
+
+ public function testMethodFindbelowReturnsArraySearchResult()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('parent', '(&(filter)(equals=equals))', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->assertEquals(
+ array(array('dn' => 'test')),
+ $this->server->findBelow('(equals=equals)', 'parent')->asArray()
+ );
+ }
+
+ public function testMethodFindbelowThrowsExceptionIfTheSearchFailed()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->will($this->returnValue(new PEAR_Error('Search failed!')));
+ try {
+ $this->assertEquals(array('dn' => 'test'), $this->server->findBelow('(equals=equals)', ''));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Search failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Test the standard LDAP 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 standard LDAP driver.
+ *
+ * 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_Ldap_StandardTest extends Horde_Kolab_Server_LdapTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->ldap_read = $this->getMock('Net_LDAP2');
+ $this->ldap_write = $this->getMock('Net_LDAP2');
+ $connection = new Horde_Kolab_Server_Connection_Splittedldap(
+ $this->ldap_read,
+ $this->ldap_write
+ );
+
+ $this->server = new Horde_Kolab_Server_Ldap_Standard(
+ $connection,
+ 'base'
+ );
+ }
+
+ private function getSearchResultMock()
+ {
+ $result = $this->getMock(
+ 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
+ );
+ $result->expects($this->any())
+ ->method('as_struct')
+ ->will($this->returnValue(array(array('dn' => 'test'))));
+ $result->expects($this->any())
+ ->method('count')
+ ->will($this->returnValue(1));
+ return $result;
+ }
+
+ public function testMethodFindbelowHasParameterQueryelementTheSearchCriteria()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->findBelow('(equals=equals)', '');
+ }
+
+ public function testMethodFindbelowHasParameterStringParent()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('parent', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->findBelow('(equals=equals)', 'parent', array());
+ }
+
+ public function testMethodFindbelowHasParameterArrayAdditionalParameters()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->findBelow('(equals=equals)', '', array());
+ }
+
+ public function testMethodFindbelowReturnsArraySearchResult()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('parent', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->assertEquals(
+ array(array('dn' => 'test')),
+ $this->server->findBelow('(equals=equals)', 'parent')->asArray()
+ );
+ }
+
+ public function testMethodFindbelowThrowsExceptionIfTheSearchFailed()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->will($this->returnValue(new PEAR_Error('Search failed!')));
+ try {
+ $this->assertEquals(array('dn' => 'test'), $this->server->findBelow('(equals=equals)', ''));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Search failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Test the LDAP 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 LDAP backend.
+ *
+ * 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_LdapTest extends Horde_Kolab_Server_LdapTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->ldap_read = $this->getMock('Net_LDAP2');
+ $this->ldap_write = $this->getMock('Net_LDAP2');
+ $connection = new Horde_Kolab_Server_Connection_Splittedldap(
+ $this->ldap_read,
+ $this->ldap_write
+ );
+
+ $this->server = new Horde_Kolab_Server_Ldap_Standard(
+ $connection,
+ 'base'
+ );
+ }
+
+ private function getSearchResultMock()
+ {
+ $result = $this->getMock(
+ 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
+ );
+ $result->expects($this->any())
+ ->method('as_struct')
+ ->will($this->returnValue(array(array('dn' => 'test'))));
+ $result->expects($this->any())
+ ->method('count')
+ ->will($this->returnValue(1));
+ return $result;
+ }
+
+ public function testMethodGetbaseguidHasResultStringBaseGuid()
+ {
+ $this->assertEquals('base', $this->server->getBaseGuid());
+ }
+
+ public function testMethodConnectguidHasStringParameterGuid()
+ {
+ $this->server->connectGuid('guid', '');
+ }
+
+ public function testMethodConnectguidHasStringParameterPass()
+ {
+ $this->server->connectGuid('', 'pass');
+ }
+
+ public function testMethodConnectguidHasPostconditionThatTheGuidIsSetIfTheConnectionWasSuccessful()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('bind')
+ ->will($this->returnValue(true));
+ $this->server->connectGuid('test', 'test');
+ $this->assertEquals('test', $this->server->getGuid());
+ }
+
+ public function testMethodConnectguidDoesNotCallBindAgainIfAlreadyConnectedWithThisGuid()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('bind')
+ ->will($this->returnValue(true));
+ $this->server->connectGuid('test', 'test');
+ $this->server->connectGuid('test', 'test');
+ }
+
+ public function testMethodConnectguidDoesNotCallBindAgainIfAlreadyConnectedWithThisGuidEvenIfTheGuidIsEmpty()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('bind')
+ ->will($this->returnValue(true));
+ $this->server->connectGuid('', '');
+ $this->server->connectGuid('', '');
+ }
+
+ public function testMethodConnectguidThrowsExceptionIfTheConnectionFailed()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('bind')
+ ->will($this->returnValue(new PEAR_Error('Bind failed!')));
+ try {
+ $this->server->connectGuid('test', 'test');
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Bind failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::BIND_FAILED, $e->getCode());
+ }
+ }
+
+ public function testMethodGetguidHasResultBooleanFalseIfNotConnected()
+ {
+ $this->assertSame(false, $this->server->getGuid());
+ }
+
+ public function testMethodGetguidHasResultStringGuidIfNotConnected()
+ {
+ $this->server->connectGuid('guid', '');
+ $this->assertEquals('guid', $this->server->getGuid());
+ }
+
+ public function testMethodReadHasParameterStringGuid()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('test', null, array('scope' => 'base'))
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->read('test');
+ }
+
+ public function testMethodReadReturnsArrayReadResult()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('test', null, array('scope' => 'base'))
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->assertEquals(array('dn' => 'test'), $this->server->read('test'));
+ }
+
+ public function testMethodReadThrowsExceptionIfTheObjectWasNotFound()
+ {
+ $result = $this->getMock(
+ 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
+ );
+ $result->expects($this->exactly(1))
+ ->method('count')
+ ->will($this->returnValue(0));
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->will($this->returnValue($result));
+ try {
+ $this->assertEquals(array(), $this->server->read('test'));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Empty result!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::EMPTY_RESULT, $e->getCode());
+ }
+ }
+
+ public function testMethodReadAttributesHasParameterStringGuid()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('guid', null, array('scope' => 'base', 'attributes' => array()))
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->readAttributes('guid', array());
+ }
+
+ public function testMethodReadAttributesHasParameterArrayAttributes()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('', null, array('scope' => 'base', 'attributes' => array('a')))
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->readAttributes('', array('a'));
+ }
+
+ public function testMethodReadAttributesReturnsArrayReadResult()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('test', null, array('scope' => 'base', 'attributes' => array('a')))
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->assertEquals(array('dn' => 'test'), $this->server->readAttributes('test', array('a')));
+ }
+
+ public function testMethodReadAttributesThrowsExceptionIfTheObjectWasNotFound()
+ {
+ $result = $this->getMock(
+ 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
+ );
+ $result->expects($this->exactly(1))
+ ->method('count')
+ ->will($this->returnValue(0));
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('test', null, array('scope' => 'base', 'attributes' => array('a')))
+ ->will($this->returnValue($result));
+ try {
+ $this->assertEquals(array(), $this->server->readAttributes('test', array('a')));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Empty result!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::EMPTY_RESULT, $e->getCode());
+ }
+ }
+
+ public function testMethodFindHasParameterQueryelementTheSearchCriteria()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('base', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->find('(equals=equals)');
+ }
+
+ public function testMethodFindHasParameterArrayAdditionalParameters()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('base', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->server->find('(equals=equals)', array());
+ }
+
+ public function testMethodFindReturnsArraySearchResult()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->with('base', '(equals=equals)', array())
+ ->will($this->returnValue($this->getSearchResultMock()));
+ $this->assertEquals(
+ array(array('dn' => 'test')),
+ $this->server->find('(equals=equals)')->asArray()
+ );
+ }
+
+ public function testMethodFindThrowsExceptionIfTheSearchFailed()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('search')
+ ->will($this->returnValue(new PEAR_Error('Search failed!')));
+ try {
+ $this->assertEquals(array('dn' => 'test'), $this->server->find('(equals=equals)'));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Search failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodSaveHasParameterObjectTheObjectToModifyOnTheServer()
+ {
+ $entry = $this->getMock(
+ 'Net_LDAP2_Entry', array(), array(), '', false
+ );
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('getEntry')
+ ->will($this->returnValue($entry));
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('modify')
+ ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
+ $object->expects($this->exactly(1))
+ ->method('readInternal')
+ ->will($this->returnValue(array()));
+ $this->server->save($object, array('attributes' => array('dn')));
+ }
+
+ public function testMethodSaveHasParameterArrayData()
+ {
+ $entry = $this->getMock(
+ 'Net_LDAP2_Entry', array(), array(), '', false
+ );
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('getEntry')
+ ->will($this->returnValue($entry));
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('modify')
+ ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
+ $object->expects($this->exactly(1))
+ ->method('readInternal')
+ ->will($this->returnValue(array()));
+ $this->server->save($object, array('dn' => 'test'));
+ }
+
+ public function testMethodSaveHasPostconditionThatTheEntryWasModified()
+ {
+ $entry = $this->getMock(
+ 'Net_LDAP2_Entry', array(), array(), '', false
+ );
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('getEntry')
+ ->will($this->returnValue($entry));
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('modify')
+ ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
+ $object->expects($this->exactly(1))
+ ->method('readInternal')
+ ->will($this->returnValue(array()));
+ $this->server->save($object, array('dn' => 'test'));
+ }
+
+ public function testMethodSaveThrowsExceptionIfSavingDataFailed()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('modify')
+ ->will($this->returnValue(new PEAR_Error('Saving failed!')));
+ $object->expects($this->exactly(1))
+ ->method('readInternal')
+ ->will($this->returnValue(array()));
+ try {
+ $this->server->save($object, array('dn' => 'test'));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Saving failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodAddHasParameterObjectTheObjectToAddToTheServer()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('add')
+ ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
+ $this->server->add($object, array('attributes' => array('dn')));
+ }
+
+ public function testMethodAddHasParameterArrayData()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('add')
+ ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
+ $this->server->add($object, array('dn' => 'test'));
+ }
+
+ public function testMethodAddHasPostconditionThatTheEntryWasModified()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('add')
+ ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
+ $this->server->add($object, array('dn' => 'test'));
+ }
+
+ public function testMethodAddThrowsExceptionIfSavingDataFailed()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('add')
+ ->will($this->returnValue(new PEAR_Error('Saving failed!')));
+ try {
+ $this->server->add($object, array('add' => array('dn' => 'test')));
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Saving failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodDeleteHasParameterStringGuid()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('delete')
+ ->with('guid');
+ $this->server->delete('guid');
+ }
+
+ public function testMethodDeleteHasPostconditionThatTheEntryWasDeleted()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('delete')
+ ->with('test');
+ $this->server->delete('test');
+ }
+
+ public function testMethodDeleteThrowsExceptionIfDeletingDataFailed()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('delete')
+ ->will($this->returnValue(new PEAR_Error('Deleting failed!')));
+ try {
+ $this->server->delete('test');
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Deleting failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodRenameHasParameterStringOldGuid()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('move')
+ ->with('oldguid', '');
+ $this->server->rename('oldguid', '');
+ }
+
+ public function testMethodRenameHasParameterStringNewGuid()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('move')
+ ->with('', 'newguid');
+ $this->server->rename('', 'newguid');
+ }
+
+ public function testMethodRenameHasPostconditionThatTheEntryWasRenamed()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('move')
+ ->with('test', 'new');
+ $this->server->rename('test', 'new');
+ }
+
+ public function testMethodRenameThrowsExceptionIfRenamingDataFailed()
+ {
+ $this->ldap_write->expects($this->exactly(1))
+ ->method('move')
+ ->will($this->returnValue(new PEAR_Error('Renaming failed!')));
+ try {
+ $this->server->rename('test', 'new');
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Renaming failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodGetschemaReturnsArrayWithADescriptionOfAllObjectClasses()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('schema')
+ ->will($this->returnValue(array('schema' => 'dummy')));
+ $this->assertEquals(
+ array('schema' => 'dummy'),
+ $this->server->getSchema()
+ );
+ }
+
+ public function testMethodGetschemaThrowsExceptionIfTheSchemaRetrievalFailed()
+ {
+ $this->ldap_read->expects($this->exactly(1))
+ ->method('schema')
+ ->will($this->returnValue(new PEAR_Error('Schema failed!')));
+ try {
+ $this->server->getSchema();
+ $this->fail('No exception!');
+ } catch (Exception $e) {
+ $this->assertEquals('Schema failed!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodGetparentguidHasResultStringParentGuid()
+ {
+ $this->assertEquals(
+ 'cn=parent', $this->server->getParentGuid('cn=child,cn=parent')
+ );
+ }
+
+/* public function testMethodSearchReturnsArrayMappedSearchResultIfMappingIsActivated() */
+/* { */
+/* $ldap = $this->getMock('Net_LDAP2', array('search')); */
+/* $ldap->expects($this->exactly(1)) */
+/* ->method('search') */
+/* ->will($this->returnValue(new Search_Mock(array(array('dn2' => 'test'))))); */
+/* $this->server->setLdap($ldap); */
+/* $this->server->setParams(array('map' => array('dn' => 'dn2'))); */
+/* $this->assertEquals( */
+/* array(array('dn' => 'test')), */
+/* $this->server->search( */
+/* 'filter', */
+/* array('attributes' => array('dn')) */
+/* ) */
+/* ); */
+/* } */
+
+}
--- /dev/null
+<?php
+/**
+ * Test the log 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 log 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_LoggedTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->logger = $this->getMock('Horde_Log_Logger');
+ $this->server = $this->getMock('Horde_Kolab_Server');
+ $this->logged = new Horde_Kolab_Server_Logged(
+ $this->server, $this->logger
+ );
+ }
+
+ public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('base', $this->logged->getBaseGuid());
+ }
+
+ public function testMethodGetuidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getGuid')
+ ->will($this->returnValue('guid'));
+ $this->assertEquals('guid', $this->logged->getGuid());
+ }
+
+ public function testMethodConnectguidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('connectGuid')
+ ->with('user', 'pass');
+ $this->logged->connectGuid('user', 'pass');
+ }
+
+ public function testMethodReadHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array()));
+ $this->assertEquals(array(), $this->logged->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->logged->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->logged->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->logged->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->logged->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->logged->add($object, array('a' => 'a'));
+ }
+
+ public function testMethodDeleteHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('delete')
+ ->with('a');
+ $this->logged->delete('a');
+ }
+
+ public function testMethodRenameHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('rename')
+ ->with('a', 'b');
+ $this->logged->rename('a', 'b');
+ }
+
+ public function testMethodGetschemaHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getSchema');
+ $this->logged->getSchema();
+ }
+
+ public function testMethodSaveHasPostconditionThatTheEventWasLogged()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $object->expects($this->once())
+ ->method('getGuid')
+ ->will($this->returnValue('a'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info', array('The object "a" has been successfully saved!')
+ );
+ $this->logged->save($object, array('a' => 'a'));
+ }
+
+ public function testMethodAddHasPostconditionThatTheEventWasLogged()
+ {
+ $object = $this->getMock(
+ 'Horde_Kolab_Server_Object', array(), array(), '', false
+ );
+ $object->expects($this->once())
+ ->method('getGuid')
+ ->will($this->returnValue('a'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info', array('The object "a" has been successfully added!')
+ );
+ $this->logged->add($object, array('a' => 'a'));
+ }
+
+ public function testMethodDeleteHasPostconditionThatTheEventWasLogged()
+ {
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info', array('The object "a" has been successfully deleted!')
+ );
+ $this->logged->delete('a');
+ }
+
+ public function testMethodRenameHasPostconditionThatTheEventWasLogged()
+ {
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info',
+ array('The object "a" has been successfully renamed to "b"!')
+ );
+ $this->logged->rename('a', 'b');
+ }
+
+ public function testMethodGetparentguidHasPostconditionThatTheCallWasDelegatedToTheServer()
+ {
+ $this->server->expects($this->exactly(1))
+ ->method('getParentGuid')
+ ->will($this->returnValue('parent'));
+ $this->assertEquals('parent', $this->logged->getParentGuid('child'));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the LDAP result 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 result 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_Result_LdapTest extends Horde_Kolab_Server_LdapTestCase
+{
+ public function testMethodConstructHasParameterNetldap2searchSearchResult()
+ {
+ $search = $this->getMock(
+ 'Net_LDAP2_Search', array(), array(), '', false
+ );
+ $result = new Horde_Kolab_Server_Result_Ldap($search);
+ }
+
+
+ public function testMethodCountHasResultIntTheNumberOfElementsFound()
+ {
+ $search = $this->getMock(
+ 'Net_LDAP2_Search', array('count'), array(), '', false
+ );
+ $search->expects($this->exactly(1))
+ ->method('count')
+ ->will($this->returnValue(1));
+ $result = new Horde_Kolab_Server_Result_Ldap($search);
+ $this->assertEquals(1, $result->count());
+ }
+
+ public function testMethodSizelimitexceededHasResultBooleanIndicatingIfTheSearchSizeLimitWasHit()
+ {
+ $search = $this->getMock(
+ 'Net_LDAP2_Search', array('sizeLimitExceeded'), array(), '', false
+ );
+ $search->expects($this->exactly(1))
+ ->method('sizeLimitExceeded')
+ ->will($this->returnValue(true));
+ $result = new Horde_Kolab_Server_Result_Ldap($search);
+ $this->assertTrue($result->sizeLimitExceeded());
+ }
+
+ public function testMethodAsarrayHasResultArrayWithTheSearchResults()
+ {
+ $search = $this->getMock(
+ 'Net_LDAP2_Search', array('as_struct'), array(), '', false
+ );
+ $search->expects($this->exactly(1))
+ ->method('as_struct')
+ ->will($this->returnValue(array('a' => 'a')));
+ $result = new Horde_Kolab_Server_Result_Ldap($search);
+ $this->assertEquals(array('a' => 'a'), $result->asArray());
+ }
+}
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Search')));
+ ->will($this->returnValue(array('Object_Dummy')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
$this->assertEquals(
- array('call' => array('class' => 'Object_Search')),
+ array(
+ 'call' => array('class' => 'Object_Search'),
+ 'reset' => array('class' => 'Object_Search')
+ ),
$search->getSearchOperations()
);
}
- public function testSetcompositeThrowsExceptionIfADeclaredSearchOperationDoesNotExist()
+ public function testSetcompositeThrowsExceptionIfADeclaredSearchClassDoesNotExist()
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
try {
$search->setComposite($composite);
} catch (Horde_Kolab_Server_Exception $e) {
- $this->assertContains(
- 'Class "Object_Search_Fail" does not support method "call"!',
+ $this->assertEquals(
+ 'Object_Search_Fail::getSearchOperations specified non-existing class "Does_Not_Exist"!',
$e->getMessage()
);
}
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Search')));
+ ->will($this->returnValue(array('Object_Dummy')));
$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_Search')));
+ ->will($this->returnValue(array('Object_Dummy')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
- $search->call();
- $call = Object_Search::$last_call;
- $this->assertType('Horde_Kolab_Server_Composite', $call[0]);
+ $search->call('a');
+ $this->assertEquals(array('a'), Object_Search::$last_call);
}
public function testCallThrowsExceptionIfTheSearchOperationIsNotSupported()
$composite = $this->getMockedComposite();
$composite->structure->expects($this->once())
->method('getSupportedObjects')
- ->will($this->returnValue(array('Object_Search')));
+ ->will($this->returnValue(array('Object_Dummy')));
$search = new Horde_Kolab_Server_Search_Base();
$search->setComposite($composite);
try {
}
}
+class Object_Dummy
+{
+ static public function getSearchOperations()
+ {
+ return array('Object_Search');
+ }
+}
+
class Object_Search
{
static public $calls = 0;
static public $last_call;
- static public function getSearchOperations()
- {
- return array('call');
- }
-
static public function call()
{
self::$last_call = func_get_args();
{
static public function getSearchOperations()
{
- return array('call');
+ return array('Does_Not_Exist');
}
}
--- /dev/null
+<?php
+/**
+ * Test the LDAP 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__) . '/../../../Autoload.php';
+
+/**
+ * Test the LDAP backend.
+ *
+ * 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_Structure_KolabTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $server = $this->getMock('Horde_Kolab_Server');
+ $this->composite = new Horde_Kolab_Server_Composite(
+ $server,
+ $this->getMock('Horde_Kolab_Server_Objects'),
+ new Horde_Kolab_Server_Structure_Kolab(),
+ $this->getMock('Horde_Kolab_Server_Search'),
+ $this->getMock('Horde_Kolab_Server_Schema')
+ );
+ }
+
+ public function testMethodGetsupportedobjectsHasResultArrayTheObjectTypesSupportedByThisStructure()
+ {
+ $this->assertType('array', $this->composite->structure->getSupportedObjects());
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid1()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('kolabGroupOfNames'))));
+ $this->assertEquals('Horde_Kolab_Server_Object_Kolabgroupofnames', $this->composite->structure->determineType('guid'));
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid2()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('kolabExternalPop3Account'))));
+ $this->assertEquals('Horde_Kolab_Server_Object_Kolabpop3account', $this->composite->structure->determineType('guid'));
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid3()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('kolabSharedFolder'))));
+ $this->assertEquals('Horde_Kolab_Server_Object_Kolabsharedfolder', $this->composite->structure->determineType('guid'));
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid4()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('top'))));
+ $this->assertEquals('Horde_Kolab_Server_Object_Top', $this->composite->structure->determineType('guid'));
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid5()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ array(
+ 'kolabinetorgperson',
+ )
+ )
+ )
+ );
+ $this->composite->search->expects($this->exactly(1))
+ ->method('__call')
+ ->with('getGroups', array('guid'))
+ ->will(
+ $this->returnValue(
+ array(
+ )
+ )
+ );
+ $this->assertEquals(
+ 'Horde_Kolab_Server_Object_Kolab_User',
+ $this->composite->structure->determineType('guid')
+ );
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid6()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ array(
+ 'kolabinetorgperson',
+ )
+ )
+ )
+ );
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->composite->search->expects($this->exactly(1))
+ ->method('__call')
+ ->with('getGroups', array('guid'))
+ ->will(
+ $this->returnValue(
+ array(
+ 'cn=admin,cn=internal,base'
+ )
+ )
+ );
+ $this->assertEquals(
+ 'Horde_Kolab_Server_Object_Kolab_Administrator',
+ $this->composite->structure->determineType('guid')
+ );
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid7()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ array(
+ 'kolabinetorgperson',
+ )
+ )
+ )
+ );
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->composite->search->expects($this->exactly(1))
+ ->method('__call')
+ ->with('getGroups', array('guid'))
+ ->will(
+ $this->returnValue(
+ array(
+ 'cn=maintainer,cn=internal,base'
+ )
+ )
+ );
+ $this->assertEquals(
+ 'Horde_Kolab_Server_Object_Kolab_Maintainer',
+ $this->composite->structure->determineType('guid')
+ );
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid8()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ array(
+ 'kolabinetorgperson',
+ )
+ )
+ )
+ );
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->composite->search->expects($this->exactly(1))
+ ->method('__call')
+ ->with('getGroups', array('guid'))
+ ->will(
+ $this->returnValue(
+ array(
+ 'cn=domain-maintainer,cn=internal,base'
+ )
+ )
+ );
+ $this->assertEquals(
+ 'Horde_Kolab_Server_Object_Kolab_Domainmaintainer',
+ $this->composite->structure->determineType('guid')
+ );
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid9()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid,cn=external')
+ ->will(
+ $this->returnValue(
+ array(
+ 'objectClass' =>
+ array(
+ 'kolabinetorgperson',
+ )
+ )
+ )
+ );
+ $this->composite->search->expects($this->exactly(1))
+ ->method('__call')
+ ->with('getGroups', array('guid,cn=external'))
+ ->will(
+ $this->returnValue(
+ array(
+ 'unknown'
+ )
+ )
+ );
+ $this->assertEquals(
+ 'Horde_Kolab_Server_Object_Kolab_Address',
+ $this->composite->structure->determineType('guid,cn=external')
+ );
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid1()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolabgroupofnames', 'id', array()));
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid2()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('id,cn=internal,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolabgroupofnames', 'id', array('visible' => false)));
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid3()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolabsharedfolder', 'id', array('visible' => false)));
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid4()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('id,cn=external,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolab_Address', 'id', array()));
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid5()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals(
+ 'id,cn=internal,base',
+ $this->composite->structure->generateServerGuid(
+ 'Horde_Kolab_Server_Object_Kolab_User', 'id',
+ array('user_type' => Horde_Kolab_Server_Object_Kolab_User::USERTYPE_INTERNAL)
+ )
+ );
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid6()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals(
+ 'id,cn=groups,base',
+ $this->composite->structure->generateServerGuid(
+ 'Horde_Kolab_Server_Object_Kolab_User', 'id',
+ array('user_type' => Horde_Kolab_Server_Object_Kolab_User::USERTYPE_GROUP)
+ )
+ );
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid7()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals(
+ 'id,cn=resources,base',
+ $this->composite->structure->generateServerGuid(
+ 'Horde_Kolab_Server_Object_Kolab_User', 'id',
+ array('user_type' => Horde_Kolab_Server_Object_Kolab_User::USERTYPE_RESOURCE)
+ )
+ );
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid8()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolab_User', 'id', array()));
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid9()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals(
+ 'id,base',
+ $this->composite->structure->generateServerGuid(
+ 'Horde_Kolab_Server_Object_Kolab_User', 'id',
+ array('user_type' => 'undefined')
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Test the LDAP 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__) . '/../../../Autoload.php';
+
+/**
+ * Test the LDAP backend.
+ *
+ * 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_Structure_LdapTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $server = $this->getMock('Horde_Kolab_Server');
+ $this->composite = new Horde_Kolab_Server_Composite(
+ $server,
+ $this->getMock('Horde_Kolab_Server_Objects'),
+ new Horde_Kolab_Server_Structure_Ldap(),
+ $this->getMock('Horde_Kolab_Server_Search'),
+ $this->getMock('Horde_Kolab_Server_Schema')
+ );
+ }
+
+ public function testMethodFindHasResultServerResultTheSearchResult()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result');
+ $this->composite->server->expects($this->exactly(1))
+ ->method('find')
+ ->with('(objectClass=equals)', array())
+ ->will($this->returnValue($result));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('Objectclass', 'equals');
+ $this->assertType(
+ 'Horde_Kolab_Server_Result',
+ $this->composite->structure->find($equals, array())
+ );
+ }
+
+ public function testMethodFindBelowHasResultServerResultTheSearchResult()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result');
+ $this->composite->server->expects($this->exactly(1))
+ ->method('findBelow')
+ ->with('(objectClass=equals)', 'base', array())
+ ->will($this->returnValue($result));
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('Objectclass', 'equals');
+ $this->assertType(
+ 'Horde_Kolab_Server_Result',
+ $this->composite->structure->findBelow($equals, 'base', array())
+ );
+ }
+
+ public function testMethodGetsupportedobjectsHasResultArrayTheObjectTypesSupportedByThisStructure()
+ {
+ $this->assertEquals(array('Horde_Kolab_Server_Object'), $this->composite->structure->getSupportedObjects());
+ }
+
+ public function testMethodDeterminetypeHasParameterStringGuid()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('TOP'))));
+ $this->composite->structure->determineType('guid');
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('TOP'))));
+ $this->assertEquals('Horde_Kolab_Server_Object_Top', $this->composite->structure->determineType('guid'));
+ }
+
+ public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid2()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('person'))));
+ $this->assertEquals('Horde_Kolab_Server_Object_Person', $this->composite->structure->determineType('guid'));
+ }
+
+ public function testMethodDeterminetypeThrowsExceptionIfTheGuidHasNoAttributeObjectclass()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array()));
+ try {
+ $this->composite->structure->determineType('guid');
+ } catch (Exception $e) {
+ $this->assertEquals('The object guid has no objectClass attribute!', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodDeterminetypeThrowsExceptionIfTheTypeIsUnknown()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('read')
+ ->with('guid')
+ ->will($this->returnValue(array('objectClass' => array('UNKNOWN'))));
+ try {
+ $this->composite->structure->determineType('guid');
+ } catch (Exception $e) {
+ $this->assertEquals('Unknown object type for GUID guid.', $e->getMessage());
+ $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
+ }
+ }
+
+ public function testMethodGenerateserverguidHasParameterStringType()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->composite->structure->generateServerGuid('type', '', array());
+ }
+
+ public function testMethodGenerateserverguidHasParameterStringId()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->composite->structure->generateServerGuid('', 'id', array());
+ }
+
+ public function testMethodGenerateserverguidHasParameterArrayObjectData()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->composite->structure->generateServerGuid('', '', array('object' => 'data'));
+ }
+
+ public function testMethodGenerateserverguidHasResultStringTheGuid()
+ {
+ $this->composite->server->expects($this->exactly(1))
+ ->method('getBaseGuid')
+ ->will($this->returnValue('base'));
+ $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('', 'id', array()));
+ }
+
+ public function testMethodGetinternalattributeThrowsExceptionForUndefinedAttributeName()
+ {
+ $structure = new Horde_Kolab_Server_Structure_Ldap();
+ try {
+ $structure->getInternalAttribute('undefined');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals(
+ 'Undefined internal attribute "undefined"',
+ $e->getMessage()
+ );
+ }
+ }
+}
/**
* Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../LdapBase.php';
+require_once dirname(__FILE__) . '/../LdapTestCase.php';
/**
* Test the test backend.
* @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_LdapBase
+class Horde_Kolab_Server_Connection_MockTest
+extends Horde_Kolab_Server_LdapTestCase
{
/**
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../Autoload.php';
+require_once dirname(__FILE__) . '/../LdapTestCase.php';
/**
* Test the handler for a simple LDAP setup without read-only slaves.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.
* @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 PHPUnit_Framework_TestCase
+class Horde_Kolab_Server_Connection_SimpleldapTest
+extends Horde_Kolab_Server_LdapTestCase
{
- public function setUp()
- {
- if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
- $this->markTestSuiteSkipped('Ldap extension is missing!');
- };
-
- if (!class_exists('Net_LDAP2')) {
- $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
- }
- }
-
public function testMethodConstructHasParameterNetldap2Connection()
{
$ldap = $this->getMock('Net_LDAP2');
*/
/**
- * Prepare the test setup.
+ * Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../Autoload.php';
+require_once dirname(__FILE__) . '/../LdapTestCase.php';
/**
* Test the handler for a LDAP master/slave setup.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.
* @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 PHPUnit_Framework_TestCase
+class Horde_Kolab_Server_Connection_SplittedldapTest
+extends Horde_Kolab_Server_LdapTestCase
{
- public function setUp()
- {
- if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
- $this->markTestSuiteSkipped('Ldap extension is missing!');
- };
-
- if (!class_exists('Net_LDAP2')) {
- $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
- }
- }
-
public function testMethodConstructHasParameterNetldap2ReadConnectionAndParameterNetldap2WriteConnection()
{
$ldap_read = $this->getMock('Net_LDAP2');
--- /dev/null
+<?php
+/**
+ * Test the search 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 search handler.
+ *
+ * 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_SearchTest
+extends Horde_Kolab_Server_LdapTestCase
+{
+ public function setUp()
+ {
+
+/* $injector = new Horde_Injector(new Horde_Injector_TopLevel()); */
+/* Horde_Kolab_Server_Factory::setup(array(), $injector); */
+/* $this->server = $injector->getInstance('Horde_Kolab_Server'); */
+ }
+
+ public function testNothing()
+ {
+ }
+
+ /**
+ * Test retrieving a primary mail for a mail or uid.
+ *
+ * @return NULL
+ */
+/* public function testMailForUidOrMail() */
+/* { */
+/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('getAttributes', */
+/* 'search', 'count', */
+/* 'firstEntry')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_getAttributes') */
+/* ->will($this->returnValue(array ( */
+/* 'mail' => */
+/* array ( */
+/* 'count' => 1, */
+/* 0 => 'wrobel@example.org', */
+/* ), */
+/* 0 => 'mail', */
+/* 'count' => 1))); */
+/* $ldap->expects($this->any()) */
+/* ->method('_search') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_count') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_firstEntry') */
+/* ->will($this->returnValue(1)); */
+
+/* $mail = $ldap->mailForIdOrMail('wrobel'); */
+/* $this->assertEquals('wrobel@example.org', $mail); */
+
+/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getAttributes', */
+/* '_search', */
+/* '_count', */
+/* '_firstEntry', */
+/* '_errno', */
+/* '_error')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_getAttributes') */
+/* ->will($this->returnValue(false)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_search') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_count') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_firstEntry') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_errno') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_error') */
+/* ->will($this->returnValue('cn=DOES NOT EXIST,dc=example,dc=org: No such object')); */
+
+/* $mail = $ldap->mailForIdOrMail('wrobel'); */
+/* $this->assertEquals('Retrieving attributes failed. Error was: cn=DOES NOT EXIST,dc=example,dc=org: No such object', */
+/* $mail->message); */
+
+/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getAttributes', */
+/* '_search', */
+/* '_count')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_getAttributes') */
+/* ->will($this->returnValue(false)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_search') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_count') */
+/* ->will($this->returnValue(4)); */
+
+/* $mail = $ldap->mailForIdOrMail('wrobel'); */
+/* $this->assertEquals('Found 4 results when expecting only one!', */
+/* $mail->message); */
+/* } */
+
+/* /\** */
+/* * Test retrieving a DN for a mail or uid. */
+/* * */
+/* * @return NULL */
+/* *\/ */
+/* public function testDnForUidOrMail() */
+/* { */
+/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getDn', */
+/* '_search', '_count', */
+/* '_firstEntry')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_getDn') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_search') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_count') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_firstEntry') */
+/* ->will($this->returnValue(1)); */
+
+/* $dn = $ldap->uidForIdOrMail('wrobel'); */
+/* $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $dn); */
+
+/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getDn', */
+/* '_search', */
+/* '_count', */
+/* '_firstEntry', */
+/* '_errno', */
+/* '_error')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_getDn') */
+/* ->will($this->returnValue(false)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_search') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_count') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_firstEntry') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_errno') */
+/* ->will($this->returnValue(1)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_error') */
+/* ->will($this->returnValue('cn=DOES NOT EXIST,dc=example,dc=org: No such object')); */
+
+/* $dn = $ldap->uidForIdOrMail('wrobel'); */
+/* $this->assertEquals('Retrieving DN failed. Error was: cn=DOES NOT EXIST,dc=example,dc=org: No such object', */
+/* $dn->message); */
+
+/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getDn', */
+/* '_search', */
+/* '_count')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_getDn') */
+/* ->will($this->returnValue(false)); */
+/* $ldap->expects($this->any()) */
+/* ->method('_search') */
+/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
+/* $ldap->expects($this->any()) */
+/* ->method('_count') */
+/* ->will($this->returnValue(4)); */
+
+/* $dn = $ldap->uidForIdOrMail('wrobel'); */
+/* $this->assertEquals('Found 4 results when expecting only one!', */
+/* $dn->message); */
+/* } */
+
+}
+
+
+class Search_Mock
+{
+ public function __construct($result, $limit = false)
+ {
+ $this->result = $result;
+ $this->limit = $limit;
+ }
+ public function as_struct()
+ {
+ return $this->result;
+ }
+ public function sizeLimitExceeded()
+ {
+ return $this->limit;
+ }
+}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Skip LDAP based tests if we don't have ldap or Net_LDAP2.
- *
- * 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';
-
-/**
- * Skip LDAP based tests if we don't have ldap or Net_LDAP2.
- *
- * 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_LdapBase extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
- $this->markTestSuiteSkipped('Ldap extension is missing!');
- };
-
- /** Hide strict errors from the Net_LDAP2 library */
- $error_reporting = error_reporting();
- error_reporting($error_reporting & ~E_STRICT);
-
- if (!class_exists('Net_LDAP2')) {
- $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
- }
-
- /** Reactivate original error reporting */
- error_reporting($error_reporting);
- }
-}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Skip LDAP based tests if we don't have ldap or Net_LDAP2.
+ *
+ * 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';
+
+/**
+ * Skip LDAP based tests if we don't have ldap or Net_LDAP2.
+ *
+ * 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_LdapTestCase extends Horde_Kolab_Server_TestCase
+{
+ public function setUp()
+ {
+ if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
+ $this->markTestSuiteSkipped('Ldap extension is missing!');
+ };
+
+ /** Hide strict errors from the Net_LDAP2 library */
+ $error_reporting = error_reporting();
+ error_reporting($error_reporting & ~E_STRICT);
+
+ if (!class_exists('Net_LDAP2')) {
+ $this->markTestSkipped('PEAR package Net_LDAP2 is not installed!');
+ }
+
+ /** Reactivate original error reporting */
+ error_reporting($error_reporting);
+ }
+}
\ No newline at end of file
/**
* Prepare the test setup.
*/
-require_once dirname(__FILE__) . '/../Autoload.php';
+require_once dirname(__FILE__) . '/../TestCase.php';
/**
* Test the base object.
* @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 PHPUnit_Framework_TestCase
+class Horde_Kolab_Server_Object_BaseTest extends Horde_Kolab_Server_TestCase
{
public function setUp()
{
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'))
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'))
$object = new Object_Mock($composite);
$object->save(array('Objectclass' => 'top'));
}
-
- private function getComposite()
- {
- return $this->getMock(
- 'Horde_Kolab_Server_Composite', array(), array(), '', false
- );
- }
-
- private function getMockedComposite()
- {
- return new Horde_Kolab_Server_Composite(
- $this->getMock(
- 'Horde_Kolab_Server', array(), array(), '', false
- ),
- $this->getMock(
- 'Horde_Kolab_Server_Objects', array(), array(), '', false
- ),
- $this->getMock(
- 'Horde_Kolab_Server_Structure', array(), array(), '', false
- ),
- $this->getMock(
- 'Horde_Kolab_Server_Search', array(), array(), '', false
- ),
- $this->getMock(
- 'Horde_Kolab_Server_Schema', array(), array(), '', false
- )
- );
- }
}
class Object_Mock extends Horde_Kolab_Server_Object_Base
/**
* Test the LDAP query elements.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.
/**
* Require our basic test case definition
*/
-require_once dirname(__FILE__) . '/../LdapBase.php';
+require_once dirname(__FILE__) . '/../LdapTestCase.php';
/**
* Test the LDAP query handler.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.
* @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_LdapBase
+class Horde_Kolab_Server_Query_LdapTest extends Horde_Kolab_Server_LdapTestCase
{
+ public function setUp()
+ {
+ parent::setUp();
+ $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);
+ $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);
+ $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);
+ $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
$this->assertEquals(
- '(|(equals=equals)(contains=contains))',
+ '(|(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);
+ $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);
+ $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);
+ $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);
+ $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);
+ $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);
+ $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);
+ $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);
- $query = new Horde_Kolab_Server_Query_Ldap($not);
+ $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);
+ $query = new Horde_Kolab_Server_Query_Ldap($and, $this->structure);
$this->assertEquals(
- '(&(equals=equals)(contains=contains))',
+ '(&(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);
+ $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
$this->assertEquals(
- '(|(equals=equals)(contains=contains))',
+ '(|(internal=equals)(internal=contains))',
$query->convertOr($or)->asString()
);
}
{
$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);
+ $query = new Horde_Kolab_Server_Query_Ldap($or, $this->structure);
/** Hide strict errors from the Net_LDAP2 library */
$error_reporting = error_reporting();
+++ /dev/null
-<?php
-/**
- * Test the LDAP result 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__) . '/../LdapBase.php';
-
-/**
- * Test the LDAP result handler.
- *
- * 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_Result_LdapTest extends Horde_Kolab_Server_LdapBase
-{
- public function testMethodConstructHasParameterNetldap2searchSearchResult()
- {
- $search = $this->getMock(
- 'Net_LDAP2_Search', array(), array(), '', false
- );
- $result = new Horde_Kolab_Server_Result_Ldap($search);
- }
-
-
- public function testMethodCountHasResultIntTheNumberOfElementsFound()
- {
- $search = $this->getMock(
- 'Net_LDAP2_Search', array('count'), array(), '', false
- );
- $search->expects($this->exactly(1))
- ->method('count')
- ->will($this->returnValue(1));
- $result = new Horde_Kolab_Server_Result_Ldap($search);
- $this->assertEquals(1, $result->count());
- }
-
- public function testMethodSizelimitexceededHasResultBooleanIndicatingIfTheSearchSizeLimitWasHit()
- {
- $search = $this->getMock(
- 'Net_LDAP2_Search', array('sizeLimitExceeded'), array(), '', false
- );
- $search->expects($this->exactly(1))
- ->method('sizeLimitExceeded')
- ->will($this->returnValue(true));
- $result = new Horde_Kolab_Server_Result_Ldap($search);
- $this->assertTrue($result->sizeLimitExceeded());
- }
-
- public function testMethodAsarrayHasResultArrayWithTheSearchResults()
- {
- $search = $this->getMock(
- 'Net_LDAP2_Search', array('as_struct'), array(), '', false
- );
- $search->expects($this->exactly(1))
- ->method('as_struct')
- ->will($this->returnValue(array('a' => 'a')));
- $result = new Horde_Kolab_Server_Result_Ldap($search);
- $this->assertEquals(array('a' => 'a'), $result->asArray());
- }
-}
+++ /dev/null
-<?php
-/**
- * Test the search handler 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
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the search handler.
- *
- * 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_SearchTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
- $this->markTestSuiteSkipped('Ldap extension is missing!');
- };
-
- if (!class_exists('Net_LDAP2')) {
- $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
- }
-
- $this->markTestIncomplete('Needs to be fixed');
-
-/* $injector = new Horde_Injector(new Horde_Injector_TopLevel()); */
-/* Horde_Kolab_Server_Factory::setup(array(), $injector); */
-/* $this->server = $injector->getInstance('Horde_Kolab_Server'); */
- }
-
- public function testNothing()
- {
- }
-
- /**
- * Test retrieving a primary mail for a mail or uid.
- *
- * @return NULL
- */
-/* public function testMailForUidOrMail() */
-/* { */
-/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('getAttributes', */
-/* 'search', 'count', */
-/* 'firstEntry')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_getAttributes') */
-/* ->will($this->returnValue(array ( */
-/* 'mail' => */
-/* array ( */
-/* 'count' => 1, */
-/* 0 => 'wrobel@example.org', */
-/* ), */
-/* 0 => 'mail', */
-/* 'count' => 1))); */
-/* $ldap->expects($this->any()) */
-/* ->method('_search') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_count') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_firstEntry') */
-/* ->will($this->returnValue(1)); */
-
-/* $mail = $ldap->mailForIdOrMail('wrobel'); */
-/* $this->assertEquals('wrobel@example.org', $mail); */
-
-/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getAttributes', */
-/* '_search', */
-/* '_count', */
-/* '_firstEntry', */
-/* '_errno', */
-/* '_error')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_getAttributes') */
-/* ->will($this->returnValue(false)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_search') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_count') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_firstEntry') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_errno') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_error') */
-/* ->will($this->returnValue('cn=DOES NOT EXIST,dc=example,dc=org: No such object')); */
-
-/* $mail = $ldap->mailForIdOrMail('wrobel'); */
-/* $this->assertEquals('Retrieving attributes failed. Error was: cn=DOES NOT EXIST,dc=example,dc=org: No such object', */
-/* $mail->message); */
-
-/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getAttributes', */
-/* '_search', */
-/* '_count')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_getAttributes') */
-/* ->will($this->returnValue(false)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_search') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_count') */
-/* ->will($this->returnValue(4)); */
-
-/* $mail = $ldap->mailForIdOrMail('wrobel'); */
-/* $this->assertEquals('Found 4 results when expecting only one!', */
-/* $mail->message); */
-/* } */
-
-/* /\** */
-/* * Test retrieving a DN for a mail or uid. */
-/* * */
-/* * @return NULL */
-/* *\/ */
-/* public function testDnForUidOrMail() */
-/* { */
-/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getDn', */
-/* '_search', '_count', */
-/* '_firstEntry')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_getDn') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_search') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_count') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_firstEntry') */
-/* ->will($this->returnValue(1)); */
-
-/* $dn = $ldap->uidForIdOrMail('wrobel'); */
-/* $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $dn); */
-
-/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getDn', */
-/* '_search', */
-/* '_count', */
-/* '_firstEntry', */
-/* '_errno', */
-/* '_error')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_getDn') */
-/* ->will($this->returnValue(false)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_search') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_count') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_firstEntry') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_errno') */
-/* ->will($this->returnValue(1)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_error') */
-/* ->will($this->returnValue('cn=DOES NOT EXIST,dc=example,dc=org: No such object')); */
-
-/* $dn = $ldap->uidForIdOrMail('wrobel'); */
-/* $this->assertEquals('Retrieving DN failed. Error was: cn=DOES NOT EXIST,dc=example,dc=org: No such object', */
-/* $dn->message); */
-
-/* $ldap = $this->getMock('Horde_Kolab_Server_ldap', array('_getDn', */
-/* '_search', */
-/* '_count')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_getDn') */
-/* ->will($this->returnValue(false)); */
-/* $ldap->expects($this->any()) */
-/* ->method('_search') */
-/* ->will($this->returnValue('cn=Gunnar Wrobel,dc=example,dc=org')); */
-/* $ldap->expects($this->any()) */
-/* ->method('_count') */
-/* ->will($this->returnValue(4)); */
-
-/* $dn = $ldap->uidForIdOrMail('wrobel'); */
-/* $this->assertEquals('Found 4 results when expecting only one!', */
-/* $dn->message); */
-/* } */
-
-}
-
-
-class Search_Mock
-{
- public function __construct($result, $limit = false)
- {
- $this->result = $result;
- $this->limit = $limit;
- }
- public function as_struct()
- {
- return $this->result;
- }
- public function sizeLimitExceeded()
- {
- return $this->limit;
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the server factory interface.
- *
- * 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 server factory interface.
- *
- * 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_Server_FactoryTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->markTestIncomplete();
- $this->injector = new Horde_Injector(new Horde_Injector_TopLevel());
- }
-
- public function testMethodSetupHasPostconditionThatAObjectHandlerOfTypeBaseIsBoundToObjects()
- {
- Horde_Kolab_Server_Factory::setup($this->injector, array());
- $this->assertType(
- 'Horde_Kolab_Server_Objects_Base',
- $this->injector->getInstance('Horde_Kolab_Server_Objects')
- );
- }
-
- public function testMethodSetupHasPostconditionThatASchemaHandlerOfTypeBaseIsBoundToSchema()
- {
- Horde_Kolab_Server_Factory::setup($this->injector, array());
- $this->assertType(
- 'Horde_Kolab_Server_Schema_Base',
- $this->injector->getInstance('Horde_Kolab_Server_Schema')
- );
- }
-
- public function testMethodSetupHasPostconditionThatASearchHandlerOfTypeBaseIsBoundToSearch()
- {
- Horde_Kolab_Server_Factory::setup($this->injector, array());
- $this->assertType(
- 'Horde_Kolab_Server_Search_Base',
- $this->injector->getInstance('Horde_Kolab_Server_Search')
- );
- }
-
- public function testMethodSetupHasPostconditionThatAStructureOfTypeKolabIsBoundToStructure()
- {
- Horde_Kolab_Server_Factory::setup($this->injector, array());
- $this->assertType(
- 'Horde_Kolab_Server_Structure_Kolab',
- $this->injector->getInstance('Horde_Kolab_Server_Structure')
- );
- }
-
- public function testMethodSetupHasPostconditionThatAStructureHandlerOfTypeLdapIsBoundToStructureIfConfiguredThatWay()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array('structure' => array('driver' => 'ldap'))
- );
- $this->assertType(
- 'Horde_Kolab_Server_Structure_Ldap',
- $this->injector->getInstance('Horde_Kolab_Server_Structure')
- );
- }
-
- public function testMethodSetupHasPostconditionThatAServerOfTypeLdapIsBoundToServer()
- {
- Horde_Kolab_Server_Factory::setup($this->injector, array('basedn' => 'dc=example,dc=com'));
- $this->assertType(
- 'Horde_Kolab_Server_Ldap_Standard',
- $this->injector->getInstance('Horde_Kolab_Server')
- );
- }
-
- public function testMethodSetupHasPostconditionThatAServerOfTypeFileIsBoundToServerIfConfiguredThatWay()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array('driver' => 'file', 'params' => array('basedn' => '', 'file' => '/tmp/nix'))
- );
- $this->assertType(
- 'Horde_Kolab_Server_Ldap_Standard',
- $this->injector->getInstance('Horde_Kolab_Server')
- );
- }
-
- public function testMethodSetupHasPostconditionThatAServerOfTypeFilteredLdapIsBoundToServerIfAFilterHasBeenProvided()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array('basedn' => 'dc=example,dc=com', 'filter' => 'test')
- );
- $this->assertType(
- 'Horde_Kolab_Server_Ldap_Filtered',
- $this->injector->getInstance('Horde_Kolab_Server')
- );
- }
-
- public function testMethodSetupHasPostconditionThatAMappedServerIsBoundToServerIfAMapHasBeenProvided()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array(
- 'basedn' => 'dc=example,dc=com',
- 'map' => array('a' => 'b'),
- )
- );
- $this->assertType(
- 'Horde_Kolab_Server_Mapped',
- $this->injector->getInstance('Horde_Kolab_Server')
- );
- }
-
- public function testMethodSetupHasPostconditionThatALoggedServerIsBoundToServerIfALoggerHasBeenProvided()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array(
- 'basedn' => 'dc=example,dc=com',
- 'logger' => $this->getMock('Horde_Log_Logger'),
- )
- );
- $this->assertType(
- 'Horde_Kolab_Server_Logged',
- $this->injector->getInstance('Horde_Kolab_Server')
- );
- }
-
- public function testMethodGetserverHasPostconditionThatTheConnectionParametersGetRewrittenIfNecessary()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array(
- 'server' => 'localhost',
- 'phpdn' => 'a',
- 'phppw' => 'a',
- 'basedn' => 'dc=example,dc=com'
- )
- );
- $this->injector->getInstance('Horde_Kolab_Server');
- /**@todo: Actually not testable as we can't read the configuration again */
- }
-
- public function testMethodGetserverHasPostconditionThatTheConnectionIsSplittedIfRequired()
- {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array(
- 'host' => 'localhost',
- 'host_master' => 'writehost',
- 'basedn' => 'dc=example,dc=com'
- )
- );
- $this->injector->getInstance('Horde_Kolab_Server');
- /**@todo: Actually not testable as we can't read the configuration again */
- }
-
- public function testMethodGetserverThrowsExceptionIfTheBasednIsMissing()
- {
- try {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array('dummy')
- );
- $this->injector->getInstance('Horde_Kolab_Server');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals(
- 'The base DN is missing', $e->getMessage()
- );
- }
- }
-
- public function testMethodGetserverThrowsExceptionIfTheDriverIsUnknown()
- {
- try {
- Horde_Kolab_Server_Factory::setup(
- $this->injector,
- array('driver' => 'unknown')
- );
- $this->injector->getInstance('Horde_Kolab_Server');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals(
- 'Invalid server configuration!', $e->getMessage()
- );
- }
- }
-
- public function testMethodSingletonReturnsTheSameInstanceWithTheSameParameters()
- {
- $result1 = Horde_Kolab_Server_Factory::singleton(array('basedn' => 'dc=example,dc=com'));
- $result2 = Horde_Kolab_Server_Factory::singleton(array('basedn' => 'dc=example,dc=com'));
- $this->assertSame($result1, $result2);
- }
-
- public function testMethodSingletonReturnsDifferentInstancesWithDifferentParameters()
- {
- global $conf;
- $conf['kolab']['ldap']['basedn'] = 'test';
- $result1 = Horde_Kolab_Server_Factory::singleton(array('basedn' => 'dc=example,dc=com'));
- $result2 = Horde_Kolab_Server_Factory::singleton();
- $this->assertTrue($result1 !== $result2);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the filtered LDAP 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__) . '/../LdapBase.php';
-
-/**
- * Test the filtered LDAP driver.
- *
- * 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_Server_FilteredTest extends Horde_Kolab_Server_LdapBase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->ldap_read = $this->getMock('Net_LDAP2');
- $this->ldap_write = $this->getMock('Net_LDAP2');
- $connection = new Horde_Kolab_Server_Connection_Splittedldap(
- $this->ldap_read,
- $this->ldap_write
- );
-
- $this->server = new Horde_Kolab_Server_Ldap_Filtered(
- $connection,
- 'base',
- 'filter'
- );
- }
-
- private function getSearchResultMock()
- {
- $result = $this->getMock(
- 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
- );
- $result->expects($this->any())
- ->method('as_struct')
- ->will($this->returnValue(array(array('dn' => 'test'))));
- $result->expects($this->any())
- ->method('count')
- ->will($this->returnValue(1));
- return $result;
- }
-
- public function testMethodFindbelowHasParameterQueryelementTheSearchCriteria()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('', '(&(filter)(equals=equals))', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->findBelow($equals, '');
- }
-
- public function testMethodFindbelowHasParameterStringParent()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('parent', '(&(filter)(equals=equals))', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->findBelow($equals, 'parent', array());
- }
-
- public function testMethodFindbelowHasParameterArrayAdditionalParameters()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('', '(&(filter)(equals=equals))', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->findBelow($equals, '', array());
- }
-
- public function testMethodFindbelowReturnsArraySearchResult()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('parent', '(&(filter)(equals=equals))', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->assertEquals(
- array(array('dn' => 'test')),
- $this->server->findBelow($equals, 'parent')->asArray()
- );
- }
-
- public function testMethodFindbelowThrowsExceptionIfTheSearchFailed()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->will($this->returnValue(new PEAR_Error('Search failed!')));
- try {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->assertEquals(array('dn' => 'test'), $this->server->findBelow($equals, ''));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Search failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Test the LDAP 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__) . '/../LdapBase.php';
-
-/**
- * Test the LDAP 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_Server_LdapTest extends Horde_Kolab_Server_LdapBase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->ldap_read = $this->getMock('Net_LDAP2');
- $this->ldap_write = $this->getMock('Net_LDAP2');
- $connection = new Horde_Kolab_Server_Connection_Splittedldap(
- $this->ldap_read,
- $this->ldap_write
- );
-
- $this->server = new Horde_Kolab_Server_Ldap_Standard(
- $connection,
- 'base'
- );
- }
-
- private function getSearchResultMock()
- {
- $result = $this->getMock(
- 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
- );
- $result->expects($this->any())
- ->method('as_struct')
- ->will($this->returnValue(array(array('dn' => 'test'))));
- $result->expects($this->any())
- ->method('count')
- ->will($this->returnValue(1));
- return $result;
- }
-
- public function testMethodConnectguidHasStringParameterGuid()
- {
- $this->server->connectGuid('guid', '');
- }
-
- public function testMethodConnectguidHasStringParameterPass()
- {
- $this->server->connectGuid('', 'pass');
- }
-
- public function testMethodConnectguidHasPostconditionThatTheGuidIsSetIfTheConnectionWasSuccessful()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('bind')
- ->will($this->returnValue(true));
- $this->server->connectGuid('test', 'test');
- $this->assertEquals('test', $this->server->getGuid());
- }
-
- public function testMethodConnectguidDoesNotCallBindAgainIfAlreadyConnectedWithThisGuid()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('bind')
- ->will($this->returnValue(true));
- $this->server->connectGuid('test', 'test');
- $this->server->connectGuid('test', 'test');
- }
-
- public function testMethodConnectguidDoesNotCallBindAgainIfAlreadyConnectedWithThisGuidEvenIfTheGuidIsEmpty()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('bind')
- ->will($this->returnValue(true));
- $this->server->connectGuid('', '');
- $this->server->connectGuid('', '');
- }
-
- public function testMethodConnectguidThrowsExceptionIfTheConnectionFailed()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('bind')
- ->will($this->returnValue(new PEAR_Error('Bind failed!')));
- try {
- $this->server->connectGuid('test', 'test');
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Bind failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::BIND_FAILED, $e->getCode());
- }
- }
-
- public function testMethodGetguidHasResultBooleanFalseIfNotConnected()
- {
- $this->assertSame(false, $this->server->getGuid());
- }
-
- public function testMethodGetguidHasResultStringGuidIfNotConnected()
- {
- $this->server->connectGuid('guid', '');
- $this->assertEquals('guid', $this->server->getGuid());
- }
-
- public function testMethodReadHasParameterStringGuid()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('test', null, array('scope' => 'base'))
- ->will($this->returnValue($this->getSearchResultMock()));
- $this->server->read('test');
- }
-
- public function testMethodReadReturnsArrayReadResult()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('test', null, array('scope' => 'base'))
- ->will($this->returnValue($this->getSearchResultMock()));
- $this->assertEquals(array('dn' => 'test'), $this->server->read('test'));
- }
-
- public function testMethodReadThrowsExceptionIfTheObjectWasNotFound()
- {
- $result = $this->getMock(
- 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
- );
- $result->expects($this->exactly(1))
- ->method('count')
- ->will($this->returnValue(0));
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->will($this->returnValue($result));
- try {
- $this->assertEquals(array(), $this->server->read('test'));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Empty result!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::EMPTY_RESULT, $e->getCode());
- }
- }
-
- public function testMethodReadAttributesHasParameterStringGuid()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('guid', null, array('scope' => 'base', 'attributes' => array()))
- ->will($this->returnValue($this->getSearchResultMock()));
- $this->server->readAttributes('guid', array());
- }
-
- public function testMethodReadAttributesHasParameterArrayAttributes()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('', null, array('scope' => 'base', 'attributes' => array('a')))
- ->will($this->returnValue($this->getSearchResultMock()));
- $this->server->readAttributes('', array('a'));
- }
-
- public function testMethodReadAttributesReturnsArrayReadResult()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('test', null, array('scope' => 'base', 'attributes' => array('a')))
- ->will($this->returnValue($this->getSearchResultMock()));
- $this->assertEquals(array('dn' => 'test'), $this->server->readAttributes('test', array('a')));
- }
-
- public function testMethodReadAttributesThrowsExceptionIfTheObjectWasNotFound()
- {
- $result = $this->getMock(
- 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
- );
- $result->expects($this->exactly(1))
- ->method('count')
- ->will($this->returnValue(0));
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('test', null, array('scope' => 'base', 'attributes' => array('a')))
- ->will($this->returnValue($result));
- try {
- $this->assertEquals(array(), $this->server->readAttributes('test', array('a')));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Empty result!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::EMPTY_RESULT, $e->getCode());
- }
- }
-
- public function testMethodFindHasParameterQueryelementTheSearchCriteria()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('base', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->find($equals);
- }
-
- public function testMethodFindHasParameterArrayAdditionalParameters()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('base', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->find($equals, array());
- }
-
- public function testMethodFindReturnsArraySearchResult()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('base', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->assertEquals(
- array(array('dn' => 'test')),
- $this->server->find($equals)->asArray()
- );
- }
-
- public function testMethodFindThrowsExceptionIfTheSearchFailed()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->will($this->returnValue(new PEAR_Error('Search failed!')));
- try {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->assertEquals(array('dn' => 'test'), $this->server->find($equals));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Search failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodSaveHasParameterObjectTheObjectToModifyOnTheServer()
- {
- $entry = $this->getMock(
- 'Net_LDAP2_Entry', array(), array(), '', false
- );
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('getEntry')
- ->will($this->returnValue($entry));
- $this->ldap_write->expects($this->exactly(1))
- ->method('modify')
- ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
- $object->expects($this->exactly(1))
- ->method('readInternal')
- ->will($this->returnValue(array()));
- $this->server->save($object, array('attributes' => array('dn')));
- }
-
- public function testMethodSaveHasParameterArrayData()
- {
- $entry = $this->getMock(
- 'Net_LDAP2_Entry', array(), array(), '', false
- );
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('getEntry')
- ->will($this->returnValue($entry));
- $this->ldap_write->expects($this->exactly(1))
- ->method('modify')
- ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
- $object->expects($this->exactly(1))
- ->method('readInternal')
- ->will($this->returnValue(array()));
- $this->server->save($object, array('dn' => 'test'));
- }
-
- public function testMethodSaveHasPostconditionThatTheEntryWasModified()
- {
- $entry = $this->getMock(
- 'Net_LDAP2_Entry', array(), array(), '', false
- );
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('getEntry')
- ->will($this->returnValue($entry));
- $this->ldap_write->expects($this->exactly(1))
- ->method('modify')
- ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
- $object->expects($this->exactly(1))
- ->method('readInternal')
- ->will($this->returnValue(array()));
- $this->server->save($object, array('dn' => 'test'));
- }
-
- public function testMethodSaveThrowsExceptionIfSavingDataFailed()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('modify')
- ->will($this->returnValue(new PEAR_Error('Saving failed!')));
- $object->expects($this->exactly(1))
- ->method('readInternal')
- ->will($this->returnValue(array()));
- try {
- $this->server->save($object, array('dn' => 'test'));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Saving failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodAddHasParameterObjectTheObjectToAddToTheServer()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('add')
- ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
- $this->server->add($object, array('attributes' => array('dn')));
- }
-
- public function testMethodAddHasParameterArrayData()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('add')
- ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
- $this->server->add($object, array('dn' => 'test'));
- }
-
- public function testMethodAddHasPostconditionThatTheEntryWasModified()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('add')
- ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry'));
- $this->server->add($object, array('dn' => 'test'));
- }
-
- public function testMethodAddThrowsExceptionIfSavingDataFailed()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->ldap_write->expects($this->exactly(1))
- ->method('add')
- ->will($this->returnValue(new PEAR_Error('Saving failed!')));
- try {
- $this->server->add($object, array('add' => array('dn' => 'test')));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Saving failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodDeleteHasParameterStringGuid()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('delete')
- ->with('guid');
- $this->server->delete('guid');
- }
-
- public function testMethodDeleteHasPostconditionThatTheEntryWasDeleted()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('delete')
- ->with('test');
- $this->server->delete('test');
- }
-
- public function testMethodDeleteThrowsExceptionIfDeletingDataFailed()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('delete')
- ->will($this->returnValue(new PEAR_Error('Deleting failed!')));
- try {
- $this->server->delete('test');
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Deleting failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodRenameHasParameterStringOldGuid()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('move')
- ->with('oldguid', '');
- $this->server->rename('oldguid', '');
- }
-
- public function testMethodRenameHasParameterStringNewGuid()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('move')
- ->with('', 'newguid');
- $this->server->rename('', 'newguid');
- }
-
- public function testMethodRenameHasPostconditionThatTheEntryWasRenamed()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('move')
- ->with('test', 'new');
- $this->server->rename('test', 'new');
- }
-
- public function testMethodRenameThrowsExceptionIfRenamingDataFailed()
- {
- $this->ldap_write->expects($this->exactly(1))
- ->method('move')
- ->will($this->returnValue(new PEAR_Error('Renaming failed!')));
- try {
- $this->server->rename('test', 'new');
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Renaming failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodGetschemaReturnsArrayWithADescriptionOfAllObjectClasses()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('schema')
- ->will($this->returnValue(array('schema' => 'dummy')));
- $this->assertEquals(
- array('schema' => 'dummy'),
- $this->server->getSchema()
- );
- }
-
- public function testMethodGetschemaThrowsExceptionIfTheSchemaRetrievalFailed()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('schema')
- ->will($this->returnValue(new PEAR_Error('Schema failed!')));
- try {
- $this->server->getSchema();
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Schema failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
-/* public function testMethodSearchReturnsArrayMappedSearchResultIfMappingIsActivated() */
-/* { */
-/* $ldap = $this->getMock('Net_LDAP2', array('search')); */
-/* $ldap->expects($this->exactly(1)) */
-/* ->method('search') */
-/* ->will($this->returnValue(new Search_Mock(array(array('dn2' => 'test'))))); */
-/* $this->server->setLdap($ldap); */
-/* $this->server->setParams(array('map' => array('dn' => 'dn2'))); */
-/* $this->assertEquals( */
-/* array(array('dn' => 'test')), */
-/* $this->server->search( */
-/* 'filter', */
-/* array('attributes' => array('dn')) */
-/* ) */
-/* ); */
-/* } */
-
-}
+++ /dev/null
-<?php
-/**
- * Test the LDAP 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__) . '/../LdapBase.php';
-
-/**
- * Test the LDAP 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_Server_LoggedTest extends Horde_Kolab_Server_LdapBase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->logger = new Horde_Log_Handler_Mock();
- $this->server = $this->getMock('Horde_Kolab_Server');
- $this->logged = new Horde_Kolab_Server_Logged(
- $this->server,
- new Horde_Log_Logger($this->logger)
- );
- }
-
- public function testMethodConnectguidDelegatesToServer()
- {
- $this->server->expects($this->exactly(1))
- ->method('connectGuid')
- ->with('user', 'pass');
- $this->logged->connectGuid('user', 'pass');
- }
-
- public function testMethodReadDelegatesToServer()
- {
- $this->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid');
- $this->logged->read('guid');
- }
-
- public function testMethodReadattributesDelegatesToServer()
- {
- $this->server->expects($this->exactly(1))
- ->method('readAttributes')
- ->with('guid', array('a'));
- $this->logged->readAttributes('guid', array('a'));
- }
-
- public function testMethodFindDelegatesToServer()
- {
- $query = $this->getMock(
- 'Horde_Kolab_Server_Query_Element', array(), array(), '', false
- );
- $this->server->expects($this->exactly(1))
- ->method('find')
- ->with($query);
- $this->logged->find($query);
- }
-
- public function testMethodFindbelowDelegatesToServer()
- {
- $query = $this->getMock(
- 'Horde_Kolab_Server_Query_Element', array(), array(), '', false
- );
- $this->server->expects($this->exactly(1))
- ->method('findBelow')
- ->with($query, 'none');
- $this->logged->findBelow($query, 'none');
- }
-
- public function testMethodSaveDelegatesToServer()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->server->expects($this->exactly(1))
- ->method('save')
- ->with($object, array('a' => 'a'));
- $this->logged->save($object, array('a' => 'a'));
- }
-
- public function testMethodAddDelegatesToServer()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $this->server->expects($this->exactly(1))
- ->method('add')
- ->with($object, array('a' => 'a'));
- $this->logged->add($object, array('a' => 'a'));
- }
-
- public function testMethodDeleteDelegatesToServer()
- {
- $this->server->expects($this->exactly(1))
- ->method('delete')
- ->with('a');
- $this->logged->delete('a');
- }
-
- public function testMethodRenameDelegatesToServer()
- {
- $this->server->expects($this->exactly(1))
- ->method('rename')
- ->with('a', 'b');
- $this->logged->rename('a', 'b');
- }
-
- public function testMethodGetschemaDelegatesToServer()
- {
- $this->server->expects($this->exactly(1))
- ->method('getSchema');
- $this->logged->getSchema();
- }
-
- public function testMethodSaveHasPostconditionThatTheEventWasLogged()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $object->expects($this->once())
- ->method('getGuid')
- ->will($this->returnValue('a'));
- $this->logged->save($object, array('a' => 'a'));
- $this->assertEquals(
- $this->logger->events[0]['message'],
- 'The object "a" has been successfully saved!'
- );
- }
-
- public function testMethodAddHasPostconditionThatTheEventWasLogged()
- {
- $object = $this->getMock(
- 'Horde_Kolab_Server_Object', array(), array(), '', false
- );
- $object->expects($this->once())
- ->method('getGuid')
- ->will($this->returnValue('a'));
- $this->logged->add($object, array('a' => 'a'));
- $this->assertEquals(
- $this->logger->events[0]['message'],
- 'The object "a" has been successfully added!'
- );
- }
-
- public function testMethodDeleteHasPostconditionThatTheEventWasLogged()
- {
- $this->logged->delete('a');
- $this->assertEquals(
- $this->logger->events[0]['message'],
- 'The object "a" has been successfully deleted!'
- );
- }
-
- public function testMethodRenameHasPostconditionThatTheEventWasLogged()
- {
- $this->logged->rename('a', 'b');
- $this->assertEquals(
- $this->logger->events[0]['message'],
- 'The object "a" has been successfully renamed to "b"!'
- );
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the standard LDAP 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__) . '/../LdapBase.php';
-
-/**
- * Test the standard LDAP driver.
- *
- * 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_Server_StandardTest extends Horde_Kolab_Server_LdapBase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->ldap_read = $this->getMock('Net_LDAP2');
- $this->ldap_write = $this->getMock('Net_LDAP2');
- $connection = new Horde_Kolab_Server_Connection_Splittedldap(
- $this->ldap_read,
- $this->ldap_write
- );
-
- $this->server = new Horde_Kolab_Server_Ldap_Standard(
- $connection,
- 'base'
- );
- }
-
- private function getSearchResultMock()
- {
- $result = $this->getMock(
- 'Net_LDAP2_Search', array('as_struct', 'count'), array(), '', false
- );
- $result->expects($this->any())
- ->method('as_struct')
- ->will($this->returnValue(array(array('dn' => 'test'))));
- $result->expects($this->any())
- ->method('count')
- ->will($this->returnValue(1));
- return $result;
- }
-
- public function testMethodFindbelowHasParameterQueryelementTheSearchCriteria()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->findBelow($equals, '');
- }
-
- public function testMethodFindbelowHasParameterStringParent()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('parent', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->findBelow($equals, 'parent', array());
- }
-
- public function testMethodFindbelowHasParameterArrayAdditionalParameters()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->server->findBelow($equals, '', array());
- }
-
- public function testMethodFindbelowReturnsArraySearchResult()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->with('parent', '(equals=equals)', array())
- ->will($this->returnValue($this->getSearchResultMock()));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->assertEquals(
- array(array('dn' => 'test')),
- $this->server->findBelow($equals, 'parent')->asArray()
- );
- }
-
- public function testMethodFindbelowThrowsExceptionIfTheSearchFailed()
- {
- $this->ldap_read->expects($this->exactly(1))
- ->method('search')
- ->will($this->returnValue(new PEAR_Error('Search failed!')));
- try {
- $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals');
- $this->assertEquals(array('dn' => 'test'), $this->server->findBelow($equals, ''));
- $this->fail('No exception!');
- } catch (Exception $e) {
- $this->assertEquals('Search failed!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Test the LDAP 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__) . '/../LdapBase.php';
-
-/**
- * Test the LDAP 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_Structure_KolabTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $server = $this->getMock('Horde_Kolab_Server');
- $this->composite = new Horde_Kolab_Server_Composite(
- $server,
- $this->getMock('Horde_Kolab_Server_Objects'),
- new Horde_Kolab_Server_Structure_Kolab(),
- $this->getMock('Horde_Kolab_Server_Search'),
- $this->getMock('Horde_Kolab_Server_Schema')
- );
- }
-
- public function testMethodGetsupportedobjectsHasResultArrayTheObjectTypesSupportedByThisStructure()
- {
- $this->assertType('array', $this->composite->structure->getSupportedObjects());
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid1()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('kolabGroupOfNames'))));
- $this->assertEquals('Horde_Kolab_Server_Object_Kolabgroupofnames', $this->composite->structure->determineType('guid'));
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid2()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('kolabExternalPop3Account'))));
- $this->assertEquals('Horde_Kolab_Server_Object_Kolabpop3account', $this->composite->structure->determineType('guid'));
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid3()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('kolabSharedFolder'))));
- $this->assertEquals('Horde_Kolab_Server_Object_Kolabsharedfolder', $this->composite->structure->determineType('guid'));
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid4()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('top'))));
- $this->assertEquals('Horde_Kolab_Server_Object_Top', $this->composite->structure->determineType('guid'));
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid5()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- array(
- 'kolabinetorgperson',
- )
- )
- )
- );
- $this->composite->search->expects($this->exactly(1))
- ->method('__call')
- ->with('getGroups', array('guid'))
- ->will(
- $this->returnValue(
- array(
- )
- )
- );
- $this->assertEquals(
- 'Horde_Kolab_Server_Object_Kolab_User',
- $this->composite->structure->determineType('guid')
- );
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid6()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- array(
- 'kolabinetorgperson',
- )
- )
- )
- );
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->composite->search->expects($this->exactly(1))
- ->method('__call')
- ->with('getGroups', array('guid'))
- ->will(
- $this->returnValue(
- array(
- 'cn=admin,cn=internal,base'
- )
- )
- );
- $this->assertEquals(
- 'Horde_Kolab_Server_Object_Kolab_Administrator',
- $this->composite->structure->determineType('guid')
- );
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid7()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- array(
- 'kolabinetorgperson',
- )
- )
- )
- );
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->composite->search->expects($this->exactly(1))
- ->method('__call')
- ->with('getGroups', array('guid'))
- ->will(
- $this->returnValue(
- array(
- 'cn=maintainer,cn=internal,base'
- )
- )
- );
- $this->assertEquals(
- 'Horde_Kolab_Server_Object_Kolab_Maintainer',
- $this->composite->structure->determineType('guid')
- );
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid8()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- array(
- 'kolabinetorgperson',
- )
- )
- )
- );
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->composite->search->expects($this->exactly(1))
- ->method('__call')
- ->with('getGroups', array('guid'))
- ->will(
- $this->returnValue(
- array(
- 'cn=domain-maintainer,cn=internal,base'
- )
- )
- );
- $this->assertEquals(
- 'Horde_Kolab_Server_Object_Kolab_Domainmaintainer',
- $this->composite->structure->determineType('guid')
- );
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid9()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid,cn=external')
- ->will(
- $this->returnValue(
- array(
- 'objectClass' =>
- array(
- 'kolabinetorgperson',
- )
- )
- )
- );
- $this->composite->search->expects($this->exactly(1))
- ->method('__call')
- ->with('getGroups', array('guid,cn=external'))
- ->will(
- $this->returnValue(
- array(
- 'unknown'
- )
- )
- );
- $this->assertEquals(
- 'Horde_Kolab_Server_Object_Kolab_Address',
- $this->composite->structure->determineType('guid,cn=external')
- );
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid1()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolabgroupofnames', 'id', array()));
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid2()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals('id,cn=internal,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolabgroupofnames', 'id', array('visible' => false)));
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid3()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolabsharedfolder', 'id', array('visible' => false)));
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid4()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals('id,cn=external,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolab_Address', 'id', array()));
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid5()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals(
- 'id,cn=internal,base',
- $this->composite->structure->generateServerGuid(
- 'Horde_Kolab_Server_Object_Kolab_User', 'id',
- array('user_type' => Horde_Kolab_Server_Object_Kolab_User::USERTYPE_INTERNAL)
- )
- );
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid6()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals(
- 'id,cn=groups,base',
- $this->composite->structure->generateServerGuid(
- 'Horde_Kolab_Server_Object_Kolab_User', 'id',
- array('user_type' => Horde_Kolab_Server_Object_Kolab_User::USERTYPE_GROUP)
- )
- );
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid7()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals(
- 'id,cn=resources,base',
- $this->composite->structure->generateServerGuid(
- 'Horde_Kolab_Server_Object_Kolab_User', 'id',
- array('user_type' => Horde_Kolab_Server_Object_Kolab_User::USERTYPE_RESOURCE)
- )
- );
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid8()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('Horde_Kolab_Server_Object_Kolab_User', 'id', array()));
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid9()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals(
- 'id,base',
- $this->composite->structure->generateServerGuid(
- 'Horde_Kolab_Server_Object_Kolab_User', 'id',
- array('user_type' => 'undefined')
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Test the LDAP 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__) . '/../LdapBase.php';
-
-/**
- * Test the LDAP 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_Structure_LdapTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $server = $this->getMock('Horde_Kolab_Server');
- $this->composite = new Horde_Kolab_Server_Composite(
- $server,
- $this->getMock('Horde_Kolab_Server_Objects'),
- new Horde_Kolab_Server_Structure_Ldap(),
- $this->getMock('Horde_Kolab_Server_Search'),
- $this->getMock('Horde_Kolab_Server_Schema')
- );
- }
-
- public function testMethodGetsupportedobjectsHasResultArrayTheObjectTypesSupportedByThisStructure()
- {
- $this->assertEquals(array('Horde_Kolab_Server_Object'), $this->composite->structure->getSupportedObjects());
- }
-
- public function testMethodDeterminetypeHasParameterStringGuid()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('TOP'))));
- $this->composite->structure->determineType('guid');
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('TOP'))));
- $this->assertEquals('Horde_Kolab_Server_Object_Top', $this->composite->structure->determineType('guid'));
- }
-
- public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid2()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('person'))));
- $this->assertEquals('Horde_Kolab_Server_Object_Person', $this->composite->structure->determineType('guid'));
- }
-
- public function testMethodDeterminetypeThrowsExceptionIfTheGuidHasNoAttributeObjectclass()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array()));
- try {
- $this->composite->structure->determineType('guid');
- } catch (Exception $e) {
- $this->assertEquals('The object guid has no objectClass attribute!', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodDeterminetypeThrowsExceptionIfTheTypeIsUnknown()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('read')
- ->with('guid')
- ->will($this->returnValue(array('objectClass' => array('UNKNOWN'))));
- try {
- $this->composite->structure->determineType('guid');
- } catch (Exception $e) {
- $this->assertEquals('Unknown object type for GUID guid.', $e->getMessage());
- $this->assertEquals(Horde_Kolab_Server_Exception::SYSTEM, $e->getCode());
- }
- }
-
- public function testMethodGenerateserverguidHasParameterStringType()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->composite->structure->generateServerGuid('type', '', array());
- }
-
- public function testMethodGenerateserverguidHasParameterStringId()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->composite->structure->generateServerGuid('', 'id', array());
- }
-
- public function testMethodGenerateserverguidHasParameterArrayObjectData()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->composite->structure->generateServerGuid('', '', array('object' => 'data'));
- }
-
- public function testMethodGenerateserverguidHasResultStringTheGuid()
- {
- $this->composite->server->expects($this->exactly(1))
- ->method('getBaseGuid')
- ->will($this->returnValue('base'));
- $this->assertEquals('id,base', $this->composite->structure->generateServerGuid('', 'id', array()));
- }
-}
/**
* Skip LDAP based tests if we don't have ldap or Net_LDAP2.
*
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * 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.