implements Horde_Kolab_Server_Object_Attribute_Interface
{
/**
- * The attribute name on the internal side.
+ * The attribute name.
*
* @param string
*/
- protected $_internal;
+ protected $name;
/**
- * The attribute name on the external side.
+ * The internal attribute adapter.
*
- * @param string
- */
- private $_external;
-
- /**
- * The object this attribute belongs to.
- *
- * @param Horde_Kolab_Server_Object
+ * @param Horde_Kolab_Server_Structure_Attribute_Interface
*/
- protected $_object;
-
- /**
- * Link to the Kolab server.
- *
- * @var Horde_Kolab_Server_Composite
- */
- protected $_composite;
+ protected $attribute;
/**
* Constructor
*
- * @param Horde_Kolab_Server_Object $object The object this attribute
- * belongs to.
- * @param Horde_Kolab_Server_Composite $composite The link to the server.
- * @param string $name The name of this attribute.
+ * @param Horde_Kolab_Server_Structure_Attribute_Interface $attribute The internal attribute adapter.
+ * @param string $name The name of this attribute.
*/
public function __construct(
- Horde_Kolab_Server_Object_Interface $object,
- Horde_Kolab_Server_Composite_Interface $composite,
- $external
+ Horde_Kolab_Server_Structure_Attribute_Interface $attribute,
+ $name
) {
- $this->_object = $object;
- $this->_composite = $composite;
- $this->_external = $external;
-
- $this->_internal = $this->_composite->structure->mapExternalToInternalAttribute(
- $this->_external
- );
+ $this->attribute = $attribute;
+ $this->name = $name;
}
/**
- * Return the object this attribute belongs to.
+ * Return the internal attribute adapter.
*
- * @return Horde_Kolab_Server_Object The object.
+ * @return Horde_Kolab_Server_Structure_Attribute_Interface The internal
+ * attribute.
*/
- public function getObject()
+ public function getAttribute()
{
- return $this->_object;
+ return $this->attribute;
}
/**
- * Return the internal name of this attribute.
+ * Return the name of this attribute.
*
- * @return string The name of this object.
+ * @return string The name of this attribute.
*/
- public function getInternalName()
+ public function getName()
{
- return $this->_internal;
- }
-
- /**
- * Return the external name of this attribute.
- *
- * @return string The name of this object.
- */
- public function getExternalName()
- {
- if (empty($this->_external)) {
- $this->_external = substr(get_class($this), 36);
- }
- return $this->_external;
+ return $this->name;
}
/**
*/
public function isEmpty(array $changes)
{
- $name = $this->getExternalName();
- if ((!in_array($name, array_keys($changes))
- || $changes[$name] === null
- || $changes[$name] === ''
- || $changes[$name] === array())) {
+ if ((!in_array($this->name, array_keys($changes))
+ || $changes[$this->name] === null
+ || $changes[$this->name] === ''
+ || $changes[$this->name] === array())
+ ) {
return true;
}
return false;
}
/**
- * Return the object this attribute belongs to.
+ * Return the internal attribute adapter.
*
- * @return Horde_Kolab_Server_Object The object.
+ * @return Horde_Kolab_Server_Structure_Attribute_Interface The internal
*/
- public function getObject()
+ public function getAttribute()
{
- return $this->_attribute->getObject();
+ return $this->_attribute->getAttribute();
}
/**
- * Return the internal name of this attribute.
+ * Return the name of this attribute.
*
- * @return string The name of this object.
- */
- public function getInternalName()
- {
- return $this->_attribute->getInternalName();
- }
-
- /**
- * Return the external name of this attribute.
- *
- * @return string The name of this object.
+ * @return string The name of this attribute.
*/
- public function getExternalName()
+ public function getName()
{
- return $this->_attribute->getExternalName();
+ return $this->_attribute->getName();
}
/**
{
return $this->_attribute->isEmpty($changes);
}
-
- /**
- * Indicate that a value will be saved by deleting it from the original data
- * array.
- *
- * @param array &$changes The object data that should be changed.
- *
- * @return NULL
- */
- public function consume(array &$changes)
- {
- return $this->_attribute->consume($changes);
- }
}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * The name of a person in "firstname lastname" format.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * The name of a person in "firstname lastname" format.
+ *
+ * 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_Attribute_Firstnamelastname
+extends Horde_Kolab_Server_Object_Attribute_Value
+{
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Structure_Attribute_Interface $object The object
+ * this attribute belongs to.
+ * @param string $name The name of this attribute.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Structure_Attribute_Double $attribute,
+ $name
+ ) {
+ parent::__construct($attribute, $name);
+ }
+
+ /**
+ * Return the value of this attribute.
+ *
+ * @return array The value(s) of this attribute.
+ *
+ * @throws Horde_Kolab_Server_Exception If retrieval of the value failed.
+ */
+ public function value()
+ {
+ $values = $this->attribute->value();
+ return sprintf('%s %s', $values[0], $values[1]);
+ }
+
+}
\ No newline at end of file
public function update(array $changes);
/**
- * Return the object this attribute belongs to.
+ * Return the internal attribute adapter.
*
- * @return Horde_Kolab_Server_Object The object.
+ * @return Horde_Kolab_Server_Structure_Attribute_Interface The internal
*/
- public function getObject();
+ public function getAttribute();
/**
- * Return the internal name of this attribute.
+ * Return the name of this attribute.
*
- * @return string The name of this object.
- */
- public function getInternalName();
-
- /**
- * Return the external name of this attribute.
- *
- * @return string The name of this object.
+ * @return string The name of this attribute.
*/
- public function getExternalName();
+ public function getName();
/**
* Return if this attribute is undefined in the given data array.
* @return string The name of this object.
*/
public function isEmpty(array $changes);
-
- /**
- * Indicate that a value will be saved by deleting it from the original data
- * array.
- *
- * @param array &$changes The object data that should be changed.
- *
- * @return NULL
- */
- public function consume(array &$changes);
}
\ No newline at end of file
throw new Horde_Kolab_Server_Exception(
sprintf(
"The value for \"%s\" may not be modified on an existing object!",
- $this->_attribute->getExternalName()
+ $this->_attribute->getName()
)
);
}
class Horde_Kolab_Server_Object_Attribute_Openldapaci
extends Horde_Kolab_Server_Object_Attribute_Value
{
- /** The attribute name */
- const NAME = 'OpenLDAPaci';
-
/**
* Constructor
*
Horde_Kolab_Server_Object $object,
Horde_Kolab_Server_Composite $composite
) {
- parent::__construct($object, $composite, self::NAME);
+ parent::__construct($object, $composite, 'Openldapaci');
}
}
\ No newline at end of file
{
$value = $this->_attribute->value();
if (is_array($value)) {
- return array_pop($value);
+ return array_shift($value);
} else {
return $value;
}
*/
public function value()
{
- return $this->_object->getInternal($this->getInternalName());
+ return $this->attribute->value();
}
/**
*/
public function consume(array &$changes)
{
- if (isset($changes[$this->getExternalName()])) {
- unset($changes[$this->getExternalName()]);
+ if (isset($changes[$this->name])) {
+ unset($changes[$this->name]);
}
}
public function update(array $changes)
{
if (!$this->isEmpty($changes)) {
- $value = $changes[$this->getExternalName()];
+ $value = $changes[$this->name];
if (!is_array($value)) {
$value = array($value);
}
- return array($this->getInternalName() => $value);
+ return $this->attribute->update($value);
}
try {
- $old = $this->_object->getInternal($this->getInternalName());
- return array($this->getInternalName() => array());
+ $old = $this->attribute->value();
+ return $this->attribute->update(array());
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
return array();
}
*/
public function getExternalAttributes()
{
- return $this->_composite->schema->getExternalAttributes($this);
+ return $this->_composite->structure->getExternalAttributes($this);
}
/**
*/
public function getInternalAttributes()
{
- return $this->_composite->schema->getInternalAttributes($this);
+ return $this->_composite->structure->getInternalAttributes($this);
}
/**
}
/**
- * Get the specified attribute of this object
+ * Get the specified internal attributes.
*
- * @param string $attr The attribute to read
+ * @param array $attributes The internal attribute.
*
- * @return array The value(s) of this attribute
+ * @return array The value(s) of these attribute
*/
- public function getInternal($attr)
+ public function getInternal(array $attributes)
{
- if (!in_array($attr, array_keys($this->getInternalAttributes()))) {
- throw new Horde_Kolab_Server_Exception(
- sprintf("Attribute \"%s\" not supported!", $attr)
- );
- }
$result = $this->readInternal();
- if (!isset($result[$attr])) {
- throw new Horde_Kolab_Server_Exception_Novalue(
- sprintf("No value for attribute \"%s\"!", $attr)
- );
+
+ $values = array();
+ foreach ($attributes as $attribute) {
+
+ if (!isset($result[$attribute])) {
+ throw new Horde_Kolab_Server_Exception_Novalue(
+ sprintf(
+ "No value for attribute \"%s\"!",
+ $attribute
+ )
+ );
+ }
+ $values[$attribute] = $result[$attribute];
}
- return $result[$attr];
+ return $values;
}
/**
*/
public function getExternal($attr)
{
- $attr = ucfirst($attr);
- $class = 'Horde_Kolab_Server_Object_Attribute_' . $attr;
- if (!in_array($attr, $this->getExternalAttributes())
- || !class_exists($class)) {
- //@todo: Consider support for external classes.
+ if (!in_array($attr, $this->getExternalAttributes())) {
throw new Horde_Kolab_Server_Exception(
sprintf("Attribute \"%s\" not supported!", $attr)
);
}
- $attribute = new $class($this, $this->_composite);
+ $attribute = $this->_composite->structure->getExternalAttribute(
+ $attr, $this
+ );
return $attribute->value();
}
protected function getNewInternal($info)
{
$internal = array();
- $consumed = $info;
- $attributes = $this->getInternalAttributes();
- foreach (array_values($attributes) as $class) {
- $attribute = new $class($this, $this->_composite);
- $internal = array_merge($internal, $attribute->update($info));
- $attribute->consume($consumed);
- }
-
- /** Check if all given data would be used for saving */
- if (!empty($consumed)) {
- throw new Horde_Kolab_Server_Exception(
- sprintf(
- "Not all data would be saved. Leftover keys: %s.",
- join(',', array_keys($consumed))
- )
+ foreach ($info as $external => $value) {
+ $attribute = $this->_composite->structure->getExternalAttribute(
+ $external, $this
);
+ $internal = array_merge($internal, $attribute->update($info));
}
-
return $internal;
}
}
/**
- * Get the specified attribute of this object
+ * Get the specified internal attributes.
*
- * @param string $attr The attribute to read
+ * @param array $attributes The internal attribute.
*
- * @return array The value(s) of this attribute
+ * @return array The value(s) of these attribute
*/
- public function getInternal($attr)
+ public function getInternal(array $attributes)
{
- return $this->_object->getInternal($attr);
+ return $this->_object->getInternal($attributes);
}
/**
*/
class Horde_Kolab_Server_Object_Inetorgperson extends Horde_Kolab_Server_Object_Organizationalperson
{
- /** Define attributes specific to this object type */
-
- /** The short ID */
- const ATTRIBUTE_SID = 'uid';
-
- /** The organization / company */
- const ATTRIBUTE_ORGANIZATION = 'o';
-
- /** The business category */
- const ATTRIBUTE_BUSINESSCATEGORY = 'businessCategory';
-
- /** The phone number at home*/
- const ATTRIBUTE_HOMEPHONE = 'homePhone';
-
- /** The mobile phone number */
- const ATTRIBUTE_MOBILE = 'mobile';
-
- /** The photo attribute */
- const ATTRIBUTE_PHOTO = 'photo';
-
- /** The photo in JPEG format */
- const ATTRIBUTE_JPEGPHOTO = 'jpegPhoto';
-
- /** The given name */
- const ATTRIBUTE_GIVENNAME = 'givenName';
-
- /** Middle names */
- const ATTRIBUTE_MIDDLENAMES = 'middleNames';
-
- /** The mail address of this person */
- const ATTRIBUTE_MAIL = 'mail';
-
- /** Home addresses */
- const ATTRIBUTE_HOMEPOSTALADDRESS = 'homePostalAddress';
-
- /** Home addresses as array */
- const ATTRARRAY_HOMEPOSTALADDRESS = 'homePostalAddressArray';
-
- /** Labeled URI */
- const ATTRIBUTE_LABELEDURI = 'labeledURI';
-
- /** Labeled URIs as array */
- const ATTRARRAY_LABELEDURI = 'labeledURIArray';
-
- /** The last name followed by the first name */
- const ATTRIBUTE_LNFN = 'lnfn';
-
- /** The first name followed by the last name */
- const ATTRIBUTE_FNLN = 'fnln';
-
- /** The SMIME certificate for the user */
- const ATTRIBUTE_SMIMECERTIFICATE = 'userSMIMECertificate';
-
/** The specific object class of this object type */
const OBJECTCLASS_INETORGPERSON = 'inetOrgPerson';
/**
+ * The attributes defined for this class.
+ *
+ * @var array
+ */
+ static public $attributes = array(
+ 'Uid', 'Mail','Firstnamelastname',
+/* 'Organization', 'Businesscategory', 'Homephone', 'Mobile', */
+/* 'Photo', 'Jpegphoto', 'Givenname', 'Middlenames', */
+/* 'Homepostaladdress', 'Labeleduri', 'Lastnamefirstname', */
+/* 'Usersmimecertificate' */
+ );
+
+ /**
* A structure to initialize the attribute structure for this class.
*
* @var array
/* 'defined' => array( */
/* self::ATTRIBUTE_SID, */
/* self::ATTRIBUTE_GIVENNAME, */
-/* self::ATTRIBUTE_MAIL, */
/* self::ATTRIBUTE_LABELEDURI, */
/* self::ATTRIBUTE_HOMEPOSTALADDRESS, */
/* self::ATTRIBUTE_ORGANIZATION, */
public function readInternal();
/**
- * Get the specified attribute of this object
+ * Get the specified internal attributes.
*
- * @param string $attr The attribute to read
+ * @param array $attributes The internal attribute.
*
- * @return array The value(s) of this attribute
+ * @return array The value(s) of these attribute
*/
- public function getInternal($attr);
+ public function getInternal(array $attributes);
/**
* Get the specified attribute of this object.
* @var array
*/
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',
+ 'Alias', 'Kolabhomeserver', 'Kolabfreebusyhost'
+/* 'kolabDelegate', 'kolabDeleteFlag', 'kolabFreeBusyFuture', */
+/* , , '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', */
);
*/
/* static public $init_attributes = array( */
/* 'defined' => array( */
-/* self::ATTRIBUTE_ALIAS, */
/* self::ATTRIBUTE_DELEGATE, */
/* self::ATTRIBUTE_DELETED, */
/* self::ATTRIBUTE_FBFUTURE, */
}
/**
- * Get the specified attribute of this object
+ * Get the specified internal attributes.
*
- * @param string $attr The attribute to read
- * @param boolean $single Should a single value be returned
- * or are multiple values allowed?
+ * @param array $attributes The internal attribute.
*
- * @return string the value of this attribute
+ * @return array The value(s) of these attribute
*/
- public function getInternal($attr)
+ public function getInternal(array $attributes)
{
if (!isset($this->_cache_int[$attr])) {
if (!in_array($attr, array_keys($this->getInternalAttributes()))) {
* @var array
*/
static public $init_attributes = array(
- 'Cn', 'Sn', 'Userpassword', 'Userpasswordraw', 'Telephonenumber'
+ 'Cn', 'Sn', 'Userpassword', 'Userpasswordraw',
+/* 'Telephonenumber' */
+
/* 'defined' => array( */
/* self::ATTRIBUTE_CN, */
/* self::ATTRIBUTE_SN, */
* @var array
*/
static public $attributes = array(
- 'Objectclass', 'Openldapaci', 'Guid', 'Id',
- 'Createtimestamp', 'Modifyimestamp',
- 'Createtimestampdate', 'Modifyimestampdate',
+ 'objectClass', 'Openldapaci', 'Guid', 'Id',
+ 'Createtimestamp', 'Modifytimestamp',
+ 'Createtimestampdate', 'Modifytimestampdate',
);
static public $object_classes = array(
class Horde_Kolab_Server_Schema_Base
implements Horde_Kolab_Server_Schema_Interface
{
- /** Maximum accepted level for the object class hierarchy */
- const MAX_HIERARCHY = 100;
-
/**
* A link to the composite server handler.
*
* @var Horde_Kolab_Server_Composite
*/
- protected $composite;
+ private $_composite;
/**
* Set the composite server reference for this object.
public function setComposite(
Horde_Kolab_Server_Composite_Interface $composite
) {
- $this->composite = $composite;
+ $this->_composite = $composite;
}
/**
*/
public function getExternalAttributes($class)
{
- if (!isset($this->attributes)) {
- if (isset($this->cache)) {
- register_shutdown_function(array($this, 'shutdown'));
- }
+ $childclass = get_class($class);
+ $classes = array();
+ $level = 0;
+ while ($childclass != 'Horde_Kolab_Server_Object_Top'
+ && $level < self::MAX_HIERARCHY) {
+ $classes[] = $childclass;
+ $childclass = get_parent_class($childclass);
+ $level++;
}
- if (empty($this->attributes[$class])) {
-
- if (isset($this->cache)) {
- $this->attributes[$class] = @unserialize($cache->get('attributes_' . $class,
- $this->params['cache_lifetime']));
- }
- if (empty($this->attributes[$class])) {
+ /** Finally add the basic object class */
+ $classes[] = $childclass;
- $childclass = $class;
- $classes = array();
- $level = 0;
- while ($childclass != 'Horde_Kolab_Server_Object'
- && $level < self::MAX_HIERARCHY) {
- $classes[] = $childclass;
- $childclass = get_parent_class($childclass);
- $level++;
- }
+ //@todo: Throw exception here
+ if ($level == self::MAX_HIERARCHY) {
+ if (isset($this->logger)) {
+ $logger->err(sprintf('The maximal level of the object hierarchy has been exceeded for class \"%s\"!',
+ $class));
+ }
+ }
- /** Finally add the basic object class */
- $classes[] = $childclass;
+ /**
+ * Collect attributes from bottom to top.
+ */
+ $classes = array_reverse($classes);
- if ($level == self::MAX_HIERARCHY) {
- if (isset($this->logger)) {
- $logger->err(sprintf('The maximal level of the object hierarchy has been exceeded for class \"%s\"!',
- $class));
- }
- }
+ $attributes = array();
+ foreach ($classes as $childclass) {
+ $vars = get_class_vars($childclass);
+ if (isset($vars['attributes'])) {
/**
- * Collect attributes from bottom to top.
+ * If the user wishes to adhere to the schema
+ * information from the server we will skip the
+ * attributes defined within the object class here.
*/
- $classes = array_reverse($classes);
-
- $types = array('defined', 'required', 'derived', 'collapsed',
- 'defaults', 'locked', 'object_classes');
- foreach ($types as $type) {
- $$type = array();
- }
-
- foreach ($classes as $childclass) {
- $vars = get_class_vars($childclass);
- if (isset($vars['init_attributes'])) {
- foreach ($types as $type) {
- /**
- * If the user wishes to adhere to the schema
- * information from the server we will skip the
- * attributes defined within the object class here.
- */
- if (!empty($this->params['schema_override'])
- && in_array($type, 'defined', 'required')) {
- continue;
- }
- if (isset($vars['init_attributes'][$type])) {
- $$type = array_merge($$type,
- $vars['init_attributes'][$type]);
- }
- }
- }
- }
-
- $attrs = array();
-
- foreach ($object_classes as $object_class) {
- $info = $this->getObjectclassSchema($object_class);
- if (isset($info['may'])) {
- $defined = array_merge($defined, $info['may']);
- }
- if (isset($info['must'])) {
- $defined = array_merge($defined, $info['must']);
- $required = array_merge($required, $info['must']);
- }
- foreach ($defined as $attribute) {
- try {
- $attrs[$attribute] = $this->getAttributeSchema($attribute);
- } catch (Horde_Kolab_Server_Exception $e) {
- /**
- * If the server considers the attribute to be
- * invalid we mark it.
- */
- $attrs[$attribute] = array('invalid' => true);
- }
- }
- foreach ($required as $attribute) {
- $attrs[$attribute]['required'] = true;
- }
- foreach ($locked as $attribute) {
- $attrs[$attribute]['locked'] = true;
- }
- foreach ($defaults as $attribute => $default) {
- $attrs[$attribute]['default'] = $default;
- }
- $attrs[Horde_Kolab_Server_Object::ATTRIBUTE_OC]['default'] = $object_classes;
- }
- foreach ($derived as $key => $attributes) {
- $supported = true;
- if (isset($attributes['base'])) {
- foreach ($attributes['base'] as $attribute) {
- /**
- * Usually derived attribute are determined on basis
- * of one or more attributes. If any of these is not
- * supported the derived attribute should not be
- * included into the set of supported attributes.
- */
- if (!isset($attrs[$attribute])) {
- unset($derived[$attribute]);
- $supported = false;
- break;
- }
- }
- }
- if ($supported) {
- $attrs[$key] = $attributes;
- }
- }
- $check_collapsed = $collapsed;
- foreach ($check_collapsed as $key => $attributes) {
- if (isset($attributes['base'])) {
- foreach ($attributes['base'] as $attribute) {
- /**
- * Usually collapsed attribute are determined on basis
- * of one or more attributes. If any of these is not
- * supported the collapsed attribute should not be
- * included into the set of supported attributes.
- */
- if (!isset($attrs[$attribute])) {
- unset($collapsed[$attribute]);
- }
- }
- }
+ if (!empty($this->params['schema_override'])) {
+ continue;
}
- $this->attributes[$class] = array($attrs,
- array(
- 'derived' => array_keys($derived),
- 'collapsed' => $collapsed,
- 'locked' => $locked,
- 'required' => $required));
+ $attributes = array_merge($vars['attributes'], $attributes);
}
}
- return $this->attributes[$class];
- }
- public function getInternalAttributes($class)
- {
+/* $attrs = array(); */
+
+/* foreach ($object_classes as $object_class) { */
+/* $info = $this->getObjectclassSchema($object_class); */
+/* if (isset($info['may'])) { */
+/* $defined = array_merge($defined, $info['may']); */
+/* } */
+/* if (isset($info['must'])) { */
+/* $defined = array_merge($defined, $info['must']); */
+/* $required = array_merge($required, $info['must']); */
+/* } */
+/* foreach ($defined as $attribute) { */
+/* try { */
+/* $attrs[$attribute] = $this->getAttributeSchema($attribute); */
+/* } catch (Horde_Kolab_Server_Exception $e) { */
+/* /\** */
+/* * If the server considers the attribute to be */
+/* * invalid we mark it. */
+/* *\/ */
+/* $attrs[$attribute] = array('invalid' => true); */
+/* } */
+/* } */
+/* foreach ($required as $attribute) { */
+/* $attrs[$attribute]['required'] = true; */
+/* } */
+/* foreach ($locked as $attribute) { */
+/* $attrs[$attribute]['locked'] = true; */
+/* } */
+/* foreach ($defaults as $attribute => $default) { */
+/* $attrs[$attribute]['default'] = $default; */
+/* } */
+/* $attrs[Horde_Kolab_Server_Object::ATTRIBUTE_OC]['default'] = $object_classes; */
+/* } */
+/* foreach ($derived as $key => $attributes) { */
+/* $supported = true; */
+/* if (isset($attributes['base'])) { */
+/* foreach ($attributes['base'] as $attribute) { */
+/* /\** */
+/* * Usually derived attribute are determined on basis */
+/* * of one or more attributes. If any of these is not */
+/* * supported the derived attribute should not be */
+/* * included into the set of supported attributes. */
+/* *\/ */
+/* if (!isset($attrs[$attribute])) { */
+/* unset($derived[$attribute]); */
+/* $supported = false; */
+/* break; */
+/* } */
+/* } */
+/* } */
+/* if ($supported) { */
+/* $attrs[$key] = $attributes; */
+/* } */
+/* } */
+/* $check_collapsed = $collapsed; */
+/* foreach ($check_collapsed as $key => $attributes) { */
+/* if (isset($attributes['base'])) { */
+/* foreach ($attributes['base'] as $attribute) { */
+/* /\** */
+/* * Usually collapsed attribute are determined on basis */
+/* * of one or more attributes. If any of these is not */
+/* * supported the collapsed attribute should not be */
+/* * included into the set of supported attributes. */
+/* *\/ */
+/* if (!isset($attrs[$attribute])) { */
+/* unset($collapsed[$attribute]); */
+/* } */
+/* } */
+/* } */
+/* } */
+/* $this->attributes[$class] = array($attrs, */
+/* array( */
+/* 'derived' => array_keys($derived), */
+/* 'collapsed' => $collapsed, */
+/* 'locked' => $locked, */
+/* 'required' => $required)); */
+ return $attributes;
}
/**
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Server
*/
-class Horde_Kolab_Server_Schema_Base
+class Horde_Kolab_Server_Schema_Decorator_Cache
implements Horde_Kolab_Server_Schema_Interface
{
/** Maximum accepted level for the object class hierarchy */
*
* @return NULL
*/
- public function setComposite(Horde_Kolab_Server_Composite $composite)
- {
+ public function setComposite(
+ Horde_Kolab_Server_Composite_Interface $composite
+ ) {
$this->composite = $composite;
}
* @throws Horde_Kolab_Server_Exception If retrieval of the schema failed.
*/
public function getAttributeSchema($attribute);
-
- /**
- * Return the external attributes supported by the given object class.
- *
- * @param Horde_Kolab_Server_Object $object Determine the external
- * attributes for this class.
- *
- * @return array The supported attributes.
- *
- * @throws Horde_Kolab_Server_Exception If the schema analysis fails.
- */
- public function getExternalAttributes($object);
-
- /**
- * Return the internal attributes supported by the given object class.
- *
- * @param Horde_Kolab_Server_Object $object Determine the internal
- * attributes for this class.
- *
- * @return array The supported attributes.
- *
- * @throws Horde_Kolab_Server_Exception If the schema analysis fails.
- */
- public function getInternalAttributes($object);
}
\ No newline at end of file
Horde_Kolab_Server_Query_Element_Interface $criteria
) {
$params = array(
- 'attributes' => 'Guid'
+ 'attributes' => 'guid'
);
$data = $this->getStructure()->find($criteria, $params);
return self::guidFromResult($data);
$criteria = new Horde_Kolab_Server_Query_Element_And(
array(
new Horde_Kolab_Server_Query_Element_Equals(
- 'Objectclass',
+ 'objectClass',
Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON
),
$criteria
--- /dev/null
+<?php
+/**
+ * An adapter for attributes that rely on two internal Kolab object attributes.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * An adapter for attributes that rely on two internal Kolab object attributes.
+ *
+ * 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_Structure_Attribute_Double
+implements Horde_Kolab_Server_Structure_Attribute_Interface
+{
+ /**
+ * The attribute names.
+ *
+ * @param array
+ */
+ protected $names;
+
+ /**
+ * The object the attribute belongs to.
+ *
+ * @param Horde_Kolab_Server_Object_Interface
+ */
+ protected $object;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Object_Interface $object The object
+ * this attribute belongs to.
+ * @param string $name The name of this attribute.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Object_Interface $object,
+ array $names
+ ) {
+ $this->object = $object;
+ $this->names = $names;
+ }
+
+ /**
+ * Return the internal attribute adapter.
+ *
+ * @return Horde_Kolab_Server_Object_Interface The object the attribute belongs to.
+ */
+ public function getObject()
+ {
+ return $this->object;
+ }
+
+ /**
+ * Return the name of this attribute.
+ *
+ * @return string The name of this attribute.
+ */
+ public function getName()
+ {
+ return $this->names;
+ }
+
+ /**
+ * Return the value of this attribute.
+ *
+ * @return array The value of the attribute
+ */
+ public function value()
+ {
+ return $this->object->getInternal($this->names);
+ }
+
+ /**
+ * Return the new internal state for this attribute.
+ *
+ * @param array $changes The object data that should be updated.
+ *
+ * @return array The resulting internal state.
+ *
+ * @throws Horde_Kolab_Server_Exception If storing the value failed.
+ */
+ public function update(array $changes)
+ {
+ return array();
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * The interface describing internal Kolab object attributes.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * The interface describing internal Kolab object attributes.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+interface Horde_Kolab_Server_Structure_Attribute_Interface
+{
+ /**
+ * Return the internal attribute adapter.
+ *
+ * @return Horde_Kolab_Server_Object_Interface The object the attribute belongs to.
+ */
+ public function getObject();
+
+ /**
+ * Return the name of this attribute.
+ *
+ * @return string The name of this attribute.
+ */
+ public function getName();
+
+ /**
+ * Return the value of this attribute.
+ *
+ * @return array The value of the attribute
+ */
+ public function value();
+
+ /**
+ * Return the new internal state for this attribute.
+ *
+ * @param array $changes The object data that should be updated.
+ *
+ * @return array The resulting internal state.
+ *
+ * @throws Horde_Kolab_Server_Exception If storing the value failed.
+ */
+ public function update(array $changes);
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * The base class representing internal Kolab object attributes.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * The base class representing internal Kolab object attributes.
+ *
+ * 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_Structure_Attribute_Value
+implements Horde_Kolab_Server_Structure_Attribute_Interface
+{
+ /**
+ * The attribute name.
+ *
+ * @param string
+ */
+ protected $name;
+
+ /**
+ * The object the attribute belongs to.
+ *
+ * @param Horde_Kolab_Server_Object_Interface
+ */
+ protected $object;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Server_Object_Interface $object The object
+ * this attribute belongs to.
+ * @param string $name The name of this attribute.
+ */
+ public function __construct(
+ Horde_Kolab_Server_Object_Interface $object,
+ $name
+ ) {
+ $this->object = $object;
+ $this->name = $name;
+ }
+
+ /**
+ * Return the internal attribute adapter.
+ *
+ * @return Horde_Kolab_Server_Object_Interface The object the attribute belongs to.
+ */
+ public function getObject()
+ {
+ return $this->object;
+ }
+
+ /**
+ * Return the name of this attribute.
+ *
+ * @return string The name of this attribute.
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Return the value of this attribute.
+ *
+ * @return array The value of the attribute
+ */
+ public function value()
+ {
+ return $this->object->getInternal((array) $this->name);
+ }
+
+ /**
+ * Return the new internal state for this attribute.
+ *
+ * @param array $changes The object data that should be updated.
+ *
+ * @return array The resulting internal state.
+ *
+ * @throws Horde_Kolab_Server_Exception If storing the value failed.
+ */
+ public function update(array $changes)
+ {
+ return array();
+ }
+}
\ No newline at end of file
abstract class Horde_Kolab_Server_Structure_Base
implements Horde_Kolab_Server_Structure_Interface
{
+ /** Maximum accepted level for the object class hierarchy */
+ const MAX_HIERARCHY = 100;
+
/**
* A link to the composite server handler.
*
{
return $this->_composite;
}
+
+ /**
+ * Return the attributes supported by the given object class.
+ *
+ * @param string $class Determine the attributes for this class.
+ *
+ * @return array The supported attributes.
+ *
+ * @throws Horde_Kolab_Server_Exception If the schema analysis fails.
+ */
+ public function getExternalAttributes($class)
+ {
+ $childclass = get_class($class);
+ $classes = array();
+ $level = 0;
+ while ($childclass != 'Horde_Kolab_Server_Object_Top'
+ && $level < self::MAX_HIERARCHY) {
+ $classes[] = $childclass;
+ $childclass = get_parent_class($childclass);
+ $level++;
+ }
+
+ /** Finally add the basic object class */
+ $classes[] = $childclass;
+
+ //@todo: Throw exception here
+ if ($level == self::MAX_HIERARCHY) {
+ if (isset($this->logger)) {
+ $logger->err(sprintf('The maximal level of the object hierarchy has been exceeded for class \"%s\"!',
+ $class));
+ }
+ }
+
+ /**
+ * Collect attributes from bottom to top.
+ */
+ $classes = array_reverse($classes);
+
+ $attributes = array();
+
+ foreach ($classes as $childclass) {
+ $vars = get_class_vars($childclass);
+ if (isset($vars['attributes'])) {
+ $attributes = array_merge($vars['attributes'], $attributes);
+ }
+ }
+
+ return $attributes;
+ }
+
+
+ public function getInternalAttributes($class)
+ {
+ $external = $this->getExternalAttributes($class);
+ return $this->mapExternalToInternalAttributes($external);
+ }
+
+ public function getInternalAttributesForExternal($class, $external)
+ {
+ return $this->mapExternalToInternalAttributes((array) $external);
+ }
}
public function mapExternalToInternalAttribute($external);
/**
+ * Return the external attributes supported by the given object class.
+ *
+ * @param Horde_Kolab_Server_Object $object Determine the external
+ * attributes for this class.
+ *
+ * @return array The supported attributes.
+ *
+ * @throws Horde_Kolab_Server_Exception If the schema analysis fails.
+ */
+ public function getExternalAttributes($object);
+
+ /**
+ * Return the internal attributes supported by the given object class.
+ *
+ * @param Horde_Kolab_Server_Object $object Determine the internal
+ * attributes for this class.
+ *
+ * @return array The supported attributes.
+ *
+ * @throws Horde_Kolab_Server_Exception If the schema analysis fails.
+ */
+ public function getInternalAttributes($object);
+
+ public function getExternalAttribute(
+ $name,
+ Horde_Kolab_Server_Object_Interface $object
+ );
+
+ /**
* Determine the type of an object by its tree position and other
* parameters.
*
return $result;
}
+ public function getExternalAttribute(
+ $name,
+ Horde_Kolab_Server_Object_Interface $object
+ ) {
+ $class = ucfirst(strtolower($name));
+ $object_attribute_class = 'Horde_Kolab_Server_Object_Attribute_'
+ . $class;
+ $structure_attribute_class = 'Horde_Kolab_Server_Structure_Attribute_'
+ . $class;
+
+ if (class_exists($structure_attribute_class)) {
+ $structure_attribute = new $structure_attribute_class($object, $name);
+ } else {
+ switch ($name) {
+ case 'Firstnamelastname':
+ $structure_attribute = new Horde_Kolab_Server_Structure_Attribute_Double(
+ $object, array('givenName', 'sn')
+ );
+ break;
+ default:
+ $structure_attribute = new Horde_Kolab_Server_Structure_Attribute_Value(
+ $object, $name
+ );
+ break;
+ }
+ }
+
+ switch ($name) {
+ case 'objectClass':
+ $structure_attribute = new Horde_Kolab_Server_Structure_Attribute_Locked(
+ $structure_attribute
+ );
+ default:
+ break;
+ }
+
+
+ if (class_exists($object_attribute_class)) {
+ $object_attribute = new $object_attribute_class($structure_attribute, $name);
+ } else {
+ switch ($name) {
+ default:
+ $object_attribute = new Horde_Kolab_Server_Object_Attribute_Value(
+ $structure_attribute, $name
+ );
+ break;
+ }
+ }
+
+/* case 'Guid': */
+/* return 'dn'; */
+/* case 'Uid': */
+/* return 'uid'; */
+/* case 'Mail': */
+/* return 'mail'; */
+/* case 'Alias': */
+/* return 'alias'; */
+/* case 'Delegate': */
+/* return 'kolabDelegate'; */
+/* case 'Firstnamelastname': */
+/* return array('givenName', 'sn'); */
+/* case 'Openldapaci': */
+/* return 'openLDAPaci'; */
+/* case 'Kolabhomeserver': */
+/* return 'kolabHomeServer'; */
+/* case 'Kolabfreebusyhost': */
+/* //@todo: rename to kolabFreeBusyService(Url) */
+/* return 'kolabFreeBusyServer'; */
+/* case 'Createtimestamp': */
+/* case 'Createtimestampdate': */
+/* return 'createTimeStamp'; */
+/* case 'Modifytimestamp': */
+/* case 'Modifytimestampdate': */
+/* return 'modifyTimeStamp'; */
+/* case 'Id': */
+/* return null; */
+/* default: */
+/* throw new Horde_Kolab_Server_Exception( */
+/* sprintf('Undefined internal attribute "%s"', $external) */
+/* ); */
+/* } */
+
+ return $object_attribute;
+ }
+
/**
- * Maps the external attribute name to its internal counterpart.
+ * Maps the external attribute name to its internal counterpart(s).
*
* @param string $external The external attribute name.
*
- * @return string The internal attribute name.
+ * @return string The internal attribute name(s).
*/
- public function mapExternalToInternalAttribute($external)
+ private function _mapExternalToInternal($external)
{
switch ($external) {
- case 'Objectclass':
- return 'objectClass';
case 'Guid':
return 'dn';
case 'Uid':
return 'uid';
case 'Mail':
return 'mail';
+ case 'Alias':
+ return 'alias';
+ case 'Delegate':
+ return 'kolabDelegate';
+ case 'Firstnamelastname':
+ return array('givenName', 'sn');
+ case 'Openldapaci':
+ return 'openLDAPaci';
+ case 'Kolabhomeserver':
+ return 'kolabHomeServer';
+ case 'Kolabfreebusyhost':
+ //@todo: rename to kolabFreeBusyService(Url)
+ return 'kolabFreeBusyServer';
+ case 'Createtimestamp':
+ case 'Createtimestampdate':
+ return 'createTimeStamp';
+ case 'Modifytimestamp':
+ case 'Modifytimestampdate':
+ return 'modifyTimeStamp';
+ case 'Id':
+ return null;
default:
- throw new Horde_Kolab_Server_Exception(
- sprintf('Undefined internal attribute "%s"', $external)
- );
+ return $external;
}
}
+
+ /**
+ * Maps the external attribute name to its internal counterpart.
+ *
+ * @param string $external The external attribute name.
+ *
+ * @return string The internal attribute name.
+ */
+ public function mapExternalToInternalAttribute($external)
+ {
+ $internal = $this->_mapExternalToInternal($external);
+ if (is_string($internal)) {
+ return $internal;
+ } else if (is_array($internal)) {
+ throw new Horde_Kolab_Server_Exception('Multiple internal attributes!');
+ } else if ($internal === null) {
+ throw new Horde_Kolab_Server_Exception('No internal attribute mapping!');
+ }
+ throw new Horde_Kolab_Server_Exception(
+ sprintf(
+ 'Invalid internal attribute mapping: %s',
+ print_r($internal, true)
+ )
+ );
+ }
+
+ /**
+ * Maps the external attribute names to their internal counterparts.
+ *
+ * @param string $external The external attribute names.
+ *
+ * @return string The internal attribute names.
+ */
+ public function mapExternalToInternalAttributes(array $external)
+ {
+ $result = array();
+ foreach ($external as $attribute) {
+ $internal = $this->_mapExternalToInternal($attribute);
+ $result = array_merge($result, (array) $internal);
+ }
+ $result = array_unique($result);
+ return $result;
+ }
}
<file name="Filtered.php" role="php" />
<file name="Standard.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Server/Ldap -->
+ <dir name="List">
+ <file name="Base.php" role="php" />
+ <file name="Interface.php" role="php" />
+ </dir> <!-- /lib/Horde/Kolab/Server/Ldap -->
<dir name="Object">
<dir name="Attribute">
<file name="Base.php" role="php" />
<file name="Createtimestamp.php" role="php" />
<file name="Decorator.php" role="php" />
<file name="External.php" role="php" />
+ <file name="Firstnamelastname.php" role="php" />
<file name="Guid.php" role="php" />
<file name="Id.php" role="php" />
<file name="Internal.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Server/Search/Operation -->
</dir> <!-- /lib/Horde/Kolab/Server/Search -->
<dir name="Structure">
+ <dir name="Attribute">
+ <file name="Double.php" role="php" />
+ <file name="Interface.php" role="php" />
+ <file name="Value.php" role="php" />
+ </dir> <!-- /lib/Horde/Kolab/Server/Structure/Attribute -->
<file name="Base.php" role="php" />
<file name="Interface.php" role="php" />
<file name="Kolab.php" role="php" />
<install name="lib/Horde/Kolab/Server/Factory/Interface.php" as="Horde/Kolab/Server/Factory/Interface.php" />
<install name="lib/Horde/Kolab/Server/Factory/Kolab.php" as="Horde/Kolab/Server/Factory/Kolab.php" />
<install name="lib/Horde/Kolab/Server/Interface.php" as="Horde/Kolab/Server/Interface.php" />
+ <install name="lib/Horde/Kolab/Server/List/Base.php" as="Horde/Kolab/Server/List/Base.php" />
+ <install name="lib/Horde/Kolab/Server/List/Interface.php" as="Horde/Kolab/Server/List/Interface.php" />
<install name="lib/Horde/Kolab/Server/Ldap.php" as="Horde/Kolab/Server/Ldap.php" />
<install name="lib/Horde/Kolab/Server/Ldap/Changes.php" as="Horde/Kolab/Server/Ldap/Changes.php" />
<install name="lib/Horde/Kolab/Server/Ldap/Filtered.php" as="Horde/Kolab/Server/Ldap/Filtered.php" />
<install name="lib/Horde/Kolab/Server/Ldap/Standard.php" as="Horde/Kolab/Server/Ldap/Standard.php" />
+ <install name="lib/Horde/Kolab/Server/Object/Attribute/Alias.php" as="Horde/Kolab/Server/Object/Attribute/Alias.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Base.php" as="Horde/Kolab/Server/Object/Attribute/Base.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Createtimestampdate.php" as="Horde/Kolab/Server/Object/Attribute/Createtimestampdate.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Createtimestamp.php" as="Horde/Kolab/Server/Object/Attribute/Createtimestamp.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Decorator.php" as="Horde/Kolab/Server/Object/Attribute/Decorator.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/External.php" as="Horde/Kolab/Server/Object/Attribute/External.php" />
+ <install name="lib/Horde/Kolab/Server/Object/Attribute/Firstnamelastname.php" as="Horde/Kolab/Server/Object/Attribute/Firstnamelastname.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Guid.php" as="Horde/Kolab/Server/Object/Attribute/Guid.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Id.php" as="Horde/Kolab/Server/Object/Attribute/Id.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Interface.php" as="Horde/Kolab/Server/Object/Attribute/Interface.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Internal.php" as="Horde/Kolab/Server/Object/Attribute/Internal.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Locked.php" as="Horde/Kolab/Server/Object/Attribute/Locked.php" />
+ <install name="lib/Horde/Kolab/Server/Object/Attribute/Mail.php" as="Horde/Kolab/Server/Object/Attribute/Mail.php" />
+ <install name="lib/Horde/Kolab/Server/Object/Attribute/Kolabfreebusyhost.php" as="Horde/Kolab/Server/Object/Attribute/Kolabfreebusyhost.php" />
+ <install name="lib/Horde/Kolab/Server/Object/Attribute/Kolabhomeserver.php" as="Horde/Kolab/Server/Object/Attribute/Kolabhomeserver.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Modifytimestampdate.php" as="Horde/Kolab/Server/Object/Attribute/Modifytimestampdate.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Modifytimestamp.php" as="Horde/Kolab/Server/Object/Attribute/Modifytimestamp.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php" as="Horde/Kolab/Server/Object/Attribute/Objectclass.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Openldapaci.php" as="Horde/Kolab/Server/Object/Attribute/Openldapaci.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Required.php" as="Horde/Kolab/Server/Object/Attribute/Required.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Single.php" as="Horde/Kolab/Server/Object/Attribute/Single.php" />
+ <install name="lib/Horde/Kolab/Server/Object/Attribute/Uid.php" as="Horde/Kolab/Server/Object/Attribute/Uid.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Value.php" as="Horde/Kolab/Server/Object/Attribute/Value.php" />
<install name="lib/Horde/Kolab/Server/Object/Attribute/Writelock.php" as="Horde/Kolab/Server/Object/Attribute/Writelock.php" />
<install name="lib/Horde/Kolab/Server/Object/Base.php" as="Horde/Kolab/Server/Object/Base.php" />
<install name="lib/Horde/Kolab/Server/Search/Operation/Mailforuidormail.php" as="Horde/Kolab/Server/Search/Operation/Mailforuidormail.php" />
<install name="lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php" as="Horde/Kolab/Server/Search/Operation/Restrictgroups.php" />
<install name="lib/Horde/Kolab/Server/Search/Operation/Restrictkolab.php" as="Horde/Kolab/Server/Search/Operation/Restrictkolab.php" />
+ <install name="lib/Horde/Kolab/Server/Structure/Attribute/Double.php" as="Horde/Kolab/Server/Structure/Attribute/Double.php" />
+ <install name="lib/Horde/Kolab/Server/Structure/Attribute/Interface.php" as="Horde/Kolab/Server/Structure/Attribute/Interface.php" />
+ <install name="lib/Horde/Kolab/Server/Structure/Attribute/Value.php" as="Horde/Kolab/Server/Structure/Attribute/Value.php" />
<install name="lib/Horde/Kolab/Server/Structure/Base.php" as="Horde/Kolab/Server/Structure/Base.php" />
<install name="lib/Horde/Kolab/Server/Structure/Interface.php" as="Horde/Kolab/Server/Structure/Interface.php" />
<install name="lib/Horde/Kolab/Server/Structure/Kolab.php" as="Horde/Kolab/Server/Structure/Kolab.php" />
array('att' => 'b', 'log' => '=', 'val' => '1'),
)), $a);
+ try {
+ $a = $conn->parse('dummy');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Filter parsing error: dummy - filter components must be enclosed in round brackets', $e->getMessage());
+ }
+
+ try {
+ $a = $conn->parse('(a/b)');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Filter parsing error: invalid filter syntax - unknown matching rule used', $e->getMessage());
+ }
+
+ try {
+ $a = $conn->parse('(a=b)(c=d)');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Filter parsing error: invalid filter syntax - multiple leaf components detected!', $e->getMessage());
+ }
}
/**
$a->as_struct()
);
+ $a = $conn->search(null, '(|(a=1)(b=2))', array('attributes' => array('a', 'b')));
+ $this->assertEquals(
+ array(
+ 'cn=a' => array(
+ 'a' => '1',
+ 'b' => '1',
+ 'dn' => 'cn=a',
+ ),
+ 'cn=b' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'dn' => 'cn=b',
+ ),
+ 'cn=c' => array(
+ 'a' => '1',
+ 'b' => '2',
+ 'dn' => 'cn=c',
+ ),
+ 'cn=d' => array(
+ 'a' => '2',
+ 'b' => '2',
+ 'dn' => 'cn=d',
+ )
+ ),
+ $a->as_struct()
+ );
+
$a = $conn->search(null, '(&(b=2))', array('attributes' => array('b')));
$this->assertEquals(
array(
),
$a->as_struct()
);
+
+ $a = $conn->search(null, '(c=t)', array('attributes' => array('a')));
+ $this->assertEquals(
+ array(),
+ $a->as_struct()
+ );
+
+ try {
+ $a = $conn->search(null, '(c>t)', array('attributes' => array('a')));
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Not implemented!', $e->getMessage());
+ }
+ }
+
+ public function testMethodBindHasPostconditionThatBindingOccursWithDefaultDnAndPwIfSpecified()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array('binddn' => 'test', 'bindpw' => 'test'),
+ array()
+ );
+ try {
+ $conn->bind('', '');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('User does not exist!', $e->getMessage());
+ }
+ }
+
+ public function testMethodBindThrowsExceptionIfTheUserDoesNotExist()
+ {
+ $this->testMethodBindHasPostconditionThatBindingOccursWithDefaultDnAndPwIfSpecified();
+ }
+
+ public function testMethodBindThrowsExceptionIfTheUserHasNoPassword()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array('binddn' => 'test', 'bindpw' => 'test'),
+ array('test' =>
+ array('data' =>
+ array()
+ )
+ )
+ );
+ try {
+ $conn->bind('', '');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('User has no password entry!', $e->getMessage());
+ }
+ }
+
+ public function testMethodBindThrowsExceptionIfThePasswordWasIncorrect()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array('binddn' => 'test', 'bindpw' => 'test'),
+ array('test' =>
+ array('data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ )
+ )
+ );
+ try {
+ $conn->bind('', '');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Incorrect password!', $e->getMessage());
+ }
+ }
+
+ public function testMethodBindThrowsExceptionIfAnonymousLoginIsDisabledAndTheDnIsUnset()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array('no_anonymous_bind' => true),
+ array()
+ );
+ try {
+ $conn->bind('', '');
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Anonymous bind is not allowed!', $e->getMessage());
+ }
+ }
+
+ public function testMethodSearchHasResultMocksearchSingleElementIfNoFilterIsSetAndSearchScopeIsBase()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array('test' =>
+ array('dn' => 'test',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ ),
+ 'testnot' =>
+ array('dn' => 'test',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ )
+ )
+ );
+ $conn->bind('', '');
+ $result = $conn->search('test', null, array('scope' => 'base'));
+ $this->assertEquals(
+ array('test' => array(
+ 'userPassword' => array('something'),
+ 'dn' => 'test'
+ )
+ ),
+ $result->as_struct()
+ );
+ }
+
+ public function testMethodSearchHasResultMocksearchEmptyIfNoFilterIsSetSearchScopeIsBaseAndTheSpecifiedBaseDoesNotExist()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array()
+ );
+ $conn->bind('', '');
+ $result = $conn->search('test', null, array('scope' => 'base'));
+ $this->assertEquals(
+ array(),
+ $result->as_struct()
+ );
+ }
+
+ public function testMethodSearchHasResultMocksearchSingleElementIfNoFilterIsSetSearchScopeIsSubAndOnlyOneElementMatchesBase()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array('test' =>
+ array('dn' => 'test',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ ),
+ 'testnot' =>
+ array('dn' => 'test',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ )
+ )
+ );
+ $conn->bind('', '');
+ $result = $conn->search('test', null, array('scope' => 'sub'));
+ $this->assertEquals(
+ array('test' => array(
+ 'userPassword' => array('something'),
+ 'dn' => 'test'
+ )
+ ),
+ $result->as_struct()
+ );
+ }
+
+ public function testMethodSearchHasResultMocksearchWithMatchingElementsIfNoSearchScopeIsSet()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array('test' =>
+ array('dn' => 'test',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ ),
+ 'yestest' =>
+ array('dn' => 'yestest',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ ),
+ 'testnot' =>
+ array('dn' => 'testnot',
+ 'data' =>
+ array(
+ 'userPassword' => array('something')
+ )
+ )
+ )
+ );
+ $conn->bind('', '');
+ $result = $conn->search('test');
+ $this->assertEquals(
+ array('test', 'yestest'),
+ array_keys($result->as_struct())
+ );
+ }
+
+ public function testMethodSearchHasResultMocksearchWithSelectedAttributesIfSpecificAttributesWereSet()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array('test' =>
+ array('dn' => 'test',
+ 'data' =>
+ array(
+ 'userPassword' => array('something'),
+ 'name' => array('name1')
+ )
+ ),
+ 'yestest' =>
+ array('dn' => 'yestest',
+ 'data' =>
+ array(
+ 'userPassword' => array('something'),
+ 'name' => array('name2')
+ )
+ ),
+ 'testnot' =>
+ array('dn' => 'testnot',
+ 'data' =>
+ array(
+ 'userPassword' => array('something'),
+ 'name' => array('name2')
+ )
+ )
+ )
+ );
+ $conn->bind('', '');
+ $result = $conn->search('test', null, array('attributes' => 'name'));
+ $this->assertEquals(
+ array(
+ 'test' => array(
+ 'name' => array('name1'),
+ 'dn' => 'test'
+ ),
+ 'yestest' => array(
+ 'name' => array('name2'),
+ 'dn' => 'yestest'
+ ),
+ ),
+ $result->as_struct()
+ );
+ }
+
+ public function testMethodSearchThrowsExceptionIfSearchScopeIsOne()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array()
+ );
+ $conn->bind('', '');
+ try {
+ $result = $conn->search('test', null, array('scope' => 'one'));
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Not implemented!', $e->getMessage());
+ }
+ }
+
+ public function testMethodSearchThrowsExceptionIfTheConnectionIsNotBound()
+ {
+ $conn = new Horde_Kolab_Server_Connection_Mock_Ldap(
+ array(),
+ array()
+ );
+ try {
+ $conn->search();
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals('Unbound connection!', $e->getMessage());
+ }
}
}
--- /dev/null
+<?php
+/**
+ * Test the count decorator server 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the count decorator server 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_Decorator_CountTest
+extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->factory = $this->getMock(
+ 'Horde_Kolab_Server_Factory_Interface'
+ );
+ }
+
+ public function testMethodGetserverHasResultCountedServer()
+ {
+ $this->factory->expects($this->once())
+ ->method('getServer')
+ ->will(
+ $this->returnValue(
+ $this->getMock(
+ 'Horde_Kolab_Server_Interface'
+ )
+ )
+ );
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $this->assertType('Horde_Kolab_Server_Decorator_Count', $factory->getServer());
+ }
+
+ public function testMethodConstructHasParametersFactoryAndMixedLoggerParameter()
+ {
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ }
+
+ public function testMethodGetconnectionfactoryHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getConnectionFactory');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getConnectionFactory();
+ }
+
+ public function testMethodGetserverHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getServer')
+ ->will(
+ $this->returnValue(
+ $this->getMock(
+ 'Horde_Kolab_Server_Interface'
+ )
+ )
+ );
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getServer();
+ }
+
+ public function testMethodGetconfigurationHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getConfiguration');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getConfiguration();
+ }
+
+ public function testMethodGetconnectionHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getConnection');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getConnection();
+ }
+
+ public function testMethodGetcompositeHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getComposite');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getComposite();
+ }
+
+ public function testMethodGetobjectsHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getObjects');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getObjects();
+ }
+
+ public function testMethodGetstructureHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getStructure');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getStructure();
+ }
+
+ public function testMethodGetsearchHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getSearch');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getSearch();
+ }
+
+ public function testMethodGetschemaHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->factory->expects($this->once())
+ ->method('getSchema');
+ $factory = new Horde_Kolab_Server_Factory_Decorator_Count(
+ $this->factory, 'logger'
+ );
+ $factory->getSchema();
+ }
+}
\ No newline at end of file
{
public function setUp()
{
- $this->object = $this->getMock(
- 'Horde_Kolab_Server_Object_Interface'
+ $this->attribute = $this->getMock(
+ 'Horde_Kolab_Server_Structure_Attribute_Interface'
);
- $this->composite = $this->getMockedComposite();
}
- public function testMethodConstructHasParameterObjectTheObjectOwningTheAttributeAndParameterCompositeWhichIsTheLinkToTheServer()
+ public function testMethodConstructHasParameterAttributeTheAdapterCoveringTheInternalSideOfTheAttribute()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, '');
+ $attribute = new Attribute_Mock($this->attribute, '');
}
public function testMethodConstructHasParameterStringTheNameOfTheAttribute()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name');
}
- public function testMethodGetobjectReturnsObjectAssociatedWithThisAttribute()
+ public function testMethodGetattributeReturnsAttributeInteralAssociatedWithThisAttribute()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, '');
+ $attribute = new Attribute_Mock($this->attribute, '');
$this->assertType(
- 'Horde_Kolab_Server_Object_Interface',
- $attribute->getObject()
+ 'Horde_Kolab_Server_Structure_Attribute_Interface',
+ $attribute->getAttribute()
);
}
public function testMethodGetnameReturnsStringTheNameOfTheAttribute()
{
- $this->composite->structure->expects($this->exactly(1))
- ->method('mapExternalToInternalAttribute')
- ->with('name')
- ->will($this->returnValue('name'));
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
- $this->assertEquals('name', $attribute->getInternalName());
+ $attribute = new Attribute_Mock($this->attribute, 'name');
+ $this->assertEquals('name', $attribute->getName());
}
public function testMethodIsemptyHasParameterArrayDataValues()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name');
$attribute->isEmpty(array());
}
public function testMethodIsemptyReturnsFalseIfTheValueIndicatedByTheAttributeNameIsNotEmptyInTheDataArray()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name', 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name', 'name');
$this->assertFalse($attribute->isEmpty(array('name' => 'HELLO')));
}
public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsMissingInTheDataArray()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name');
$this->assertTrue($attribute->isEmpty(array()));
}
public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsStringEmptyInTheDataArray()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name');
$this->assertTrue($attribute->isEmpty(array('name' => '')));
}
public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsNullInTheDataArray()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name');
$this->assertTrue($attribute->isEmpty(array('name' => null)));
}
public function testMethodIsemptyReturnsTrueIfTheValueIndicatedByTheAttributeNameIsEmptyArrayInTheDataArray()
{
- $attribute = new Attribute_Mock($this->object, $this->composite, 'name');
+ $attribute = new Attribute_Mock($this->attribute, 'name');
$this->assertTrue($attribute->isEmpty(array('name' => array())));
}
}
{
public function value() {}
public function update(array $changes) {}
- public function consume(array &$changes) {}
}
\ No newline at end of file
$object = new Object_Mock($composite, 'guid');
}
- public function testGetguidHasResultStringGuidTheObjectIdOnTheServer()
+ public function testMethodGetguidHasResultStringGuidTheObjectIdOnTheServer()
{
$composite = $this->getComposite();
$object = new Object_Mock($composite, 'guid');
$this->assertEquals('guid', $object->getGuid());
}
- public function testGetguidThrowsExceptionIfGuidHasNotBeenSetYet()
+ public function testMethodGetguidThrowsExceptionIfGuidHasNotBeenSetYet()
{
$composite = $this->getComposite();
$object = new Object_Mock($composite);
}
}
- public function testGetexternalattributesHasResultArrayTheExternalAttributesSupportedByTheObject()
+ public function testMethodGetexternalattributesHasResultArrayTheExternalAttributesSupportedByTheObject()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getExternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('external')));
$this->assertEquals(array('external'), $object->getExternalAttributes());
}
- public function testGetinternalattributesHasResultArrayTheInternalAttributesSupportedByTheObject()
+ public function testMethodGetinternalattributesHasResultArrayTheInternalAttributesSupportedByTheObject()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('internal' => 'Internal')));
$this->assertEquals(array('internal' => 'Internal'), $object->getInternalAttributes());
}
- public function testGetinternalattributesHasResultBooleanFalseIfTheGuidIsNotSpecified()
+ public function testMethodExistsHasResultBooleanFalseIfTheGuidIsNotSpecified()
{
$composite = $this->getMockedComposite();
$object = new Object_Mock($composite);
$this->assertFalse($object->exists());
}
- public function testGetinternalattributesHasResultBooleanFalseIfTheServerReturnedAnError()
+ public function testMethodExistsHasResultBooleanFalseIfTheServerReturnedAnError()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('internal' => 'Internal')));
$this->assertFalse($object->exists());
}
- public function testGetinternalattributesHasResultBooleanTrueIfTheServerReturnedData()
+ public function testMethodExistsHasResultBooleanTrueIfTheServerReturnedData()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('internal' => 'Internal')));
$this->assertTrue($object->exists());
}
- public function testReadinternalHasResultArrayDataTheInternalObjectData()
+ public function testMethodReadinternalHasResultArrayDataTheInternalObjectData()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('internal' => 'Internal')));
);
}
- public function testGetinternalHasResultArrayTheDataOfTheRequestedAttribute()
+ public function testMethodGetinternalHasResultArrayTheDataOfTheRequestedAttribute()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->exactly(2))
+ $composite->structure->expects($this->exactly(1))
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('internal' => 'Internal')));
->will($this->returnValue(array('internal' => array('test'))));
$object = new Object_Mock($composite, 'guid');
$this->assertEquals(
- array('test'), $object->getInternal('internal')
+ array('internal' => array('test')), $object->getInternal(array('internal'))
);
}
- public function testGetinternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
+ public function testMethodGetinternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('internal' => 'Internal')));
$object = new Object_Mock($composite, 'guid');
try {
- $object->getInternal('test');
+ $object->getInternal(array('test'));
$this->fail('No exception!');
} catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Attribute "test" not supported!', $e->getMessage());
+ $this->assertEquals('No value for attribute "test"!', $e->getMessage());
}
}
- public function testGetinternalThrowsExceptionIfTheRequestedAttributeHasNoValue()
+ public function testMethodGetinternalThrowsExceptionIfTheRequestedAttributeHasNoValue()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->exactly(2))
+ $composite->structure->expects($this->exactly(1))
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will(
->will($this->returnValue(array('internal' => array('test'))));
$object = new Object_Mock($composite, 'guid');
try {
- $object->getInternal('test');
+ $object->getInternal(array('test'));
$this->fail('No exception!');
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
$this->assertEquals('No value for attribute "test"!', $e->getMessage());
}
}
- public function testGetexternalHasResultArrayTheDataOfTheRequestedAttribute()
+ public function testMethodGetexternalHasResultArrayTheDataOfTheRequestedAttribute()
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->exactly(1))
- ->method('mapExternalToInternalAttribute')
- ->with('Objectclass')
- ->will($this->returnValue('objectClass'));
- $composite->schema->expects($this->exactly(1))
->method('getExternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
- ->will($this->returnValue(array('Objectclass')));
- $composite->schema->expects($this->exactly(2))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
- ->will($this->returnValue(array('objectClass' => 'Objectclass')));
- $composite->server->expects($this->once())
- ->method('readAttributes')
- ->with('guid', array('objectClass'))
- ->will($this->returnValue(array('objectClass' => array('test'))));
+ ->will($this->returnValue(array('objectClass')));
+ $external = $this->getMock('Horde_Kolab_Server_Object_Attribute_Interface');
+ $external->expects($this->once())
+ ->method('value')
+ ->will($this->returnValue(array('test')));
+ $composite->structure->expects($this->exactly(1))
+ ->method('getExternalAttribute')
+ ->with('objectClass')
+ ->will(
+ $this->returnValue(
+ $external
+ )
+ );
$object = new Object_Mock($composite, 'guid');
$this->assertEquals(
- array('test'), $object->getExternal('Objectclass')
+ array('test'), $object->getExternal('objectClass')
);
}
- public function testGetexternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
+ public function testMethodGetexternalThrowsExceptionIfTheRequestedAttributeIsNotSupported()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
+ $composite->structure->expects($this->once())
->method('getExternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will($this->returnValue(array('external')));
$object->getExternal('test');
$this->fail('No exception!');
} catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Attribute "Test" not supported!', $e->getMessage());
- }
- }
-
- public function testGetexternalThrowsExceptionIfTheRequestedClassDoesNotExist()
- {
- $composite = $this->getMockedComposite();
- $composite->schema->expects($this->once())
- ->method('getExternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
- ->will($this->returnValue(array('Test')));
- $object = new Object_Mock($composite, 'guid');
- try {
- $object->getExternal('test');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals('Attribute "Test" not supported!', $e->getMessage());
+ $this->assertEquals('Attribute "test" not supported!', $e->getMessage());
}
}
- public function testDeleteHasPostconditionThatTheObjectWasDeletedOnTheServer()
+ public function testMethodDeleteHasPostconditionThatTheObjectWasDeletedOnTheServer()
{
$composite = $this->getMockedComposite();
$composite->server->expects($this->once())
$object->delete();
}
- public function testSaveHasParameterArrayTheDataToSave()
+ public function testMethodSaveHasParameterArrayTheDataToSave()
{
$composite = $this->getMockedComposite();
- $composite->schema->expects($this->exactly(3))
+ $composite->structure->expects($this->exactly(1))
->method('getInternalAttributes')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
->will(
)
)
);
- $composite->server->expects($this->exactly(2))
+ $composite->server->expects($this->exactly(1))
->method('readAttributes')
->with('guid', array('objectClass'))
->will($this->returnValue(array('objectClass' => array('test'))));
$object->save(array());
}
- public function testSaveHasPostconditionThatTheObjectWasAddedToTheServerIfItDidNotExistBefore()
+ public function testMethodSaveHasPostconditionThatTheObjectWasAddedToTheServerIfItDidNotExistBefore()
{
$composite = $this->getMockedComposite();
$composite->structure->expects($this->exactly(1))
- ->method('mapExternalToInternalAttribute')
- ->with('Objectclass')
- ->will($this->returnValue('objectClass'));
- $composite->schema->expects($this->exactly(1))
- ->method('getInternalAttributes')
- ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'))
+ ->method('generateServerGuid')
+ ->with(
+ 'Object_Mock', null,
+ array('objectClass' => array('top')))
->will(
$this->returnValue(
array(
)
)
);
+ $external = $this->getMock('Horde_Kolab_Server_Object_Attribute_Interface');
+ $external->expects($this->exactly(1))
+ ->method('update')
+ ->will($this->returnValue(array('objectClass' => array('top'))));
$composite->structure->expects($this->exactly(1))
- ->method('generateServerGuid')
- ->with(
- 'Object_Mock', null,
- array('objectClass' => array('top')))
+ ->method('getExternalAttribute')
+ ->with('objectClass')
->will(
$this->returnValue(
- array(
- 'objectClass' =>
- 'Horde_Kolab_Server_Object_Attribute_Objectclass'
- )
+ $external
)
);
$composite->server->expects($this->exactly(1))
->method('add')
->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'), array('objectClass' => array('top')));
$object = new Object_Mock($composite);
- $object->save(array('Objectclass' => 'top'));
+ $object->save(array('objectClass' => 'top'));
}
}
--- /dev/null
+<?php
+/**
+ * Test the mapped query element.
+ *
+ * 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 mapped query element.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Query_Element_MappedTest
+extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->element = $this->getMock(
+ 'Horde_Kolab_Server_Query_Element_Interface'
+ );
+ $this->mapper = $this->getMock(
+ 'Horde_Kolab_Server_Decorator_Map', array(), array(), '', false, false
+ );
+ }
+
+ public function testMethodConstructHasParameterElementTheDecoratedElement()
+ {
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ }
+
+ public function testMethodConstructHasParameterMapper()
+ {
+ $this->testMethodConstructHasParameterElementTheDecoratedElement();
+ }
+
+ public function testMethodGetnameHasResultStringTheMappedNameOfTheElement()
+ {
+ $this->element->expects($this->once())
+ ->method('getName')
+ ->will($this->returnValue('test'));
+ $this->mapper->expects($this->once())
+ ->method('mapField')
+ ->with('test')
+ ->will($this->returnValue('mapped'));
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $this->assertEquals('mapped', $element->getName());
+ }
+
+ public function testMethodGetvalueHasResultTheValueOfTheMappedElement()
+ {
+ $this->element->expects($this->once())
+ ->method('getValue')
+ ->will($this->returnValue('test'));
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $this->assertEquals('test', $element->getValue());
+ }
+
+ public function testMethodGetelementsHasResultArrayOfMappedElements()
+ {
+ $elements = array(
+ $this->getMock(
+ 'Horde_Kolab_Server_Query_Element_Interface'
+ ),
+ $this->getMock(
+ 'Horde_Kolab_Server_Query_Element_Interface'
+ ),
+ );
+ $this->element->expects($this->once())
+ ->method('getElements')
+ ->will($this->returnValue($elements));
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $elements = $element->getElements();
+ foreach ($elements as $element) {
+ $this->assertType(
+ 'Horde_Kolab_Server_Query_Element_Mapped', $element
+ );
+ }
+ }
+
+ public function testMethodConvertHasResultStringTheConvertedElement()
+ {
+ $this->element->expects($this->once())
+ ->method('convert')
+ ->will($this->returnValue('test'));
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $query = $this->getMock('Horde_Kolab_Server_Query_Interface');
+ $this->assertEquals('test', $element->convert($query));
+ }
+
+ public function testMethodGetnameHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->element->expects($this->once())
+ ->method('getName');
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $element->getName();
+ }
+
+ public function testMethodGetvalueHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->element->expects($this->once())
+ ->method('getValue');
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $element->getValue();
+ }
+
+ public function testMethodGetelementsHasPostconditionThatTheCallWasDelegated()
+ {
+ $elements = array();
+ $this->element->expects($this->once())
+ ->method('getElements')
+ ->will($this->returnValue($elements));
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $element->getElements();
+ }
+
+ public function testMethodConvertHasPostconditionThatTheCallWasDelegated()
+ {
+ $this->element->expects($this->once())
+ ->method('convert');
+ $element = new Horde_Kolab_Server_Query_Element_Mapped(
+ $this->element,
+ $this->mapper
+ );
+ $query = $this->getMock('Horde_Kolab_Server_Query_Interface');
+ $element->convert($query);
+ }
+}
$this->isInstanceOf(
'Horde_Kolab_Server_Query_Element_Interface'
),
- array('attributes' => 'Guid')
+ array('attributes' => 'guid')
)
->will($this->returnValue($result));
$search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
$this->isInstanceOf(
'Horde_Kolab_Server_Query_Element_Interface'
),
- array('attributes' => 'Guid')
+ array('attributes' => 'guid')
)
->will($this->returnValue($result));
$search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure);
--- /dev/null
+<?php
+/**
+ * Test the search operations restricted to Kolab users.
+ *
+ * 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 operations restricted to Kolab users.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Server
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Search_Operation_RestrictkolabTest
+extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface');
+ }
+
+ public function testMethodRestrictkolabHasResultRestrictedToKolabUsers()
+ {
+ $result = $this->getMock('Horde_Kolab_Server_Result_Interface');
+ $result->expects($this->once())
+ ->method('asArray')
+ ->will($this->returnValue(array('a' => 'a')));
+ $this->structure->expects($this->once())
+ ->method('find')
+ ->with(
+ $this->isRestrictedToKolabUsers(),
+ array('attributes' => 'guid')
+ )
+ ->will($this->returnValue($result));
+ $search = new Horde_Kolab_Server_Search_Operation_Restrictkolab($this->structure);
+ $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
+ $this->assertEquals(array('a'), $search->searchRestrictkolab($criteria));
+ }
+
+ public function isRestrictedToKolabUsers()
+ {
+ return new Constraint_RestrictedToKolabUsers();
+ }
+}
+
+class Constraint_RestrictedToKolabUsers extends PHPUnit_Framework_Constraint
+{
+ public function evaluate($other)
+ {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Interface) {
+ if ($other instanceOf Horde_Kolab_Server_Query_Element_Group) {
+ $elements = $other->getElements();
+ foreach ($elements as $element) {
+ if ($this->evaluate($element)) {
+ return true;
+ }
+ }
+ return true;
+ } else {
+ if ($other->getName() == 'objectClass'
+ && $other->getValue() == Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public function fail($other, $description, $not = FALSE)
+ {
+ throw new PHPUnit_Framework_ExpectationFailedException(
+ sprintf(
+ '%sFailed asserting that %s contains a query element that restricts the search to Kolab users',
+
+ !empty($description) ? $description . "\n" : '',
+ PHPUnit_Util_Type::toString($other, TRUE)
+ ),
+ NULL
+ );
+ }
+
+ public function toString()
+ {
+ return 'contains a query element that restricts the search to Kolab users';
+ }
+}
->method('find')
->with('(objectClass=equals)', array())
->will($this->returnValue($result));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('Objectclass', 'equals');
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('objectClass', 'equals');
$this->assertType(
'Horde_Kolab_Server_Result',
$this->composite->structure->find($equals, array())
->method('findBelow')
->with('(objectClass=equals)', 'base', array())
->will($this->returnValue($result));
- $equals = new Horde_Kolab_Server_Query_Element_Equals('Objectclass', 'equals');
+ $equals = new Horde_Kolab_Server_Query_Element_Equals('objectClass', 'equals');
$this->assertType(
'Horde_Kolab_Server_Result',
$this->composite->structure->findBelow($equals, 'base', array())
->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->mapExternalToInternalAttribute('undefined');
- $this->fail('No exception!');
- } catch (Horde_Kolab_Server_Exception $e) {
- $this->assertEquals(
- 'Undefined internal attribute "undefined"',
- $e->getMessage()
- );
- }
- }
-}
+}
\ No newline at end of file
/* Default inetOrgPerson */
array(
'type' => 'Horde_Kolab_Server_Object_Inetorgperson',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
+ 'givenName' => 'Frank',
'Sn' => 'Mustermann',
'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
),
/* Person with middle names */
array(
'type' => 'Horde_Kolab_Server_Object_Inetorgperson',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Günter Eloic',
+ 'givenName' => 'Frank',
+ 'Middlenames' => 'Günter Eloic',
'Sn' => 'Mustermann',
'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
),
{
foreach ($this->servers as $server) {
$person = $this->assertAdd($server, $this->objects[2],
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => $this->objects[2][Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME],
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => $this->objects[2][Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES]));
+ array('givenName' => $this->objects[2]['givenName'],
+ 'Middlenames' => $this->objects[2]['Middlenames']));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Kolab_Server_InetorgpersonTest_123$123',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Kolab_Server_InetorgpersonTest_123$123'),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Kolab_Server_InetorgpersonTest_123$123',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Kolab_Server_InetorgpersonTest_123$123'));
+ array('givenName' => 'Kolab_Server_InetorgpersonTest_123$123',
+ 'Middlenames' => 'Kolab_Server_InetorgpersonTest_123$123'),
+ array('givenName' => 'Kolab_Server_InetorgpersonTest_123$123',
+ 'Middlenames' => 'Kolab_Server_InetorgpersonTest_123$123'));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Kolab_Server_InetorgpersonTest_123$456',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => ''),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Kolab_Server_InetorgpersonTest_123$456',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => ''));
+ array('givenName' => 'Kolab_Server_InetorgpersonTest_123$456',
+ 'Middlenames' => ''),
+ array('givenName' => 'Kolab_Server_InetorgpersonTest_123$456',
+ 'Middlenames' => ''));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Kolab_Server_InetorgpersonTest_789'),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Kolab_Server_InetorgpersonTest_123$456',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Kolab_Server_InetorgpersonTest_789'));
+ array('Middlenames' => 'Kolab_Server_InetorgpersonTest_789'),
+ array('givenName' => 'Kolab_Server_InetorgpersonTest_123$456',
+ 'Middlenames' => 'Kolab_Server_InetorgpersonTest_789'));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => '',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => ''),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => '',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => ''));
+ array('givenName' => '',
+ 'Middlenames' => ''),
+ array('givenName' => '',
+ 'Middlenames' => ''));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Kolab_Server_InetorgpersonTest_789'),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => '',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => 'Kolab_Server_InetorgpersonTest_789'));
+ array('Middlenames' => 'Kolab_Server_InetorgpersonTest_789'),
+ array('givenName' => '',
+ 'Middlenames' => 'Kolab_Server_InetorgpersonTest_789'));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => ''),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
- Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MIDDLENAMES => ''));
+ array('givenName' => 'Frank',
+ 'Middlenames' => ''),
+ array('givenName' => 'Frank',
+ 'Middlenames' => ''));
}
}
{
foreach ($this->servers as $server) {
$person = $this->assertAdd($server, $this->objects[0],
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME => $this->objects[0][Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME],
- Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array()));
+ array('givenName' => $this->objects[0]['givenName'],
+ 'labelledURI' => array()));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array('a' => 'http://a.example.com',
+ array('labelledURI' => array('a' => 'http://a.example.com',
'b' => 'http://b.example.com')),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array('a' => array('http://a.example.com'),
+ array('labelledURI' => array('a' => array('http://a.example.com'),
'b' => array('http://b.example.com'))));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array('a' => 'http://a.example.com',
+ array('labelledURI' => array('a' => 'http://a.example.com',
'b' => 'http://b.example.com',
'c' => 'http://c.example.com')),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array('a' => array('http://a.example.com'),
+ array('labelledURI' => array('a' => array('http://a.example.com'),
'b' => array('http://b.example.com'),
'c' => array('http://c.example.com'))));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array()),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array()));
+ array('labelledURI' => array()),
+ array('labelledURI' => array()));
$this->assertStoreFetch($person, $server,
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array('a' => 'http://a.example.com')),
- array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => array('a' => array('http://a.example.com'))));
+ array('labelledURI' => array('a' => 'http://a.example.com')),
+ array('labelledURI' => array('a' => array('http://a.example.com'))));
}
}
/* Default bank account owner */
array(
'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
- Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
+ 'givenName' => 'Frank',
'Sn' => 'Mustermann',
'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
),
/* Default kolabInetOrgPerson */
array(
'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
- Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
+ 'givenName' => 'Frank',
'Sn' => 'Mustermann',
'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
),
/* Default bank account owner */
array(
'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
- Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME => 'Frank',
+ 'givenName' => 'Frank',
'Sn' => 'Mustermann',
'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
),
--- /dev/null
+<?php
+/**
+ * Test the "GuidForUidOrMail" search using the mock 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 "GuidForUidOrMail" search using the mock 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_Integration_SearchguidforuidormailTest
+extends Horde_Kolab_Server_LdapTestCase
+{
+ public function setUp()
+ {
+ $conf['basedn'] = 'dc=test';
+ $conf['mock'] = true;
+ $conf['data'] = array(
+ 'dn=user,dc=test' => array(
+ 'dn' => 'dn=user,dc=test',
+ 'data' => array(
+ 'uid' => array('user'),
+ 'mail' => array('user@example.org'),
+ 'objectClass' => array('top', 'kolabInetOrgPerson'),
+ )
+ )
+ );
+ $server_factory = new Horde_Kolab_Server_Factory_Configuration(
+ $conf
+ );
+
+ $this->composite = $server_factory->getComposite();
+ $this->composite->server->connectGuid();
+ }
+
+ public function testSearchingForUnknownUserReturnsEmptyGuid()
+ {
+ $this->composite->search->searchGuidForUidOrMail('unknown');
+ }
+
+ public function testSearchingForUserByMailReturnsTheGuid()
+ {
+ $this->assertEquals(
+ 'dn=user,dc=test',
+ $this->composite->search->searchGuidForUidOrMail('user@example.org')
+ );
+ }
+
+ public function testSearchingForUserByUidReturnsTheGuid()
+ {
+ $this->assertEquals(
+ 'dn=user,dc=test',
+ $this->composite->search->searchGuidForUidOrMail('user')
+ );
+ }
+}