Refactored the mock driver into a mock LDAP connection to adapt it to
authorGunnar Wrobel <p@rdus.de>
Thu, 22 Oct 2009 10:19:00 +0000 (12:19 +0200)
committerGunnar Wrobel <p@rdus.de>
Thu, 22 Oct 2009 10:19:00 +0000 (12:19 +0200)
the new structure. Fixed the server factory. Fixed some of the unit
tests.

67 files changed:
framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php [new file with mode: 0644]
framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/File.php [new file with mode: 0644]
framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php [new file with mode: 0644]
framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Search.php [new file with mode: 0644]
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/File.php [deleted file]
framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Mock.php [deleted file]
framework/Kolab_Server/lib/Horde/Kolab/Server/List/Base.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/Domainmaintainer.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabgroupofnames.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Person.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Top.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php
framework/Kolab_Server/package.xml
framework/Kolab_Server/test/Horde/Kolab/Server/Autoload.php
framework/Kolab_Server/test/Horde/Kolab/Server/Connection/MockTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/AddingObjectsTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/AdminTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/DistListHandlingTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/GroupHandlingTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/GroupTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/InetorgpersonTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/KolabgermanbankarrangementTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/KolabinetorgpersonTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/Kolabpop3accountTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/MockTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/ObjectTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/OrgPersonTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/PersonTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/Scenario.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/UserHandlingTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Integration/UserTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/LdapBase.php
framework/Kolab_Server/test/Horde/Kolab/Server/Object/AddingObjectsTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/AdminTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/DistListHandlingTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/GroupHandlingTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/GroupTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/InetorgpersonTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/KolabgermanbankarrangementTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/KolabinetorgpersonTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/Kolabpop3accountTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/ObjectTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/OrgPersonTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/PersonTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/UserHandlingTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Object/UserTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Objects/ServerTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Query/LdapTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/Result/LdapTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/Scenario.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Server/FactoryTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/Server/MockTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Server/ServerTest.php [deleted file]
framework/Kolab_Server/test/Horde/Kolab/Server/Structure/KolabTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/Structure/LdapTest.php

diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php
new file mode 100644 (file)
index 0000000..adb685f
--- /dev/null
@@ -0,0 +1,268 @@
+<?php
+/**
+ * A cleanup decoration for Kolab Servers that allows to remove all added
+ * objects.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * A cleanup decoration for Kolab Servers that allows to remove all added
+ * objects.
+ *
+ * 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_Cleaner implements Horde_Kolab_Server
+{
+    /**
+     * The server we delegate to.
+     *
+     * @var Horde_Kolab_Server
+     */
+    private $_server;
+
+    /**
+     * The objects added.
+     *
+     * @var array
+     */
+    private $_added = array();
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Kolab_Server $server The base server connection.
+     */
+    public function __construct(Horde_Kolab_Server $server)
+    {
+        $this->_server = $server;
+    }
+
+    /**
+     * Connect to the server.
+     *
+     * @param string $guid The global unique id of the user.
+     * @param string $pass The password.
+     *
+     * @return NULL.
+     *
+     * @throws Horde_Kolab_Server_Exception If the connection failed.
+     */
+    public function connectGuid($guid = null, $pass = null)
+    {
+        $this->_server->connectGuid($guid, $pass);
+    }
+
+    /**
+     * Get the current GUID
+     *
+     * @return string The GUID of the connected user.
+     */
+    public function getGuid()
+    {
+        $this->_server->getGuid();
+    }
+
+    /**
+     * Get the base GUID of this server
+     *
+     * @return string The base GUID of this server.
+     */
+    public function getBaseGuid()
+    {
+        $this->_server->getBaseGuid();
+    }
+
+    /**
+     * Low level access to reading object data.
+     *
+     * @param string $guid  The object to retrieve.
+     * @param array  $attrs Restrict to these attributes.
+     *
+     * @return array An array of attributes.
+     *
+     * @throws Horde_Kolab_Server_Exception If the search operation hit an error
+     *                                      or returned no result.
+     */
+    public function read($guid, array $attrs = array())
+    {
+        return $this->_server->read($guid);
+    }
+
+    /**
+     * Low level access to reading some object attributes.
+     *
+     * @param string $guid  The object to retrieve.
+     * @param string $attrs Restrict to these attributes.
+     *
+     * @return array An array of attributes.
+     *
+     * @throws Horde_Kolab_Server_Exception
+     *
+     * @see Horde_Kolab_Server::read
+     */
+    public function readAttributes($guid, array $attrs)
+    {
+        return $this->_server->readAttributes($guid, $attrs);
+    }
+
+    /**
+     * Finds object data matching a given set of criteria.
+     *
+     * @param Horde_Kolab_Server_Query_Element $criteria The criteria for the search.
+     * @param array                            $params   Additional search parameters.
+     *
+     * @return Horde_Kolab_Server_Result The result object.
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function find(
+        Horde_Kolab_Server_Query_Element $criteria,
+        array $params = array()
+    ) {
+        return $this->_server->find($criteria, $params);
+    }
+
+    /**
+     * Finds all object data below a parent matching a given set of criteria.
+     *
+     * @param Horde_Kolab_Server_Query_Element $criteria The criteria for the search.
+     * @param string                           $parent   The parent to search below.
+     * @param array                            $params   Additional search parameters.
+     *
+     * @return Horde_Kolab_Server_Result The result object.
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function findBelow(
+        Horde_Kolab_Server_Query_Element $criteria,
+        $parent,
+        array $params = array()
+    ) {
+        return $this->_server->findBelow($criteria, $parent, $params);
+    }
+
+    /**
+     * Modify existing object data.
+     *
+     * @param Horde_Kolab_Server_Object $object The object to be modified.
+     * @param array                     $data   The attributes of the object
+     *                                          to be stored.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function save(Horde_Kolab_Server_Object $object, array $data)
+    {
+        $this->_server->save($object, $data);
+    }
+
+    /**
+     * Add new object data.
+     *
+     * @param Horde_Kolab_Server_Object $object The object to be added.
+     * @param array                     $data   The attributes of the object
+     *                                          to be added.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function add(Horde_Kolab_Server_Object $object, array $data)
+    {
+        $this->_server->add($object, $data);
+        $this->_added[] = $object->getGuid();
+    }
+
+    /**
+     * Delete an object.
+     *
+     * @param string $guid The GUID of the object to be deleted.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function delete($guid)
+    {
+        $this->_server->delete($guid);
+        if (in_array($guid, $this->_added)) {
+            $this->_added = array_diff($this->_added, array($guid));
+        }
+    }
+
+    /**
+     * Rename an object.
+     *
+     * @param string $guid The GUID of the object to be renamed.
+     * @param string $new  The new GUID of the object.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function rename($guid, $new)
+    {
+        $this->_server->rename($guid, $new);
+    }
+
+    /**
+     * Return the ldap schema.
+     *
+     * @return Net_LDAP2_Schema The LDAP schema.
+     *
+     * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed.
+     */
+    public function getSchema()
+    {
+        return $this->_server->getSchema();
+    }
+
+    /**
+     * Get the parent GUID of this object.
+     *
+     * @param string $guid The GUID of the child.
+     *
+     * @return string the parent GUID of this object.
+     */
+    public function getParentGuid($guid)
+    {
+        return $this->_server->getParentGuid($guid);
+    }
+
+    /**
+     * Cleanup the server.
+     *
+     * @return NULL
+     */
+    public function cleanup()
+    {
+        foreach ($this->_added as $guid) {
+            $this->delete($guid);
+        }
+    }
+
+    /**
+     * Destructor.
+     */
+    public function __destruct()
+    {
+        $this->cleanup();
+    }
+}
index 058af25..caeda19 100644 (file)
@@ -98,12 +98,11 @@ class Horde_Kolab_Server_Composite
      *
      * @throws Horde_Kolab_Server_Exception If the connection failed.
      */
-    protected function _connect($user = null, $pass = null)
+    public function connect($user = null, $pass = null)
     {
         /** Bind anonymously first. */
-        $this->connectUid();
+        $this->server->connectGuid();
         $guid = $this->structure->getGuidForUser($user);
-        $this->connectUid($guid, $pass);
-        return $this->structure->getUserForUser($user);
+        $this->server->connectGuid($guid, $pass);
     }
 }
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/File.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/File.php
new file mode 100644 (file)
index 0000000..ba69a17
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+/**
+ * A persistent file-based driver for simulating a Kolab user database stored in
+ * LDAP.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * This class provides a persistant class for testing the Kolab Server DB.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_File extends Horde_Kolab_Server_Test
+{
+
+    /**
+     * The file for storing the database data.
+     *
+     * @var string
+     */
+    private $_file;
+
+    /**
+     * Set configuration parameters.
+     *
+     * @param array $params The parameters.
+     *
+     * @return NULL
+     */
+    public function setParams(array $params)
+    {
+        if (isset($params['file'])) {
+            $this->_file = $params['file'];
+        }
+
+        parent::setParams($params);
+    }
+
+    /**
+     * Get the file parameter.
+     *
+     * @return NULL
+     */
+    private function _getFile()
+    {
+        if (empty($this->_file)) {
+            throw new Horde_Kolab_Server_Exception('The file based driver requires a \'file\' parameter.');
+        }
+        return $this->_file;
+    }
+    
+    /**
+     * Load the current state of the database.
+     *
+     * @return NULL
+     */
+    protected function load()
+    {
+        $raw_data = file_get_contents($this->_getFile());
+        if (!$raw_data === false) {
+            $data = @unserialize($raw_data);
+            if ($data !== false) {
+                $this->data = $data;
+            } else {
+                $error = error_get_last();
+                if (isset($this->logger)) {
+                    $this->logger->warn(sprintf('Horde_Kolab_Server_file failed to read the database from %s. Error was: %s',
+                                                $this->_getFile(), $error['message']));
+                }
+                $this->data = array();
+            }
+        }
+    }
+
+    /**
+     * Store the current state of the database.
+     *
+     * @return NULL
+     */
+    protected function store()
+    {
+        $raw_data = serialize($this->data);
+        $result = @file_put_contents($this->_getFile(), $raw_data);
+        if ($result === false) {
+            $error = error_get_last();
+            if (isset($this->logger)) {
+                $this->logger->warn(sprintf('Horde_Kolab_Server_file failed to store the database in %s. Error was: %s',
+                                            $this->_getFile(),  $error['message']));
+            }
+        }
+    }
+
+    /**
+     * Cleans the current state of the database.
+     *
+     * @return NULL
+     */
+    public function clean()
+    {
+        unlink($this->_getFile());
+        $this->data = array();
+        $this->store();
+    }
+
+    /**
+     * Returns the path to the storage location of the database.
+     *
+     * @return string The path to the database.
+     */
+    public function getStoragePath()
+    {
+        return $this->_getFile();
+    }
+}
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php
new file mode 100644 (file)
index 0000000..3a1ecff
--- /dev/null
@@ -0,0 +1,693 @@
+<?php
+/**
+ * A driver for simulating a Kolab user database stored in LDAP.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * This class provides a class for testing the Kolab Server DB.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Connection_Mock
+implements Horde_Kolab_Server_Connection
+{
+
+    /**
+     * The current database data.
+     *
+     * @var array
+     */
+    protected $data = array();
+
+    /**
+     * Indicates if we are bound.
+     *
+     * @var array
+     */
+    protected $bound;
+
+    /**
+     * Array holding the current result set.
+     *
+     * @var array
+     */
+    private $_result;
+
+    /**
+     * Buffer for error numbers.
+     *
+     * @var int
+     */
+    private $_errno = 0;
+
+    /**
+     * Buffer for error descriptions.
+     *
+     * @var int
+     */
+    private $_error = '';
+
+    /**
+     * Attribute used for sorting.
+     *
+     * @var string
+     */
+    private $_sort_by;
+
+    /**
+     * A result cache for iterating over the result.
+     *
+     * @var array
+     */
+    private $_current_result;
+
+    /**
+     * An index into the current result for iterating.
+     *
+     * @var int
+     */
+    private $_current_index;
+
+    /**
+     * Set configuration parameters.
+     *
+     * @param array $params The parameters.
+     *
+     * @return NULL
+     */
+    public function __construct(array $params)
+    {
+        if (isset($params['data'])) {
+            $this->data = $params['data'];
+        }
+
+        if (isset($this->params['admin'])
+            && isset($this->params['admin']['type'])) {
+            $type = $this->params['admin']['type'];
+            $data = $this->params['admin'];
+            unset($data['type']);
+            $admin = new $type($this, null, $data);
+            if (!$admin->exists()) {
+                $admin->save();
+            }
+        }
+    }
+
+    /**
+     * Get the server read connection.
+     *
+     * @return mixed The connection for reading data.
+     */
+    public function getRead()
+    {
+        return $this;
+    }
+
+    /**
+     * Get the server write connection.
+     *
+     * @return mixed The connection for writing data.
+     */
+    public function getWrite()
+    {
+        return $this;
+    }
+
+    /**
+     * Binds the LDAP connection with a specific user and pass.
+     *
+     * @param string $dn DN to bind with
+     * @param string $pw Password associated to this DN.
+     *
+     * @return boolean Whether or not the binding succeeded.
+     *
+     * @throws Horde_Kolab_Server_Exception If the user does not exit, he has no
+     *                                      password, provided an incorrect
+     *                                      password or anonymous binding is not
+     *                                      allowed.
+     */
+    public function bind($dn = '', $pw = '')
+    {
+        if ($this->bound && empty($dn) && empty($pw)) {
+            return true;
+        }
+
+        if (!$dn) {
+            if (isset($this->params['uid'])) {
+                $dn = $this->params['uid'];
+            } else {
+                $dn = '';
+            }
+        }
+        if (!$pw) {
+            if (isset($this->params['pass'])) {
+                $pw = $this->params['pass'];
+            }
+        }
+
+        if (!empty($dn)) {
+            if (!isset($this->data[$dn])) {
+                throw new Horde_Kolab_Server_Exception('User does not exist!');
+            }
+
+            $this->bound = true;
+
+            try {
+                $data = $this->read($dn, array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD));
+            } catch (Horde_Kolab_Server_Exception $e) {
+                $this->bound = false;
+                throw $e;
+            }
+            if (!isset($data[Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD])) {
+                $this->bound = false;
+                throw new Horde_Kolab_Server_Exception('User has no password entry!');
+            }
+            $this->bound = $data['userPassword'][0] == $pw;
+            if (!$this->bound) {
+                throw new Horde_Kolab_Server_Exception('Incorrect password!');
+            }
+        } else if (!empty($this->params['no_anonymous_bind'])) {
+            $this->bound = false;
+            throw new Horde_Kolab_Server_Exception('Anonymous bind is not allowed!');
+        } else {
+            $this->bound = true;
+        }
+
+        if ($this->bound) {
+            $this->load();
+        }
+
+        return $this->bound;
+    }
+
+    /**
+    * Get a specific entry based on the DN
+    *
+    * @param string $dn   DN of the entry that should be fetched
+    * @param array  $attr Array of Attributes to select. If ommitted, all attributes are fetched.
+    *
+    * @return Net_LDAP2_Entry|Net_LDAP2_Error    Reference to a Net_LDAP2_Entry object or Net_LDAP2_Error object
+    * @todo Maybe check against the shema should be done to be sure the attribute type exists
+    */
+    public function getEntry($dn, $attr = array())
+    {
+        if (!is_array($attr)) {
+            $attr = array($attr);
+        }
+        $result = $this->search($dn, '(objectClass=*)',
+                                array('scope' => 'base', 'attributes' => $attr));
+        if ($result->count() == 0) {
+            throw new Horde_Kolab_Server_Exception('Could not fetch entry '.$dn.': no entry found');
+        }
+        $entry = $result->shiftEntry();
+        if (false == $entry) {
+            throw new Horde_Kolab_Server_Exception('Could not fetch entry (error retrieving entry from search result)');
+        }
+        return $entry;
+    }
+
+    /**
+     * Search for object data.
+     *
+     * @param string $base   The search base
+     * @param string $filter The LDAP search filter.
+     * @param string $params Additional search parameters.
+     *
+     * @return array The result array.
+     *
+     * @throws Horde_Kolab_Server_Exception If the search operation encountered
+     *                                      a problem.
+     */
+    public function search($base = null, $filter = null, $params = array())
+    {
+        $this->bind();
+
+        $filter = $this->parse($filter);
+        if (isset($params['attributes'])) {
+            $attributes = $params['attributes'];
+            if (!is_array($attributes)) {
+                $attributes = array($attributes);
+            }
+        } else {
+            $attributes = array();
+        }
+
+        $result = $this->doSearch($filter, $attributes);
+
+        if (empty($result)) {
+            $search = new Horde_Kolab_Server_Connection_Mock_Search(array());
+            return $search;
+        }
+
+        if (!empty($base)) {
+            $subtree = array();
+            foreach ($result as $entry) {
+                if (strpos($entry['dn'], $base)) {
+                    $subtree[] = $entry;
+                }
+            }
+            $result = $subtree;
+        }
+
+        $search = new Horde_Kolab_Server_Connection_Mock_Search($this->getEntries($result));
+        return $search;
+    }
+
+    /**
+     * Return the entries of a result.
+     *
+     * @param array $result The LDAP search result.
+     *
+     * @return mixed The entries of the result or false.
+     */
+    public function getEntries($result)
+    {
+        if (is_array($result)) {
+            $data = array();
+            foreach ($result as $entry) {
+                $t       = $entry['data'];
+                $t['dn'] = $entry['dn'];
+                $data[$entry['dn']]  = $t;
+            }
+            return $data;
+        }
+        return false;
+    }
+
+    /**
+     * Parse LDAP filter.
+     * Partially derived from Net_LDAP_Filter.
+     *
+     * @param string $filter The filter string.
+     *
+     * @return array An array of the parsed filter.
+     *
+     * @throws Horde_Kolab_Server_Exception If parsing the filter expression
+     *                                      fails.
+     */
+    public function parse($filter)
+    {
+        $result = array();
+        if (preg_match('/^\((.+?)\)$/', $filter, $matches)) {
+            if (in_array(substr($matches[1], 0, 1), array('!', '|', '&'))) {
+                $result['op']  = substr($matches[1], 0, 1);
+                $result['sub'] = $this->parseSub(substr($matches[1], 1));
+                return $result;
+            } else {
+                if (stristr($matches[1], ')(')) {
+                    throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - multiple leaf components detected!');
+                } else {
+                    $filter_parts = preg_split('/(?<!\\\\)(=|=~|>|<|>=|<=)/',
+                                               $matches[1], 2,
+                                               PREG_SPLIT_DELIM_CAPTURE);
+                    if (count($filter_parts) != 3) {
+                        throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - unknown matching rule used');
+                    } else {
+                        $result['att'] = $filter_parts[0];
+                        $result['log'] = $filter_parts[1];
+                        $val = Net_LDAP2_Util::unescape_filter_value($filter_parts[2]);
+                        $result['val'] = $val[0];
+                        return $result;
+                    }
+                }
+            }
+        } else {
+            throw new Horde_Kolab_Server_Exception(sprintf("Filter parsing error: %s - filter components must be enclosed in round brackets",
+                                                           $filter));
+        }
+    }
+
+    /**
+     * Parse a LDAP subfilter.
+     *
+     * @param string $filter The subfilter string.
+     *
+     * @return array An array of the parsed subfilter.
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function parseSub($filter)
+    {
+        $result  = array();
+        $level   = 0;
+        $collect = '';
+        while (preg_match('/^(\(.+?\))(.*)/', $filter, $matches)) {
+            if (in_array(substr($matches[1], 0, 2), array('(!', '(|', '(&'))) {
+                $level++;
+            }
+            if ($level) {
+                $collect .= $matches[1];
+                if (substr($matches[2], 0, 1) == ')') {
+                    $collect   .= ')';
+                    $matches[2] = substr($matches[2], 1);
+                    $level--;
+                    if (!$level) {
+                        $result[] = $this->parse($collect);
+                    }
+                }
+            } else {
+                $result[] = $this->parse($matches[1]);
+            }
+            $filter = $matches[2];
+        }
+        return $result;
+    }
+
+    /**
+     * Perform the search.
+     *
+     * @param array $filter     Filter criteria-
+     * @param array $attributes Restrict the search result to
+     *                          these attributes.
+     *
+     * @return array A LDAP serach result.
+     *
+     * @throws Horde_Kolab_Server_Exception If the search operation is not
+     *                                      available.
+     */
+    public function doSearch($filter, $attributes = null)
+    {
+        if (isset($filter['log'])) {
+            $result = array();
+            foreach ($this->data as $element) {
+                if (isset($element['data'][$filter['att']])) {
+                    switch ($filter['log']) {
+                    case '=':
+                        $value = $element['data'][$filter['att']];
+                        if (!empty($value) && is_array($value)) {
+                            $keys = array_keys($value);
+                            $first = $value[$keys[0]];
+                        } else {
+                            $first = $value;
+                        }
+                        if ((($filter['val'] == '*')
+                             && !empty($value))
+                            || $value == $filter['val']
+                            || (substr($filter['val'], 0, 1) == '*'
+                                && substr($filter['val'], strlen($filter['val']) - 1) == '*'
+                                && strpos($first, substr($filter['val'], 1, strlen($filter['val']) - 2)) !== false)
+                            || (is_array($value)
+                                && in_array($filter['val'], $value))) {
+                            if (empty($attributes)) {
+                                $result[] = $element;
+                            } else {
+                                $selection = $element;
+                                foreach ($element['data'] as $attr => $value) {
+                                    if (!in_array($attr, $attributes)) {
+                                        unset($selection['data'][$attr]);
+                                    }
+                                }
+                                $result[] = $selection;
+                            }
+                        }
+                        break;
+                    default:
+                        throw new Horde_Kolab_Server_Exception("Not implemented!");
+                    }
+                }
+            }
+            return $result;
+        } else {
+            $subresult   = array();
+            $filtercount = count($filter['sub']);
+            foreach ($filter['sub'] as $subfilter) {
+                $subresult = array_merge($subresult,
+                                         $this->doSearch($subfilter,
+                                                         $attributes));
+            }
+            $result = array();
+            $dns    = array();
+            foreach ($subresult as $element) {
+                $dns[] = $element['dn'];
+
+                $result[$element['dn']] = $element;
+            }
+            switch ($filter['op']) {
+            case '&':
+                $count     = array_count_values($dns);
+                $selection = array();
+                foreach ($count as $dn => $value) {
+                    if ($value == $filtercount) {
+                        $selection[] = $result[$dn];
+                    }
+                }
+                return $selection;
+            case '|':
+                return array_values($result);
+            case '!':
+                $dns = array();
+                foreach ($result as $entry) {
+                    if (!in_array($entry['dn'], $dns) ) {
+                        $dns[] = $entry['dn'];
+                    }
+                }
+                $all_dns = array_keys($this->data);
+                $diff    = array_diff($all_dns, $dns);
+
+                $result = array();
+                foreach ($diff as $dn) {
+                    if (empty($attributes)) {
+                        $result[] = $this->data[$dn];
+                    } else {
+                        $selection = $this->data[$dn];
+                        foreach ($this->data[$dn]['data']
+                                 as $attr => $value) {
+                            if (!in_array($attr, $attributes)) {
+                                unset($selection['data'][$attr]);
+                            }
+                        }
+                        $result[] = $selection;
+                    }
+                }
+                return $result;
+            default:
+                throw new Horde_Kolab_Server_Exception("Not implemented!");
+            }
+        }
+    }
+
+    /**
+    * Add a new entryobject to a directory.
+    *
+    * @param Net_LDAP2_Entry $entry Net_LDAP2_Entry
+    *
+    * @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
+    */
+    public function add($entry)
+    {
+        $this->bind();
+
+        $ldap_data = $this->toStorage($entry->getValues());
+
+        $guid = $entry->getDn();
+
+        $this->data[$guid] = array(
+            'dn' => $guid,
+            'data' => array_merge($ldap_data,
+                                  array('dn' => $guid)),
+        );
+
+        $this->store();
+    }
+
+    /**
+    * Modify an ldapentry directly on the server
+    *
+    * @param string|Net_LDAP2_Entry &$entry DN-string or Net_LDAP2_Entry
+    * @param array                 $parms  Array of changes
+    *
+    * @access public
+    * @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
+    */
+    public function modify($entry, $data = array())
+    {
+        $this->bind();
+
+        $guid = $entry->getDn();
+
+        if (isset($data['delete'])) {
+            foreach ($data['delete'] as $k => $v) {
+                if (is_int($k)) {
+                    if (isset($this->data[$guid]['data'][$w])) {
+                        /** Delete a complete attribute */
+                        unset($this->data[$guid]['data'][$w]);
+                    }
+                } else {
+                    if (isset($this->data[$guid]['data'][$l])) {
+                        if (!is_array($v)) {
+                            $v = array($v);
+                        }
+                        foreach ($v as $w) {
+                            $key = array_search($w, $this->data[$guid]['data'][$l]);
+                            if ($key !== false) {
+                                /** Delete a single value */
+                                unset($this->data[$guid]['data'][$l][$key]);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (isset($data['replace'])) {
+            $ldap_data = $this->toStorage($data['replace']);
+
+            $this->data[$guid] = array(
+                'dn' => $guid,
+                'data' => array_merge($this->data[$guid]['data'],
+                                      $ldap_data,
+                                      array('dn' => $guid)),
+            );
+        }
+
+        if (isset($data['add'])) {
+            $ldap_data = $this->toStorage($data['add']);
+
+            foreach ($ldap_data as $k => $v) {
+                if (is_array($v)) {
+                    foreach ($v as $w) {
+                        $this->data[$guid]['data'][$k][] = $w;
+                    }
+                } else {
+                    $this->data[$guid]['data'][$k][] = $v;
+                }
+                $this->data[$guid]['data'][$k] = array_values($this->data[$guid]['data'][$k]);
+            }
+        }
+
+        $this->store();
+    }
+
+    /**
+     * Delete an object.
+     *
+     * @param string $uid The UID of the object to be deleted.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function delete($uid)
+    {
+        if (isset($this->data[$uid])) {
+            unset($this->data[$uid]);
+        } else {
+            throw new Horde_Kolab_Server_MissingObjectException(sprintf("No such object: %s",
+                                                                        $uid));
+        }
+
+        $this->store();
+    }
+
+    /**
+     * Rename an object.
+     *
+     * @param string $uid The UID of the object to be renamed.
+     * @param string $new The new UID of the object.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function move($uid, $new)
+    {
+        if (isset($this->data[$uid])) {
+            $this->data[$new] = $this->data[$uid];
+            unset($this->data[$uid]);
+        }
+
+        $this->store();
+    }
+
+    public function schema()
+    {
+        //@todo: implement
+    }
+
+    /**
+     * Cleans the current state of the database.
+     *
+     * @return NULL
+     */
+    public function clean()
+    {
+        $this->unbind();
+
+        $GLOBALS['KOLAB_SERVER_TEST_DATA'] = array();
+
+        $this->data = array();
+    }
+
+    /**
+     * Disconnect from LDAP.
+     *
+     * @return NULL
+     */
+    public function unbind()
+    {
+        $this->bound = false;
+    }
+
+    /**
+     * Load the current state of the database.
+     *
+     * @return NULL
+     */
+    protected function load()
+    {
+        /**
+         * @todo: remove as it does not make much sense. The file based handler
+         * can do the same thing as a decorator.
+         */
+        if (isset($GLOBALS['KOLAB_SERVER_TEST_DATA'])) {
+            $this->data = $GLOBALS['KOLAB_SERVER_TEST_DATA'];
+        }
+    }
+
+    /**
+     * Store the current state of the database.
+     *
+     * @return NULL
+     */
+    protected function store()
+    {
+        $GLOBALS['KOLAB_SERVER_TEST_DATA'] = $this->data;
+    }
+
+
+    /**
+     * Rewrite a data array to our internal storage format.
+     *
+     * @param array   $data    The attributes of the object to be added/replaced.
+     *
+     * @return array  The transformed data set.
+     */
+    protected function toStorage($data)
+    {
+        $ldap_data = array();
+        foreach ($data as $key => $val) {
+            if (!is_array($val)) {
+                $val = array($val);
+            }
+            $ldap_data[$key] = $val;
+        }
+        return $ldap_data;
+    }
+}
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Search.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Search.php
new file mode 100644 (file)
index 0000000..d6a9a6c
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/**
+ * A mockup class to simulate LDAP search results.
+ *
+ * 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
+ */
+
+/**
+ * A mockup class to simulate LDAP search results.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Connection_Mock_Search
+extends Net_LDAP2_Search
+{
+    /**
+     * The search result.
+     *
+     * @var array
+     */
+    private $_result;
+
+    /**
+     * Constructor.
+     *
+     * @param array $result The search result.
+     */
+    public function __construct(array $result)
+    {
+        $this->_result = $result;
+    }
+
+    /**
+     * The number of result entries.
+     *
+     * @return int The number of elements.
+     */
+    public function count()
+    {
+        return count($this->_result);
+    }
+
+    /**
+     * Test if the last search exceeded the size limit.
+     *
+     * @return boolean True if the last search exceeded the size limit.
+     */
+    public function sizeLimitExceeded()
+    {
+        return false;
+    }
+
+    /**
+     * Return the result as an array.
+     *
+     * @return array The resulting array.
+     */
+    public function as_struct()
+    {
+        return $this->_result;
+    }
+
+}
index 2d02685..1a881c3 100644 (file)
@@ -43,34 +43,23 @@ class Horde_Kolab_Server_Factory
      *
      * @return NULL
      */
-    static public function setup(array $configuration, Horde_Injector $injector)
+    static public function setup(Horde_Injector $injector, array $configuration)
     {
         self::setupObjects($injector);
         self::setupSearch($injector);
         self::setupSchema($injector);
 
         self::setupStructure(
+            $injector,
             isset($configuration['structure'])
-            ? $configuration['structure'] : array(),
-            $injector
+            ? $configuration['structure'] : array()
         );
         unset($configuration['structure']);
 
-        self::setupCache(
-            $injector,
-            isset($configuration['cache'])
-            ? $configuration['cache'] : null
-        );
-        unset($configuration['cache']);
-
-        self::setupLogger(
-            $injector,
-            isset($configuration['logger'])
-            ? $configuration['logger'] : null
-        );
-        unset($configuration['logger']);
+        self::setupConfiguration($injector, $configuration);
 
-        self::setupServer($configuration, $injector);
+        self::setupServer($injector);
+        self::setupComposite($injector);
     }
 
     /**
@@ -99,8 +88,8 @@ class Horde_Kolab_Server_Factory
      * @return NULL
      */
     static protected function setupStructure(
-        array $configuration,
-        Horde_Injector $injector
+        Horde_Injector $injector,
+        array $configuration
     ) {
         if (!isset($configuration['driver'])) {
             $configuration['driver'] = 'Horde_Kolab_Server_Structure_Kolab';
@@ -151,112 +140,165 @@ class Horde_Kolab_Server_Factory
     }
 
     /**
-     * Provide a cache handler for Horde_Kolab_Server.
+     * Inject the server configuration.
      *
-     * @param Horde_Injector $injector The object providing our dependencies.
-     * @param mixed          $instance The cache handler or empty if it
-     *                                 should be created.
+     * @param Horde_Injector $injector      The object providing our dependencies.
+     * @param array          $configuration The parameters required to create
+     *                                      the desired Horde_Kolab_Server.
      *
      * @return NULL
      */
-    static protected function setupCache(
+    static protected function setupConfiguration(
         Horde_Injector $injector,
-        $instance = null
+        array $configuration
     ) {
-        if (empty($instance)) {
-            $instance = new Horde_Cache_Null();
-        }
-        $injector->setInstance('Horde_Kolab_Server_Cache', $instance);
+        $injector->setInstance('Horde_Kolab_Server_Config', $configuration);
     }
 
     /**
-     * Provide a log handler for Horde_Kolab_Server.
+     * Setup the machinery to create a Horde_Kolab_Server.
      *
-     * @param Horde_Injector $injector The object providing our dependencies.
-     * @param mixed          $instance The log handler or empty if it
-     *                                 should be created.
+     * @param array          $configuration The parameters required to create
+     *                                      the desired Horde_Kolab_Server.
+     * @param Horde_Injector $injector      The object providing our dependencies.
      *
      * @return NULL
      */
-    static protected function setupLogger(
-        Horde_Injector $injector,
-        $instance = null
-    ) {
-        if (empty($instance)) {
-            $instance = new Horde_Log_Logger(new Horde_Log_Handler_Null());
-        }
-        $injector->setInstance('Horde_Kolab_Server_Logger', $instance);
+    static protected function setupServer(Horde_Injector $injector) {
+        $injector->bindFactory(
+            'Horde_Kolab_Server',
+            'Horde_Kolab_Server_Factory',
+            'getServer'
+        );
     }
 
     /**
-     * Setup the machinery to create a Horde_Kolab_Server.
+     * Attempts to return a concrete Horde_Kolab_Server instance.
      *
-     * @param array          $configuration The parameters required to create
-     *                                      the desired Horde_Kolab_Server.
-     * @param Horde_Injector $injector      The object providing our dependencies.
+     * @param Horde_Injector $injector The object providing our dependencies.
      *
-     * @return NULL
+     * @return Horde_Kolab_Server The newly created concrete Horde_Kolab_Server
+     *                            instance.
      */
-    static protected function setupServer(
-        array $configuration,
-        Horde_Injector $injector
-    ) {
+    static public function getServer(Horde_Injector $injector)
+    {
+        $configuration = $injector->getInstance('Horde_Kolab_Server_Config');
+
         if (empty($configuration['driver'])) {
-            $configuration['driver'] = 'Horde_Kolab_Server_Ldap';
+            $configuration['driver'] = 'Ldap';
         }
-         
-        $config = new stdClass;
 
-        switch (ucfirst(strtolower($configuration['driver']))) {
+        if (isset($configuration['params'])) {
+            $params = $configuration['params'];
+        } else {
+            $params = $configuration;
+        }
+
+        $driver = ucfirst(strtolower($configuration['driver']));
+        switch ($driver) {
         case 'Ldap':
         case 'Test':
         case 'File':
-            $config->driver = 'Horde_Kolab_Server_'
-                . ucfirst(strtolower($configuration['driver']));
+            $server = self::getLdapServer($driver, $params);
             break;
         default:
-            $config->driver = $configuration['driver'];
-            break;
+            throw new Horde_Kolab_Server_Exception('Invalid server configuration!');
         }
 
-        $config->params = isset($configuration['params'])
-            ? $configuration['params'] : array();
-
-        $injector->setInstance('Horde_Kolab_Server_Config', $config);
+        if (isset($params['map'])) {
+            $server = new Horde_Kolab_Server_Mapped($server, $params['map']);
+        }
+        if (isset($configuration['logger'])) {
+            $server = new Horde_Kolab_Server_Logged($server, $configuration['logger']);
+        }
+        if (isset($configuration['cache'])) {
+            $server = new Horde_Kolab_Server_Cached($server, $configuration['cache']);
+        }
 
-        $injector->bindFactory(
-            'Horde_Kolab_Server',
-            'Horde_Kolab_Server_Factory',
-            'getServer'
-        );
+        return $server;
     }
 
     /**
-     * Attempts to return a concrete Horde_Kolab_Server instance.
+     * Attempts to return a concrete Horde_Kolab_Server_Ldap instance.
      *
-     * @param Horde_Injector $injector The object providing our dependencies.
+     * @param array $params LDAP connection parameters.
      *
-     * @return Horde_Kolab_Server The newly created concrete Horde_Kolab_Server
-     *                            instance.
+     * @return Horde_Kolab_Server_Ldap The newly created concrete
+     *                                 Horde_Kolab_Server_Ldap instance.
      */
-    static public function &getServer(Horde_Injector $injector)
+    static protected function getLdapServer($driver, array $params)
     {
-        $config = $injector->getInstance('Horde_Kolab_Server_Config');
-        $driver = $config->driver;
-        $server = new $driver(
-            $injector->getInstance('Horde_Kolab_Server_Objects'),
-            $injector->getInstance('Horde_Kolab_Server_Structure'),
-            $injector->getInstance('Horde_Kolab_Server_Search'),
-            $injector->getInstance('Horde_Kolab_Server_Schema')
-        );
-        $server->setParams($config->params);
-        $server->setCache($injector->getInstance('Horde_Kolab_Server_Cache'));
-        $server->setLogger($injector->getInstance('Horde_Kolab_Server_Logger'));
+        if (!isset($params['basedn'])) {
+            throw new Horde_Kolab_Server_Exception('The base DN is missing');
+        }
+
+        if (isset($params['server'])) {
+            $params['host'] = $params['server'];
+            unset($params['server']);
+        }
+
+        if (isset($params['phpdn'])) {
+            $params['binddn'] = $params['phpdn'];
+            unset($params['phpdn']);
+        }
+
+        if (isset($params['phppw'])) {
+            $params['bindpw'] = $params['phppw'];
+            unset($params['phppw']);
+        }
+
+        //@todo: Place this is a specific connection factory.
+        switch ($driver) {
+        case 'Ldap':
+            $ldap_read = new Net_LDAP2($params);
+            if (isset($params['host_master'])) {
+                $params['host'] = $params['host_master'];
+                $ldap_write = new Net_LDAP2($params);
+                $connection = new Horde_Kolab_Server_Connection_Splittedldap(
+                    $ldap_read, $ldap_write
+                );
+            } else {
+                $connection = new Horde_Kolab_Server_Connection_Simpleldap(
+                    $ldap_read
+                );
+            }
+            break;
+        case 'File':
+        case 'Test':
+            $connection = new Horde_Kolab_Server_Connection_Mock($params);
+            break;
+        }
 
+        if (!isset($params['filter'])) {
+            $server = new Horde_Kolab_Server_Ldap_Standard(
+                $connection,
+                $params['basedn']
+            );
+        } else {
+            $server = new Horde_Kolab_Server_Ldap_Filtered(
+                $connection,
+                $params['basedn'],
+                $params['filter']
+            );
+        }
         return $server;
     }
 
     /**
+     * Setup the machinery to create a Horde_Kolab_Server_Composite server.
+     *
+     * @param Horde_Injector $injector The object providing our dependencies.
+     *
+     * @return NULL
+     */
+    static protected function setupComposite(Horde_Injector $injector)
+    {
+        /**
+         * Nothing to do here for now as class and interface name are the same.
+         */
+    }
+
+    /**
      * Attempts to return a reference to a concrete Horde_Kolab_Server
      * instance based on $driver. It will only create a new instance
      * if no Horde_Kolab_Server instance with the same parameters currently
@@ -273,52 +315,32 @@ class Horde_Kolab_Server_Factory
      */
     static public function &singleton($params = array())
     {
-        $signature = hash('md5', serialize(ksort($params)));
+        global $conf;
 
+        if (empty($params) && isset($conf['kolab']['ldap'])) {
+            $params = $conf['kolab']['ldap'];
+        }
+
+        ksort($params);
+        $signature = hash('md5', serialize($params));
         if (!isset(self::$_instances[$signature])) {
-            $params['cache'] = Horde_Cache::singleton(
-                $GLOBALS['conf']['cache']['driver'],
-               //@todo: Can we omit Horde:: here?
-                Horde::getDriverConfig(
-                    'cache',
-                    $GLOBALS['conf']['cache']['driver']
-                )
-            );
+            /** @todo: The caching decorator is still missing.
+/*             $params['cache'] = Horde_Cache::singleton( */
+/*                 $GLOBALS['conf']['cache']['driver'], */
+/*                 //@todo: Can we omit Horde:: here? */
+/*                 Horde::getDriverConfig( */
+/*                     'cache', */
+/*                     $GLOBALS['conf']['cache']['driver'] */
+/*                 ) */
+/*             ); */
             $params['logger'] = Horde::getLogger();
             $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-            self::setup($params, $injector);
+            self::setup($injector, $params);
             self::$_instances[$signature] = $injector->getInstance(
                 'Horde_Kolab_Server'
             );
         }
 
-/*         if (empty($this->_ldap_read)) { */
-/*             $this->handleError( */
-/*                 Net_LDAP2::checkLDAPExtension(), */
-/*                 Horde_Kolab_Server_Exception::MISSING_LDAP_EXTENSION */
-/*             ); */
-
-/*             $this->_ldap_read = new Net_LDAP2($this->params); */
-
-/*             if (isset($this->params['host_master']) */
-/*                 && $this->params['host_master'] == $this->params['host'] */
-/*             ) { */
-
-/*                 $params         = $this->params; */
-/*                 $params['host'] = $this->params['host_master']; */
-
-/*                 $this->_ldap_write = new Net_LDAP2($params); */
-/*             } else { */
-/*                 $this->_ldap_write = $this->_ldap_read; */
-/*             } */
-/*         } */
-
-/*         if ($write) { */
-/*             return $this->_ldap_write; */
-/*         } else { */
-/*             return $this->_ldap_read; */
-/*         } */
-
         return self::$_instances[$signature];
     }
 }
\ No newline at end of file
index 0e76479..cf5d786 100644 (file)
@@ -59,11 +59,15 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server
      */
     public function __construct(
         Horde_Kolab_Server_Connection $connection,
-        $base_dn,
-        $filter = null
+        $base_dn
     ) {
         $this->_conn    = $connection;
         $this->_base_dn = $base_dn;
+
+        $this->_handleError(
+            Net_LDAP2::checkLDAPExtension(),
+            Horde_Kolab_Server_Exception::MISSING_LDAP_EXTENSION
+        );
     }
 
     /**
@@ -190,11 +194,11 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server
      */
     public function save(Horde_Kolab_Server_Object $object, array $data)
     {
+        $changes = new Horde_Kolab_Server_Ldap_Changes($object, $data);
         $entry  = $this->_conn->getWrite()->getEntry(
             $object->getGuid(), array_keys($data)
         );
         $this->_handleError($entry, Horde_Kolab_Server_Exception::SYSTEM);
-        $changes = new Horde_Kolab_Server_Ldap_Changes($object, $data);
         $this->_handleError(
             $this->_conn->getWrite()->modify($entry, $changes->getChangeset()),
             Horde_Kolab_Server_Exception::SYSTEM
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/File.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/File.php
deleted file mode 100644 (file)
index ba69a17..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * A persistent file-based driver for simulating a Kolab user database stored in
- * LDAP.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * This class provides a persistant class for testing the Kolab Server DB.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_File extends Horde_Kolab_Server_Test
-{
-
-    /**
-     * The file for storing the database data.
-     *
-     * @var string
-     */
-    private $_file;
-
-    /**
-     * Set configuration parameters.
-     *
-     * @param array $params The parameters.
-     *
-     * @return NULL
-     */
-    public function setParams(array $params)
-    {
-        if (isset($params['file'])) {
-            $this->_file = $params['file'];
-        }
-
-        parent::setParams($params);
-    }
-
-    /**
-     * Get the file parameter.
-     *
-     * @return NULL
-     */
-    private function _getFile()
-    {
-        if (empty($this->_file)) {
-            throw new Horde_Kolab_Server_Exception('The file based driver requires a \'file\' parameter.');
-        }
-        return $this->_file;
-    }
-    
-    /**
-     * Load the current state of the database.
-     *
-     * @return NULL
-     */
-    protected function load()
-    {
-        $raw_data = file_get_contents($this->_getFile());
-        if (!$raw_data === false) {
-            $data = @unserialize($raw_data);
-            if ($data !== false) {
-                $this->data = $data;
-            } else {
-                $error = error_get_last();
-                if (isset($this->logger)) {
-                    $this->logger->warn(sprintf('Horde_Kolab_Server_file failed to read the database from %s. Error was: %s',
-                                                $this->_getFile(), $error['message']));
-                }
-                $this->data = array();
-            }
-        }
-    }
-
-    /**
-     * Store the current state of the database.
-     *
-     * @return NULL
-     */
-    protected function store()
-    {
-        $raw_data = serialize($this->data);
-        $result = @file_put_contents($this->_getFile(), $raw_data);
-        if ($result === false) {
-            $error = error_get_last();
-            if (isset($this->logger)) {
-                $this->logger->warn(sprintf('Horde_Kolab_Server_file failed to store the database in %s. Error was: %s',
-                                            $this->_getFile(),  $error['message']));
-            }
-        }
-    }
-
-    /**
-     * Cleans the current state of the database.
-     *
-     * @return NULL
-     */
-    public function clean()
-    {
-        unlink($this->_getFile());
-        $this->data = array();
-        $this->store();
-    }
-
-    /**
-     * Returns the path to the storage location of the database.
-     *
-     * @return string The path to the database.
-     */
-    public function getStoragePath()
-    {
-        return $this->_getFile();
-    }
-}
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Mock.php
deleted file mode 100644 (file)
index ddcbc32..0000000
+++ /dev/null
@@ -1,877 +0,0 @@
-<?php
-/**
- * A driver for simulating a Kolab user database stored in LDAP.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * This class provides a class for testing the Kolab Server DB.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Ldap_Mock extends Horde_Kolab_Server_Ldap_Standard
-{
-
-    /**
-     * The current database data.
-     *
-     * @var array
-     */
-    protected $data;
-
-    /**
-     * Indicates if we are bound.
-     *
-     * @var array
-     */
-    protected $bound;
-
-    /**
-     * Array holding the current result set.
-     *
-     * @var array
-     */
-    private $_result;
-
-    /**
-     * Buffer for error numbers.
-     *
-     * @var int
-     */
-    private $_errno = 0;
-
-    /**
-     * Buffer for error descriptions.
-     *
-     * @var int
-     */
-    private $_error = '';
-
-    /**
-     * Attribute used for sorting.
-     *
-     * @var string
-     */
-    private $_sort_by;
-
-    /**
-     * A result cache for iterating over the result.
-     *
-     * @var array
-     */
-    private $_current_result;
-
-    /**
-     * An index into the current result for iterating.
-     *
-     * @var int
-     */
-    private $_current_index;
-
-    /**
-     * Set configuration parameters.
-     *
-     * @param array $params The parameters.
-     *
-     * @return NULL
-     */
-    public function setParams(array $params)
-    {
-        //@todo Load when connecting
-        //$this->load();
-
-        if (isset($params['data'])) {
-            $this->data = $params['data'];
-        } else {
-            if (!isset($this->data)) {
-               $this->data  = array();
-            }
-        }
-
-        if (isset($this->params['admin'])
-            && isset($this->params['admin']['type'])) {
-            $type = $this->params['admin']['type'];
-            $data = $this->params['admin'];
-            unset($data['type']);
-            $admin = new $type($this, null, $data);
-            if (!$admin->exists()) {
-                $admin->save();
-            }
-        }
-
-        //@todo Load when connecting
-        //$this->store();
-
-        parent::setParams($params);
-    }
-
-    /**
-     * Connect to the LDAP server.
-     *
-     * @param string $uid  The unique id of the user.
-     * @param string $pass The password.
-     *
-     * @return NULL.
-     *
-     * @throws Horde_Kolab_Server_Exception If the connection failed.
-     */
-    protected function _connectUid($uid = null, $pass = null)
-    {
-        //@todo
-    }
-
-    /**
-     * Load the current state of the database.
-     *
-     * @return NULL
-     */
-    protected function load()
-    {
-        //@todo: remove the global
-        if (isset($GLOBALS['KOLAB_SERVER_TEST_DATA'])) {
-            $this->data = $GLOBALS['KOLAB_SERVER_TEST_DATA'];
-        } else {
-            $this->data = array();
-        }
-    }
-
-    /**
-     * Store the current state of the database.
-     *
-     * @return NULL
-     */
-    protected function store()
-    {
-        $GLOBALS['KOLAB_SERVER_TEST_DATA'] = $this->data;
-    }
-
-    /**
-     * Cleans the current state of the database.
-     *
-     * @return NULL
-     */
-    public function clean()
-    {
-        $this->unbind();
-
-        $GLOBALS['KOLAB_SERVER_TEST_DATA'] = array();
-
-        $this->data = array();
-    }
-
-    /**
-     * Binds the LDAP connection with a specific user and pass.
-     *
-     * @param string $dn DN to bind with
-     * @param string $pw Password associated to this DN.
-     *
-     * @return boolean Whether or not the binding succeeded.
-     *
-     * @throws Horde_Kolab_Server_Exception If the user does not exit, he has no
-     *                                      password, provided an incorrect
-     *                                      password or anonymous binding is not
-     *                                      allowed.
-     */
-    protected function bind($dn = false, $pw = '')
-    {
-        if (!$dn) {
-            if (isset($this->params['uid'])) {
-                $dn = $this->params['uid'];
-            } else {
-                $dn = '';
-            }
-        }
-        if (!$pw) {
-            if (isset($this->params['pass'])) {
-                $pw = $this->params['pass'];
-            }
-        }
-
-        if (!empty($dn)) {
-            if (!isset($this->data[$dn])) {
-                throw new Horde_Kolab_Server_Exception('User does not exist!');
-            }
-
-            $this->bound = true;
-
-            try {
-                $data = $this->read($dn, array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD));
-            } catch (Horde_Kolab_Server_Exception $e) {
-                $this->bound = false;
-                throw $e;
-            }
-            if (!isset($data[Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD])) {
-                $this->bound = false;
-                throw new Horde_Kolab_Server_Exception('User has no password entry!');
-            }
-            $this->bound = $data['userPassword'][0] == $pw;
-            if (!$this->bound) {
-                throw new Horde_Kolab_Server_Exception('Incorrect password!');
-            }
-        } else if (!empty($this->params['no_anonymous_bind'])) {
-            $this->bound = false;
-            throw new Horde_Kolab_Server_Exception('Anonymous bind is not allowed!');
-        } else {
-            $this->bound = true;
-        }
-        return $this->bound;
-    }
-
-    /**
-     * Disconnect from LDAP.
-     *
-     * @return NULL
-     */
-    public function unbind()
-    {
-        $this->bound = false;
-    }
-
-    /**
-     * Parse LDAP filter.
-     * Partially derived from Net_LDAP_Filter.
-     *
-     * @param string $filter The filter string.
-     *
-     * @return array An array of the parsed filter.
-     *
-     * @throws Horde_Kolab_Server_Exception If parsing the filter expression
-     *                                      fails.
-     */
-    public function parse($filter)
-    {
-        $result = array();
-        if (preg_match('/^\((.+?)\)$/', $filter, $matches)) {
-            if (in_array(substr($matches[1], 0, 1), array('!', '|', '&'))) {
-                $result['op']  = substr($matches[1], 0, 1);
-                $result['sub'] = $this->parseSub(substr($matches[1], 1));
-                return $result;
-            } else {
-                if (stristr($matches[1], ')(')) {
-                    throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - multiple leaf components detected!');
-                } else {
-                    $filter_parts = preg_split('/(?<!\\\\)(=|=~|>|<|>=|<=)/',
-                                               $matches[1], 2,
-                                               PREG_SPLIT_DELIM_CAPTURE);
-                    if (count($filter_parts) != 3) {
-                        throw new Horde_Kolab_Server_Exception('Filter parsing error: invalid filter syntax - unknown matching rule used');
-                    } else {
-                        $result['att'] = $filter_parts[0];
-                        $result['log'] = $filter_parts[1];
-                        $val = Net_LDAP2_Util::unescape_filter_value($filter_parts[2]);
-                        $result['val'] = $val[0];
-                        return $result;
-                    }
-                }
-            }
-        } else {
-            throw new Horde_Kolab_Server_Exception(sprintf("Filter parsing error: %s - filter components must be enclosed in round brackets",
-                                                           $filter));
-        }
-    }
-
-    /**
-     * Parse a LDAP subfilter.
-     *
-     * @param string $filter The subfilter string.
-     *
-     * @return array An array of the parsed subfilter.
-     *
-     * @throws Horde_Kolab_Server_Exception
-     */
-    public function parseSub($filter)
-    {
-        $result  = array();
-        $level   = 0;
-        $collect = '';
-        while (preg_match('/^(\(.+?\))(.*)/', $filter, $matches)) {
-            if (in_array(substr($matches[1], 0, 2), array('(!', '(|', '(&'))) {
-                $level++;
-            }
-            if ($level) {
-                $collect .= $matches[1];
-                if (substr($matches[2], 0, 1) == ')') {
-                    $collect   .= ')';
-                    $matches[2] = substr($matches[2], 1);
-                    $level--;
-                    if (!$level) {
-                        $result[] = $this->parse($collect);
-                    }
-                }
-            } else {
-                $result[] = $this->parse($matches[1]);
-            }
-            $filter = $matches[2];
-        }
-        return $result;
-    }
-
-    /**
-     * Search for object data.
-     *
-     * @param string $filter The LDAP search filter.
-     * @param string $params Additional search parameters.
-     * @param string $base   The search base
-     *
-     * @return array The result array.
-     *
-     * @throws Horde_Kolab_Server_Exception If the search operation encountered
-     *                                      a problem.
-     */
-    public function search($filter = null, $params = array(), $base = null)
-    {
-        if (!$this->bound) {
-            $result = $this->bind();
-        }
-
-        $filter = $this->parse($filter);
-        if (isset($params['attributes'])) {
-            $attributes = $params['attributes'];
-            if (!is_array($attributes)) {
-                $attributes = array($attributes);
-            }
-            $this->mapKeys($attributes);
-        } else {
-            $attributes = array();
-        }
-        $result = $this->doSearch($filter, $attributes);
-        if (empty($result)) {
-            return array();
-        }
-        if ($base) {
-            $subtree = array();
-            foreach ($result as $entry) {
-                if (strpos($entry['dn'], $base)) {
-                    $subtree[] = $entry;
-                }
-            }
-            $result = $subtree;
-        }
-
-        $this->unmapAttributes($result);
-
-        return $this->getEntries($result);
-    }
-
-    /**
-     * Perform the search.
-     *
-     * @param array $filter     Filter criteria-
-     * @param array $attributes Restrict the search result to
-     *                          these attributes.
-     *
-     * @return array A LDAP serach result.
-     *
-     * @throws Horde_Kolab_Server_Exception If the search operation is not
-     *                                      available.
-     */
-    protected function doSearch($filter, $attributes = null)
-    {
-        if (isset($filter['log'])) {
-            $result = array();
-            foreach ($this->data as $element) {
-                if (isset($element['data'][$filter['att']])) {
-                    switch ($filter['log']) {
-                    case '=':
-                        $value = $element['data'][$filter['att']];
-                        if (!empty($value) && is_array($value)) {
-                            $keys = array_keys($value);
-                            $first = $value[$keys[0]];
-                        } else {
-                            $first = $value;
-                        }
-                        if ((($filter['val'] == '*')
-                             && !empty($value))
-                            || $value == $filter['val']
-                            || (substr($filter['val'], 0, 1) == '*'
-                                && substr($filter['val'], strlen($filter['val']) - 1) == '*'
-                                && strpos($first, substr($filter['val'], 1, strlen($filter['val']) - 2)) !== false)
-                            || (is_array($value)
-                                && in_array($filter['val'], $value))) {
-                            if (empty($attributes)) {
-                                $result[] = $element;
-                            } else {
-                                $selection = $element;
-                                foreach ($element['data'] as $attr => $value) {
-                                    if (!in_array($attr, $attributes)) {
-                                        unset($selection['data'][$attr]);
-                                    }
-                                }
-                                $result[] = $selection;
-                            }
-                        }
-                        break;
-                    default:
-                        throw new Horde_Kolab_Server_Exception("Not implemented!");
-                    }
-                }
-            }
-            return $result;
-        } else {
-            $subresult   = array();
-            $filtercount = count($filter['sub']);
-            foreach ($filter['sub'] as $subfilter) {
-                $subresult = array_merge($subresult,
-                                         $this->doSearch($subfilter,
-                                                         $attributes));
-            }
-            $result = array();
-            $dns    = array();
-            foreach ($subresult as $element) {
-                $dns[] = $element['dn'];
-
-                $result[$element['dn']] = $element;
-            }
-            switch ($filter['op']) {
-            case '&':
-                $count     = array_count_values($dns);
-                $selection = array();
-                foreach ($count as $dn => $value) {
-                    if ($value == $filtercount) {
-                        $selection[] = $result[$dn];
-                    }
-                }
-                return $selection;
-            case '|':
-                return array_values($result);
-            case '!':
-                $dns = array();
-                foreach ($result as $entry) {
-                    if (!in_array($entry['dn'], $dns) ) {
-                        $dns[] = $entry['dn'];
-                    }
-                }
-                $all_dns = array_keys($this->data);
-                $diff    = array_diff($all_dns, $dns);
-
-                $result = array();
-                foreach ($diff as $dn) {
-                    if (empty($attributes)) {
-                        $result[] = $this->data[$dn];
-                    } else {
-                        $selection = $this->data[$dn];
-                        foreach ($this->data[$dn]['data']
-                                 as $attr => $value) {
-                            if (!in_array($attr, $attributes)) {
-                                unset($selection['data'][$attr]);
-                            }
-                        }
-                        $result[] = $selection;
-                    }
-                }
-                return $result;
-            default:
-                throw new Horde_Kolab_Server_Exception("Not implemented!");
-            }
-        }
-    }
-
-    /**
-     * Read object data.
-     *
-     * @param string $dn    The object to retrieve.
-     * @param string $attrs Restrict to these attributes
-     *
-     * @return array An array of attributes.
-     *
-     * @throws Horde_Kolab_Server_Exception If the object does not exist.
-     */
-    public function read($uid, array $attrs = array())
-    {
-        if (!$this->bound) {
-            $result = $this->bind();
-        }
-
-        if (!isset($this->data[$dn])) {
-            throw new Horde_Kolab_Server_MissingObjectException(sprintf("No such object: %s",
-                                                                        $dn));
-        }
-        if (empty($attrs)) {
-            $data = $this->data[$dn]['data'];
-            $this->unmapAttributes($data);
-            return $data;
-        } else {
-            $this->mapKeys($attrs);
-
-            $result = array();
-            $data   = $this->data[$dn]['data'];
-
-            foreach ($attrs as $attr) {
-                if (isset($data[$attr])) {
-                    $result[$attr] = $data[$attr];
-                }
-            }
-
-            $this->unmapAttributes($result);
-
-            return $result;
-        }
-    }
-
-    /**
-     * Save an object.
-     *
-     * @param string  $uid     The UID of the object to be added.
-     * @param array   $data    The attributes of the object to be added/replaced.
-     * @param boolean $exists  Does the object already exist on the server?
-     *
-     * @return NULL
-     */
-    public function save($uid, array $data, $exists = false)
-    {
-        if (!$this->bound) {
-            $result = $this->bind();
-        }
-
-        if ($exists === false) {
-
-            $ldap_data = $this->_toStorage($data['add']);
-
-            $this->data[$uid] = array(
-                'dn' => $uid,
-                'data' => array_merge($ldap_data,
-                                      array('dn' => $uid)),
-            );
-        } else {
-
-            if (isset($data['delete'])) {
-                foreach ($data['delete'] as $k => $v) {
-                    if (is_int($k)) {
-                        $w = $this->mapField($v);
-                        if (isset($this->data[$uid]['data'][$w])) {
-                            /** Delete a complete attribute */
-                            unset($this->data[$uid]['data'][$w]);
-                        }
-                    } else {
-                        $l = $this->mapField($k);
-                        if (isset($this->data[$uid]['data'][$l])) {
-                            if (!is_array($v)) {
-                                $v = array($v);
-                            }
-                            foreach ($v as $w) {
-                                $key = array_search($w, $this->data[$uid]['data'][$l]);
-                                if ($key !== false) {
-                                    /** Delete a single value */
-                                    unset($this->data[$uid]['data'][$l][$key]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (isset($data['replace'])) {
-                $ldap_data = $this->_toStorage($data['replace']);
-
-                $this->data[$uid] = array(
-                    'dn' => $uid,
-                    'data' => array_merge($this->data[$uid]['data'],
-                                          $ldap_data,
-                                          array('dn' => $uid)),
-                );
-            }
-
-            if (isset($data['add'])) {
-                $ldap_data = $this->_toStorage($data['add']);
-
-                foreach ($ldap_data as $k => $v) {
-                    if (is_array($v)) {
-                        foreach ($v as $w) {
-                            $this->data[$uid]['data'][$k][] = $w;
-                        }
-                    } else {
-                        $this->data[$uid]['data'][$k][] = $v;
-                    }
-                    $this->data[$uid]['data'][$k] = array_values($this->data[$uid]['data'][$k]);
-                }
-            }
-        }
-
-        $this->store();
-
-        if (isset($this->logger)) {
-            $this->logger->debug(sprintf('The object \"%s\" has been successfully saved!',
-                                         $uid));
-        }
-    }
-
-    /**
-     * Rewrite a data array to our internal storage format.
-     *
-     * @param array   $data    The attributes of the object to be added/replaced.
-     *
-     * @return array  The transformed data set.
-     */
-    private function _toStorage($data)
-    {
-        $this->mapAttributes($data);
-
-        $ldap_data = array();
-        foreach ($data as $key => $val) {
-            if (!is_array($val)) {
-                $val = array($val);
-            }
-            $ldap_data[$key] = $val;
-        }
-        return $ldap_data;
-    }
-
-    /**
-     * Delete an object.
-     *
-     * @param string $uid The UID of the object to be deleted.
-     *
-     * @return NULL
-     *
-     * @throws Horde_Kolab_Server_Exception
-     */
-    public function delete($uid)
-    {
-        if (isset($this->data[$uid])) {
-            unset($this->data[$uid]);
-        } else {
-            throw new Horde_Kolab_Server_MissingObjectException(sprintf("No such object: %s",
-                                                                        $uid));
-        }
-        $this->store();
-        if (isset($this->logger)) {
-            $this->logger->debug(sprintf('The object \"%s\" has been successfully deleted!',
-                                         $uid));
-        }
-    }
-
-    /**
-     * Rename an object.
-     *
-     * @param string $uid The UID of the object to be renamed.
-     * @param string $new The new UID of the object.
-     *
-     * @return NULL
-     *
-     * @throws Horde_Kolab_Server_Exception
-     */
-    public function rename($uid, $new)
-    {
-        if (isset($this->data[$uid])) {
-            $this->data[$new] = $this->data[$uid];
-            unset($this->data[$uid]);
-        }
-        $this->store();
-        if (isset($this->logger)) {
-            $this->logger->debug(sprintf('The object \"%s\" has been successfully renamed to \"%s\"!',
-                                         $uid, $new));
-        }
-    }
-
-    /**
-     * Return the schema for the given objectClass.
-     *
-     * @param string $objectclass Fetch the schema for this objectClass.
-     *
-     * @return array The schema for the given objectClass.
-     *
-     * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed.
-     */
-    public function getObjectclassSchema($objectclass)
-    {
-        return array();
-    }
-
-    /**
-     * Return the schema for the given attribute.
-     *
-     * @param string $attribute Fetch the schema for this attribute.
-     *
-     * @return array The schema for the given attribute.
-     *
-     * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed.
-     */
-    public function getAttributeSchema($attribute)
-    {
-        return array();
-    }
-
-    /**
-     * Return the current entry of a result.
-     *
-     * @return mixe  The current entry of the result or false.
-     */
-    protected function fetchEntry()
-    {
-        if (is_array($this->_current_result)
-            && $this->_current_index < count($this->_current_result)) {
-
-            $data = array_keys($this->_current_result[$this->_current_index]['data']);
-
-            $data['dn'] = array($this->_current_result[$this->_current_index]['dn']);
-
-            foreach ($this->_current_result[$this->_current_index]['data']
-                     as $attr => $value) {
-                if (!is_array($value)) {
-                    $value = array($value);
-                }
-                $data[$attr] = $value;
-            }
-            $this->_current_index++;
-            return $data;
-        }
-        return false;
-    }
-
-    /**
-     * Return the first entry of a result.
-     *
-     * @param array $result The LDAP search result.
-     *
-     * @return mixed The first entry of the result or false.
-     */
-    protected function firstEntry($result)
-    {
-        $this->_current_result = $result;
-        $this->_current_index  = 0;
-        return $this->fetchEntry();
-    }
-
-    /**
-     * Return the next entry of a result.
-     *
-     * @param resource $entry The current LDAP entry.
-     *
-     * @return resource The next entry of the result.
-     */
-    protected function nextEntry($entry)
-    {
-        return $this->fetchEntry();
-    }
-
-    /**
-     * Return the entries of a result.
-     *
-     * @param array $result The LDAP search result.
-     *
-     * @return mixed The entries of the result or false.
-     */
-    protected function getEntries($result)
-    {
-        if (is_array($result)) {
-            $data = array();
-            foreach ($result as $entry) {
-                $t       = $entry['data'];
-                $t['dn'] = $entry['dn'];
-                $data[$entry['dn']]  = $t;
-            }
-            return $data;
-        }
-        return false;
-    }
-
-    /**
-     * Sort the entries of a result.
-     *
-     * @param resource &$result   The LDAP search result.
-     * @param string   $attribute The attribute used for sorting.
-     *
-     * @return boolean  True if sorting succeeded.
-     */
-    public function sort(&$result, $attribute)
-    {
-        if (empty($result)) {
-            return $result;
-        }
-
-        $this->_sort_by = $attribute;
-        usort($result, array($this, 'resultSort'));
-        return false;
-    }
-
-    /**
-     * Sort two entries.
-     *
-     * @param array $a First entry.
-     * @param array $b Second entry.
-     *
-     * @return int  Comparison result.
-     */
-    protected function resultSort($a, $b)
-    {
-        $x = isset($a['data'][$this->_sort_by][0])?$a['data'][$this->_sort_by][0]:'';
-        $y = isset($b['data'][$this->_sort_by][0])?$b['data'][$this->_sort_by][0]:'';
-        return strcasecmp($x, $y);
-    }
-
-
-    /**
-     * Return the current LDAP error number.
-     *
-     * @return int  The current LDAP error number.
-     */
-    protected function errno()
-    {
-        return $this->_errno;
-    }
-
-    /**
-     * Return the current LDAP error description.
-     *
-     * @return string  The current LDAP error description.
-     */
-    protected function error()
-    {
-        return $this->_error;
-    }
-
-    /**
-     * Identify the DN of the first result entry.
-     *
-     * @todo Check if this could be reintegrated with the code in the LDAP handler
-     *       again.
-     *
-     * @param array $result   The LDAP search result.
-     * @param int   $restrict A Horde_Kolab_Server::RESULT_* result restriction.
-     *
-     * @return boolean|string|array The DN(s) or false if there was no result.
-     *
-     * @throws Horde_Kolab_Server_Exception If the number of results did not
-     *                                      meet the expectations.
-     */
-    protected function dnFromResult($result,
-                                    $restrict = Horde_Kolab_Server::RESULT_SINGLE)
-    {
-        if (empty($result)) {
-            return false;
-        }
-        $dns = array();
-        foreach ($result as $entry) {
-            $dns[] = $entry['dn'];
-        }
-
-        switch ($restrict) {
-        case self::RESULT_STRICT:
-            if (count($dns) > 1) {
-                throw new Horde_Kolab_Server_Exception(sprintf("Found %s results when expecting only one!",
-                                                               $count));
-            }
-        case self::RESULT_SINGLE:
-            return $dns[0];
-        case self::RESULT_MANY:
-            return $dns;
-        }
-    }
-
-}
index 2c57856..e70abd2 100644 (file)
@@ -64,7 +64,7 @@ class Horde_Kolab_Server_List_Base implements Horde_Kolab_Server_List
         }
 
         if ($sort) {
-            /* FIXME */
+            /* @todo: sorting */
             /* $data = $result->as_sorted_struct(); */
             /*$this->sort($result, $sort); */
         }
index fdd194b..1644b88 100644 (file)
@@ -45,12 +45,11 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server
      * Constructor.
      *
      * @param Horde_Kolab_Server $server The base server connection.
-     * @param Horde_Log_Logger   $logger THe log handler.
+     * @param mixed              $logger The log handler. The class must at
+     *                                   least provide the info() method.
      */
-    public function __construct(
-        Horde_Kolab_Server $server,
-        Horde_Log_Logger $logger
-    ) {
+    public function __construct(Horde_Kolab_Server $server, $logger)
+    {
         $this->_server = $server;
         $this->_logger = $logger;
     }
@@ -67,7 +66,22 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server
      */
     public function connectGuid($guid = null, $pass = null)
     {
-        $this->_server->connectGuid($guid, $pass);
+        try {
+            $this->_server->connectGuid($guid, $pass);
+            $this->_logger->info(
+                sprintf(
+                    "Successfully connected to the Kolab Server as \"%s\".",
+                    $guid
+                )
+            );
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->_logger->info(
+                sprintf(
+                    "Failed saving object \"%s\"! Error: %s",
+                    $object->getGuid(), $e->getMessage()
+                )
+            );
+        }
     }
 
     /**
@@ -172,13 +186,23 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server
      */
     public function save(Horde_Kolab_Server_Object $object, array $data)
     {
-        $this->_server->save($object, $data);
-        $this->_logger->info(
-            sprintf(
-                "The object \"%s\" has been successfully saved!",
-                $object->getGuid()
-            )
-        );
+        try {
+            $this->_server->save($object, $data);
+            $this->_logger->info(
+                sprintf(
+                    "The object \"%s\" has been successfully saved!",
+                    $object->getGuid()
+                )
+            );
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->_logger->info(
+                sprintf(
+                    "Failed saving object \"%s\"! Error: %s",
+                    $object->getGuid(), $e->getMessage()
+                )
+            );
+
+        }
     }
 
     /**
@@ -194,13 +218,23 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server
      */
     public function add(Horde_Kolab_Server_Object $object, array $data)
     {
-        $this->_server->add($object, $data);
-        $this->_logger->info(
-            sprintf(
-                "The object \"%s\" has been successfully added!",
-                $object->getGuid()
-            )
-        );
+        try {
+            $this->_server->add($object, $data);
+            $this->_logger->info(
+                sprintf(
+                    "The object \"%s\" has been successfully added!",
+                    $object->getGuid()
+                )
+            );
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->_logger->info(
+                sprintf(
+                    "Failed adding object \"%s\"! Error: %s",
+                    $object->getGuid(), $e->getMessage()
+                )
+            );
+
+        }
     }
 
     /**
@@ -214,10 +248,21 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server
      */
     public function delete($guid)
     {
-        $this->_server->delete($guid);
-        $this->_logger->info(
-            sprintf("The object \"%s\" has been successfully deleted!", $guid)
-        );
+        try {
+            $this->_server->delete($guid);
+            $this->_logger->info(
+                sprintf("The object \"%s\" has been successfully deleted!", $guid)
+            );
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->_logger->info(
+                sprintf(
+                    "Failed deleting object \"%s\"! Error: %s",
+                    $object->getGuid(), $e->getMessage()
+                )
+            );
+
+        }
+
     }
 
     /**
@@ -232,13 +277,23 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server
      */
     public function rename($guid, $new)
     {
-        $this->_server->rename($guid, $new);
-        $this->_logger->info(
-            sprintf(
-                "The object \"%s\" has been successfully renamed to \"%s\"!",
-                $guid, $new
-            )
-        );
+        try {
+            $this->_server->rename($guid, $new);
+            $this->_logger->info(
+                sprintf(
+                    "The object \"%s\" has been successfully renamed to \"%s\"!",
+                    $guid, $new
+                )
+            );
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->_logger->info(
+                sprintf(
+                    "Failed saving object \"%s\"! Error: %s",
+                    $object->getGuid(), $e->getMessage()
+                )
+            );
+
+        }
     }
 
     /**
index 456653e..2bdc92a 100644 (file)
@@ -153,8 +153,10 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server
      *
      * @throws Horde_Kolab_Server_Exception
      */
-    public function find(array $criteria, array $params = array())
-    {
+    public function find(
+        Horde_Kolab_Server_Query_Element $criteria,
+        array $params = array()
+    ) {
         $criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this);
         $data = $this->_server->find($criteria, $params);
         $this->unmapAttributes($data);
@@ -172,8 +174,11 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server
      *
      * @throws Horde_Kolab_Server_Exception
      */
-    public function findBelow(array $criteria, $parent, array $params = array())
-    {
+    public function findBelow(
+        Horde_Kolab_Server_Query_Element $criteria,
+        $parent,
+        array $params = array()
+    ) {
         $criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this);
         $data = $this->_server->findBelow($criteria, $parent, $params);
         $this->unmapAttributes($data);
@@ -191,10 +196,12 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server
      *
      * @throws Horde_Kolab_Server_Exception
      */
-    public function save($guid, array $data)
+    public function save(Horde_Kolab_Server_Object $object, array $data)
     {
+        //@todo: This will not work this way as we need to map internal
+        // attributes.
         $this->mapAttributes($data);
-        $this->_server->save($guid, $data);
+        $this->_server->save($object, $data);
     }
 
     /**
@@ -207,10 +214,12 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server
      *
      * @throws Horde_Kolab_Server_Exception
      */
-    public function add($guid, array $data)
+    public function add(Horde_Kolab_Server_Object $object, array $data)
     {
+        //@todo: This will not work this way as we need to map internal
+        // attributes.
         $this->mapAttributes($data);
-        $this->_server->add($guid, $data);
+        $this->_server->add($object, $data);
     }
 
     /**
@@ -326,4 +335,16 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server
         }
         return $field;
     }
+
+    /**
+     * Get the parent GUID of this object.
+     *
+     * @param string $guid The GUID of the child.
+     *
+     * @return string the parent GUID of this object.
+     */
+    public function getParentGuid($guid)
+    {
+        return $this->_server->getParentGuid($guid);
+    }
 }
index 93248fb..bd13a29 100644 (file)
@@ -109,13 +109,6 @@ interface Horde_Kolab_Server_Object
     public function delete();
 
     /**
-     * Returns the set of actions supported by this object type.
-     *
-     * @return array An array of supported actions.
-     */
-    public function getActions();
-
-    /**
      * Generates an ID for the given information.
      *
      * @param array &$info The data of the object.
@@ -135,4 +128,11 @@ interface Horde_Kolab_Server_Object
      */
     public function prepareObjectInformation(array &$info);
 
+    /**
+     * Returns the set of actions supported by this object type.
+     *
+     * @return array An array of supported actions.
+     */
+    public function getActions();
+
 }
index e56315e..17e6d14 100644 (file)
@@ -159,6 +159,7 @@ implements Horde_Kolab_Server_Object
         $class = 'Horde_Kolab_Server_Object_Attribute_' . $attr;
         if (!in_array($attr, $this->getExternalAttributes())
             || !class_exists($class)) {
+            //@todo: Consider support for external classes.
             throw new Horde_Kolab_Server_Exception(
                 sprintf("Attribute \"%s\" not supported!", $attr)
             );
index 588478a..ad68cde 100644 (file)
@@ -127,7 +127,7 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T
     {
         $members = $this->getMembers();
         if (in_array($member, $members)) {
-            //FIXME: As the member attribute is required we may not remove the last member
+            //@todo: As the member attribute is required we may not remove the last member
             $this->_cache[self::ATTRIBUTE_MEMBER] =
                 array_diff($this->_cache[self::ATTRIBUTE_MEMBER],
                            array($member));
@@ -175,7 +175,7 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T
     }
 
     /**
-     * FIXME: This method belongs somewhere where we are aware of groups
+     * @todo: This method belongs somewhere where we are aware of groups
      * Identify the GID for the first group found using the specified
      * search criteria
      *
@@ -187,7 +187,7 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T
      * @throws Horde_Kolab_Server_Exception
      */
     static public function gidForSearch($server, $criteria,
-                                        $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                        $restrict = 0)
     {
         $groups = array('field' => self::ATTRIBUTE_OC,
                         'op'    => '=',
index 6db3c08..e831975 100644 (file)
@@ -84,7 +84,7 @@ class Horde_Kolab_Server_Object_Kolab_Domainmaintainer extends Horde_Kolab_Serve
             $domain_uid = sprintf('cn=%s,cn=domain,cn=internal,%s',
                                   $domain, $this->server->getBaseUid());
 
-            //FIXME: This should be made easier by the group object
+            //@todo: This should be made easier by the group object
 
             $domain_group = $this->server->fetch($domain_uid, 'Horde_Kolab_Server_Object_Kolabgroupofnames');
             if ($domain_group instanceOf PEAR_Error) {
index cbdc7f9..344afda 100644 (file)
@@ -131,7 +131,7 @@ class Horde_Kolab_Server_Object_Kolab_User extends Horde_Kolab_Server_Object_Kol
     /**
      * Get the "first name" attribute of this object
      *
-     * FIXME: This should get refactored to be combined with the Id value.
+     * @todo: This should get refactored to be combined with the Id value.
      *
      * @return string the "first name" of this object
      */
index bfc88bf..d320717 100644 (file)
@@ -180,7 +180,7 @@ class Horde_Kolab_Server_Object_Kolabgroupofnames extends Horde_Kolab_Server_Obj
      * @throws Horde_Kolab_Server_Exception
      */
     static public function gidForMail($server, $mail,
-                                      $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                      $restrict = 0)
     {
         $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_MAIL,
                                                'op'    => '=',
index 9e891a9..b3d03e3 100644 (file)
@@ -404,7 +404,7 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob
      * @throws Horde_Kolab_Server_Exception
      */
     static public function uidForSearch($server, $criteria,
-                                        $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                        $restrict = 0)
     {
         $users = array('field' => self::ATTRIBUTE_OC,
                        'op'    => '=',
@@ -429,7 +429,7 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob
      * @throws Horde_Kolab_Server_Exception
      */
     static public function uidForId($server, $id,
-                                    $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                    $restrict = 0)
     {
         $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_SID,
                                                'op'    => '=',
@@ -451,7 +451,7 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob
      * @throws Horde_Kolab_Server_Exception
      */
     static public function uidForMail($server, $mail,
-                                      $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                      $restrict = 0)
     {
         $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_MAIL,
                                                'op'    => '=',
@@ -498,7 +498,7 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob
      * @throws Horde_Kolab_Server_Exception
      */
     static public function uidForAlias($server, $mail,
-                                       $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                       $restrict = 0)
     {
         $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_ALIAS,
                                                'op'    => '=',
index 0344eb5..469347b 100644 (file)
  */
 class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object_Top
 {
-    /** Define attributes specific to this object type */
-
-    /** The common name */
-    const ATTRIBUTE_CN = 'cn';
-
-    /** The surname */
-    const ATTRIBUTE_SN = 'sn';
-
-    /** A password for this person */
-    const ATTRIBUTE_USERPASSWORD = 'userPassword';
-
-    /** A password for this person */
-    const ATTRIBUTE_USERPASSWORDRAW = 'userPasswordRaw';
-
-    /** A telephone number for this person */
-    const ATTRIBUTE_TELNO = 'telephoneNumber';
-
     /** The specific object class of this object type */
     const OBJECTCLASS_PERSON = 'person';
 
@@ -53,36 +36,37 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object_Top
      * @var array
      */
     static public $init_attributes = array(
-        'defined' => array(
-            self::ATTRIBUTE_CN,
-            self::ATTRIBUTE_SN,
-            self::ATTRIBUTE_USERPASSWORD,
-            self::ATTRIBUTE_TELNO,
-        ),
-        'derived' => array(
-            self::ATTRIBUTE_USERPASSWORD => array(
-                'base' => array(
-                    self::ATTRIBUTE_USERPASSWORD
-                ),
-                'method' => 'getEmpty',
-            ),
-            self::ATTRIBUTE_USERPASSWORDRAW => array(
-                'base' => array(
-                    self::ATTRIBUTE_USERPASSWORD
-                ),
-                'method' => '_get',
-                'args' => array(
-                    self::ATTRIBUTE_USERPASSWORD,
-                ),
-            ),
-        ),
-        'required' => array(
-            self::ATTRIBUTE_CN,
-            self::ATTRIBUTE_SN,
-        ),
-        'object_classes' => array(
-            self::OBJECTCLASS_PERSON
-        ),
+        'Cn', 'Sn', 'Userpassword', 'Userpasswordraw', 'Telephonenumber'
+/*         'defined' => array( */
+/*             self::ATTRIBUTE_CN, */
+/*             self::ATTRIBUTE_SN, */
+/*             self::ATTRIBUTE_USERPASSWORD, */
+/*             self::ATTRIBUTE_TELNO, */
+/*         ), */
+/*         'derived' => array( */
+/*             self::ATTRIBUTE_USERPASSWORD => array( */
+/*                 'base' => array( */
+/*                     self::ATTRIBUTE_USERPASSWORD */
+/*                 ), */
+/*                 'method' => 'getEmpty', */
+/*             ), */
+/*             self::ATTRIBUTE_USERPASSWORDRAW => array( */
+/*                 'base' => array( */
+/*                     self::ATTRIBUTE_USERPASSWORD */
+/*                 ), */
+/*                 'method' => '_get', */
+/*                 'args' => array( */
+/*                     self::ATTRIBUTE_USERPASSWORD, */
+/*                 ), */
+/*             ), */
+/*         ), */
+/*         'required' => array( */
+/*             self::ATTRIBUTE_CN, */
+/*             self::ATTRIBUTE_SN, */
+/*         ), */
+/*         'object_classes' => array( */
+/*             self::OBJECTCLASS_PERSON */
+/*         ), */
     );
 
     /**
@@ -165,12 +149,10 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object_Top
      */
     public static function getFilter()
     {
-        $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_OC,
-                                               'op'    => '=',
-                                               'test'  => self::OBJECTCLASS_PERSON),
-                          ),
+        return new Horde_Kolab_Server_Query_Element_Equals(
+            Horde_Kolab_Server_Object_Attribute_Objectclass::NAME,
+            self::OBJECTCLASS_PERSON
         );
-        return $criteria;
     }
 
     /**
@@ -184,28 +166,30 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object_Top
      */
     public function generateId(array &$info)
     {
+        $cn = Horde_Kolab_Server_Object_Attribute_Cn::NAME;
+        $sn = Horde_Kolab_Server_Object_Attribute_Sn::NAME;
         if ($this->exists()) {
-            if (!isset($info[self::ATTRIBUTE_CN])
-                && !isset($info[self::ATTRIBUTE_SN])) {
-                return false;
+            if (!isset($info[$cn])
+                && !isset($info[$sn])) {
+                return $this->getGuid();
             }
-            if (!isset($info[self::ATTRIBUTE_CN])) {
-                $old = $this->get(self::ATTRIBUTE_CN);
+            if (!isset($info[$cn])) {
+                $old = $this->getInternal($cn);
                 if (!empty($old)) {
-                    return false;
+                    return $this->getGuid();
                 }
             }            
         }
 
-        if (!empty($info[self::ATTRIBUTE_CN])) {
-            $id = $info[self::ATTRIBUTE_CN];
+        if (!empty($info[$cn])) {
+            $id = $info[$cn];
         } else {
-            $id = $info[self::ATTRIBUTE_SN];
+            $id = $info[$sn];
         }
         if (is_array($id)) {
             $id = $id[0];
         }
-        return self::ATTRIBUTE_CN . '=' . $this->server->structure->quoteForUid($id);
+        return $cn . '=' . $this->server->structure->quoteForUid($id);
     }
 
     /**
@@ -219,10 +203,10 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object_Top
      */
     public function prepareObjectInformation(array &$info)
     {
-        if (!$this->exists()
-            && empty($info[self::ATTRIBUTE_CN])
-            && !empty($info[self::ATTRIBUTE_SN])) {
-            $info[self::ATTRIBUTE_CN] = $info[self::ATTRIBUTE_SN];
+        $cn = Horde_Kolab_Server_Object_Attribute_Cn::NAME;
+        $sn = Horde_Kolab_Server_Object_Attribute_Sn::NAME;
+        if (!$this->exists() && empty($info[$cn]) && !empty($info[$sn])) {
+            $info[$cn] = $info[$sn];
         }
 
         if (!empty($info[self::ATTRIBUTE_USERPASSWORD])) {
@@ -258,7 +242,7 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object_Top
      * @throws Horde_Kolab_Server_Exception
      */
     static public function uidForCn($server, $cn,
-                                    $restrict = Horde_Kolab_Server_Object::RESULT_SINGLE)
+                                    $restrict = 0)
     {
         $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_CN,
                                                'op'    => '=',
index bac365b..21cabf9 100644 (file)
@@ -27,7 +27,7 @@
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Kolab_Server
  */
-class Horde_Kolab_Server_Object_Top
+abstract class Horde_Kolab_Server_Object_Top
 extends Horde_Kolab_Server_Object_Base
 implements Horde_Kolab_Server_Object_Searches
 {
@@ -73,30 +73,6 @@ implements Horde_Kolab_Server_Object_Searches
     }
 
     /**
-     * Generates an ID for the given information.
-     *
-     * @param array &$info The data of the object.
-     *
-     * @return string The ID.
-     */
-    public function generateId(array &$info)
-    {
-        if ($this->exists() && empty($info['Id'])) {
-            return false;
-        }
-
-        if (!empty($info['Id'])) {
-            if (is_array($info['Id'])) {
-                $id = $info['Id'][0];
-            } else {
-                $id = $info['Id'];
-            }
-            return $this->_composite->server->quoteForGuid($id);
-        }
-        return $this->composite->server->quoteForGuid(hash('sha256', uniqid(mt_rand(), true)));
-    }
-
-    /**
      * Distill the server side object information to save.
      *
      * @param array &$info The information about the object.
index d2edfca..36a2423 100644 (file)
 class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects
 {
     /**
-     * A link to the server handler.
+     * A link to the composite server handler.
      *
-     * @var Horde_Kolab_Server
+     * @var Horde_Kolab_Server_Composite
      */
-    protected $server;
+    protected $composite;
 
     /**
-     * Set the server reference for this object.
+     * Set the composite server reference for this object.
      *
-     * @param Horde_Kolab_Server &$server A link to the server handler.
+     * @param Horde_Kolab_Server_Composite $composite A link to the composite
+     *                                                server handler.
+     *
+     * @return NULL
      */
-    public function setServer($server)
+    public function setComposite(Horde_Kolab_Server_Composite $composite)
     {
-        $this->server = $server;
+        $this->composite = $composite;
     }
 
     /**
@@ -204,7 +207,7 @@ class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects
         }
 
         if ($sort) {
-            /* FIXME */
+            /* @todo: sorting */
             /* $data = $result->as_sorted_struct(); */
             /*$this->sort($result, $sort); */
         }
index 9ed27a7..4193e93 100644 (file)
@@ -39,20 +39,23 @@ class Horde_Kolab_Server_Schema_Base implements Horde_Kolab_Server_Schema
     protected $attributes;
 
     /**
-     * A link to the server handler.
+     * A link to the composite server handler.
      *
-     * @var Horde_Kolab_Server
+     * @var Horde_Kolab_Server_Composite
      */
-    protected $server;
+    protected $composite;
 
     /**
-     * Set the server reference for this object.
+     * Set the composite server reference for this object.
      *
-     * @param Horde_Kolab_Server &$server A link to the server handler.
+     * @param Horde_Kolab_Server_Composite $composite A link to the composite
+     *                                                server handler.
+     *
+     * @return NULL
      */
-    public function setServer($server)
+    public function setComposite(Horde_Kolab_Server_Composite $composite)
     {
-        $this->server = $server;
+        $this->composite = $composite;
     }
 
     /**
@@ -104,7 +107,7 @@ class Horde_Kolab_Server_Schema_Base implements Horde_Kolab_Server_Schema
      *
      * @throws Horde_Kolab_Server_Exception If the schema analysis fails.
      */
-    public function &getAttributes($class)
+    public function getExternalAttributes($class)
     {
         if (!isset($this->attributes)) {
             if (isset($this->cache)) {
@@ -253,6 +256,10 @@ class Horde_Kolab_Server_Schema_Base implements Horde_Kolab_Server_Schema
         return $this->attributes[$class];
     }
 
+    public function getInternalAttributes($class)
+    {
+    }
+
     /**
      * Stores the attribute definitions in the cache.
      *
index f3c0499..3e1639e 100644 (file)
@@ -72,7 +72,7 @@ class Horde_Kolab_Server_Structure_Ldap extends Horde_Kolab_Server_Structure_Bas
         foreach ($ocs as $oc) {
             try {
                 $class_name = 'Horde_Kolab_Server_Object_' . ucfirst(strtolower($oc));
-                Horde_Kolab_Server_Object::loadClass($class_name);
+                Horde_Kolab_Server_Object_Factory::loadClass($class_name);
                 return $class_name;
             } catch (Horde_Kolab_Server_Exception $e)  {
             }
index 3ad9d28..2c3f134 100644 (file)
@@ -64,6 +64,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <file name="Composite.php" role="php" />
        <file name="Connection.php" role="php" />
        <dir name="Connection">
+        <file name="File.php" role="php" />
+        <file name="Mock.php" role="php" />
+        <dir name="Mock">
+         <file name="Search.php" role="php" />
+        </dir> <!-- /lib/Horde/Kolab/Server/Connection/Mock -->
         <file name="Simpleldap.php" role="php" />
         <file name="Splittedldap.php" role="php" />
        </dir> <!-- /lib/Horde/Kolab/Server/Connection -->
@@ -75,12 +80,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <file name="Ldap.php" role="php" />
        <dir name="Ldap">
         <file name="Changes.php" role="php" />
-        <file name="File.php" role="php" />
         <file name="Filtered.php" role="php" />
-        <file name="Mock.php" role="php" />
         <file name="Standard.php" role="php" />
        </dir> <!-- /lib/Horde/Kolab/Server/Ldap -->
        <file name="Logged.php" role="php" />
+       <file name="Mapped.php" role="php" />
        <file name="Object.php" role="php" />
        <dir name="Object">
         <file name="Attribute.php" role="php" />
@@ -104,6 +108,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
          <file name="Writelock.php" role="php" />
         </dir> <!-- /lib/Horde/Kolab/Server/Object/Attribute -->
         <file name="Base.php" role="php" />
+        <file name="Factory.php" role="php" />
         <file name="Groupofnames.php" role="php" />
         <file name="Inetorgperson.php" role="php" />
         <file name="Kolab.php" role="php" />
@@ -183,14 +188,13 @@ http://pear.php.net/dtd/package-2.0.xsd">
        </dir> <!-- /test/Horde/Kolab/Server/Attribute -->
        <file name="Autoload.php" role="test" />
        <dir name="Connection">
+        <file name="MockTest.php" role="test" />
         <file name="SimpleldapTest.php" role="php" />
         <file name="SplittedldapTest.php" role="php" />
        </dir> <!-- /test/Horde/Kolab/Server/Connection -->
-       <file name="LdapBase.php" role="test" />
-       <dir name="Object">
+       <dir name="Integration">
         <file name="AddingObjectsTest.php" role="test" />
         <file name="AdminTest.php" role="test" />
-        <file name="BaseTest.php" role="test" />
         <file name="DistListHandlingTest.php" role="test" />
         <file name="GroupHandlingTest.php" role="test" />
         <file name="GroupTest.php" role="test" />
@@ -198,12 +202,21 @@ http://pear.php.net/dtd/package-2.0.xsd">
         <file name="KolabgermanbankarrangementTest.php" role="test" />
         <file name="KolabinetorgpersonTest.php" role="test" />
         <file name="Kolabpop3accountTest.php" role="test" />
+        <file name="MockTest.php" role="test" />
         <file name="ObjectTest.php" role="test" />
         <file name="OrgPersonTest.php" role="test" />
         <file name="PersonTest.php" role="test" />
+        <file name="Scenario.php" role="test" />
         <file name="UserHandlingTest.php" role="test" />
         <file name="UserTest.php" role="test" />
+       </dir> <!-- /test/Horde/Kolab/Server/Integration -->
+       <file name="LdapBase.php" role="test" />
+       <dir name="Object">
+        <file name="BaseTest.php" role="test" />
        </dir> <!-- /test/Horde/Kolab/Server/Object -->
+       <dir name="Objects">
+        <file name="ServerTest.php" role="test" />
+       </dir> <!-- /test/Horde/Kolab/Server/Objects -->
        <dir name="Query">
         <file name="ElementTest.php" role="test" />
         <file name="LdapTest.php" role="test" />
@@ -211,7 +224,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <dir name="Result">
         <file name="LdapTest.php" role="test" />
        </dir> <!-- /test/Horde/Kolab/Server/Result -->
-       <file name="Scenario.php" role="test" />
        <dir name="Search">
         <file name="SearchTest.php" role="test" />
        </dir> <!-- /test/Horde/Kolab/Server/Search -->
@@ -220,8 +232,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
         <file name="FilteredTest.php" role="test" />
         <file name="LdapTest.php" role="test" />
         <file name="LoggedTest.php" role="test" />
-        <file name="MockTest.php" role="test" />
-        <file name="ServerTest.php" role="test" />
         <file name="StandardTest.php" role="test" />
        </dir> <!-- /test/Horde/Kolab/Server/Server -->
        <dir name="Structure">
@@ -266,6 +276,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Kolab/Server.php" as="Horde/Kolab/Server.php" />
    <install name="lib/Horde/Kolab/Server/Composite.php" as="Horde/Kolab/Server/Composite.php" />
    <install name="lib/Horde/Kolab/Server/Connection.php" as="Horde/Kolab/Server/Connection.php" />
+   <install name="lib/Horde/Kolab/Server/Connection/File.php" as="Horde/Kolab/Server/Connection/File.php" />
+   <install name="lib/Horde/Kolab/Server/Connection/Mock.php" as="Horde/Kolab/Server/Connection/Mock.php" />
+   <install name="lib/Horde/Kolab/Server/Connection/Mock/Search.php" as="Horde/Kolab/Server/Connection/Mock/Search.php" />
    <install name="lib/Horde/Kolab/Server/Connection/Simpleldap.php" as="Horde/Kolab/Server/Connection/Simpleldap.php" />
    <install name="lib/Horde/Kolab/Server/Connection/Splittedldap.php" as="Horde/Kolab/Server/Connection/Splittedldap.php" />
    <install name="lib/Horde/Kolab/Server/Exception.php" as="Horde/Kolab/Server/Exception.php" />
@@ -273,11 +286,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Kolab/Server/Factory.php" as="Horde/Kolab/Server/Factory.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/File.php" as="Horde/Kolab/Server/Ldap/File.php" />
    <install name="lib/Horde/Kolab/Server/Ldap/Filtered.php" as="Horde/Kolab/Server/Ldap/Filtered.php" />
-   <install name="lib/Horde/Kolab/Server/Ldap/Mock.php" as="Horde/Kolab/Server/Ldap/Mock.php" />
    <install name="lib/Horde/Kolab/Server/Ldap/Standard.php" as="Horde/Kolab/Server/Ldap/Standard.php" />
    <install name="lib/Horde/Kolab/Server/Logged.php" as="Horde/Kolab/Server/Logged.php" />
+   <install name="lib/Horde/Kolab/Server/Mapped.php" as="Horde/Kolab/Server/Mapped.php" />
    <install name="lib/Horde/Kolab/Server/Object.php" as="Horde/Kolab/Server/Object.php" />
    <install name="lib/Horde/Kolab/Server/Object/Attribute.php" as="Horde/Kolab/Server/Object/Attribute.php" />
    <install name="lib/Horde/Kolab/Server/Object/Attribute/Base.php" as="Horde/Kolab/Server/Object/Attribute/Base.php" />
@@ -298,6 +310,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <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/Object/Factory.php" as="Horde/Kolab/Server/Object/Factory.php" />
    <install name="lib/Horde/Kolab/Server/Object/Groupofnames.php" as="Horde/Kolab/Server/Object/Groupofnames.php" />
    <install name="lib/Horde/Kolab/Server/Object/Inetorgperson.php" as="Horde/Kolab/Server/Object/Inetorgperson.php" />
    <install name="lib/Horde/Kolab/Server/Object/Kolab.php" as="Horde/Kolab/Server/Object/Kolab.php" />
@@ -349,35 +362,36 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="test/Horde/Kolab/Server/Attribute/BaseTest.php" as="Horde/Kolab/Server/Attribute/BaseTest.php" />
    <install name="test/Horde/Kolab/Server/Attribute/ValueTest.php" as="Horde/Kolab/Server/Attribute/ValueTest.php" />
    <install name="test/Horde/Kolab/Server/Autoload.php" as="Horde/Kolab/Server/Autoload.php" />
+   <install name="test/Horde/Kolab/Server/Connection/MockTest.php" as="Horde/Kolab/Server/Connection/MockTest.php" />
    <install name="test/Horde/Kolab/Server/Connection/SimpleldapTest.php" as="Horde/Kolab/Server/Connection/SimpleldapTest.php" />
    <install name="test/Horde/Kolab/Server/Connection/SplittedldapTest.php" as="Horde/Kolab/Server/Connection/SplittedldapTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/AddingObjectsTest.php" as="Horde/Kolab/Server/Integration/AddingObjectsTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/AdminTest.php" as="Horde/Kolab/Server/Integration/AdminTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/DistListHandlingTest.php" as="Horde/Kolab/Server/Integration/DistListHandlingTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/GroupHandlingTest.php" as="Horde/Kolab/Server/Integration/GroupHandlingTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/GroupTest.php" as="Horde/Kolab/Server/Integration/GroupTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/InetorgpersonTest.php" as="Horde/Kolab/Server/Integration/InetorgpersonTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/KolabgermanbankarrangementTest.php" as="Horde/Kolab/Server/Integration/KolabgermanbankarrangementTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/KolabinetorgpersonTest.php" as="Horde/Kolab/Server/Integration/KolabinetorgpersonTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/Kolabpop3accountTest.php" as="Horde/Kolab/Server/Integration/Kolabpop3accountTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/MockTest.php" as="Horde/Kolab/Server/Integration/MockTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/ObjectTest.php" as="Horde/Kolab/Server/Integration/ObjectTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/OrgPersonTest.php" as="Horde/Kolab/Server/Integration/OrgPersonTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/PersonTest.php" as="Horde/Kolab/Server/Integration/PersonTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/Scenario.php" as="Horde/Kolab/Server/Integration/Scenario.php" />
+   <install name="test/Horde/Kolab/Server/Integration/UserHandlingTest.php" as="Horde/Kolab/Server/Integration/UserHandlingTest.php" />
+   <install name="test/Horde/Kolab/Server/Integration/UserTest.php" as="Horde/Kolab/Server/Integration/UserTest.php" />
    <install name="test/Horde/Kolab/Server/LdapBase.php" as="Horde/Kolab/Server/LdapBase.php" />
-   <install name="test/Horde/Kolab/Server/Object/AddingObjectsTest.php" as="Horde/Kolab/Server/Object/AddingObjectsTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/AdminTest.php" as="Horde/Kolab/Server/Object/AdminTest.php" />
    <install name="test/Horde/Kolab/Server/Object/BaseTest.php" as="Horde/Kolab/Server/Object/BaseTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/DistListHandlingTest.php" as="Horde/Kolab/Server/Object/DistListHandlingTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/GroupHandlingTest.php" as="Horde/Kolab/Server/Object/GroupHandlingTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/GroupTest.php" as="Horde/Kolab/Server/Object/GroupTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/InetorgpersonTest.php" as="Horde/Kolab/Server/Object/InetorgpersonTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/KolabgermanbankarrangementTest.php" as="Horde/Kolab/Server/Object/KolabgermanbankarrangementTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/KolabinetorgpersonTest.php" as="Horde/Kolab/Server/Object/KolabinetorgpersonTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/Kolabpop3accountTest.php" as="Horde/Kolab/Server/Object/Kolabpop3accountTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/ObjectTest.php" as="Horde/Kolab/Server/Object/ObjectTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/OrgPersonTest.php" as="Horde/Kolab/Server/Object/OrgPersonTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/PersonTest.php" as="Horde/Kolab/Server/Object/PersonTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/UserHandlingTest.php" as="Horde/Kolab/Server/Object/UserHandlingTest.php" />
-   <install name="test/Horde/Kolab/Server/Object/UserTest.php" as="Horde/Kolab/Server/Object/UserTest.php" />
+   <install name="test/Horde/Kolab/Server/Objects/ServerTest.php" as="Horde/Kolab/Server/Objects/ServerTest.php" />
    <install name="test/Horde/Kolab/Server/Query/ElementTest.php" as="Horde/Kolab/Server/Query/ElementTest.php" />
    <install name="test/Horde/Kolab/Server/Query/LdapTest.php" as="Horde/Kolab/Server/Query/LdapTest.php" />
    <install name="test/Horde/Kolab/Server/Result/LdapTest.php" as="Horde/Kolab/Server/Result/LdapTest.php" />
-   <install name="test/Horde/Kolab/Server/Scenario.php" as="Horde/Kolab/Server/Scenario.php" />
    <install name="test/Horde/Kolab/Server/Search/SearchTest.php" as="Horde/Kolab/Server/Search/SearchTest.php" />
    <install name="test/Horde/Kolab/Server/Server/FactoryTest.php" as="Horde/Kolab/Server/Server/FactoryTest.php" />
    <install name="test/Horde/Kolab/Server/Server/FilteredTest.php" as="Horde/Kolab/Server/Server/FilteredTest.php" />
    <install name="test/Horde/Kolab/Server/Server/LdapTest.php" as="Horde/Kolab/Server/Server/LdapTest.php" />
    <install name="test/Horde/Kolab/Server/Server/LoggedTest.php" as="Horde/Kolab/Server/Server/LoggedTest.php" />
-   <install name="test/Horde/Kolab/Server/Server/MockTest.php" as="Horde/Kolab/Server/Server/MockTest.php" />
-   <install name="test/Horde/Kolab/Server/Server/ServerTest.php" as="Horde/Kolab/Server/Server/ServerTest.php" />
    <install name="test/Horde/Kolab/Server/Server/StandardTest.php" as="Horde/Kolab/Server/Server/StandardTest.php" />
    <install name="test/Horde/Kolab/Server/Structure/KolabTest.php" as="Horde/Kolab/Server/Structure/KolabTest.php" />
    <install name="test/Horde/Kolab/Server/Structure/LdapTest.php" as="Horde/Kolab/Server/Structure/LdapTest.php" />
index b1d01ba..780b43c 100644 (file)
@@ -18,10 +18,8 @@ if (!spl_autoload_functions()) {
             '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);'
             . '$err_mask = E_ALL ^ E_WARNING;'
             . '$oldErrorReporting = error_reporting($err_mask);'
-            . '$included = include "$filename.php";'
+            . 'include "$filename.php";'
             . 'error_reporting($oldErrorReporting);'
         )
     );
-}
-
-require_once dirname(__FILE__) . '/Scenario.php';
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Connection/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Connection/MockTest.php
new file mode 100644 (file)
index 0000000..6801ca5
--- /dev/null
@@ -0,0 +1,235 @@
+<?php
+/**
+ * Test the test driver.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/../LdapBase.php';
+
+/**
+ * Test the test backend.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Connection_MockTest extends Horde_Kolab_Server_LdapBase
+{
+
+    /**
+     * Test parsing of LDAP filters.
+     *
+     * @return NULL
+     */
+    public function testFilterParse()
+    {
+        $conn = new Horde_Kolab_Server_Connection_Mock(array());
+
+        $a = $conn->parse('(a=b)');
+        $this->assertEquals(array('att' => 'a', 'log' => '=', 'val' => 'b'),
+                            $a);
+
+        $a = $conn->parse('(&(a=b)(c=d))');
+        $this->assertEquals(array('op' => '&', 'sub' => array(
+                                      array('att' => 'a', 'log' => '=', 'val' => 'b'),
+                                      array('att' => 'c', 'log' => '=', 'val' => 'd'),
+                                  )), $a);
+
+        $a = $conn->parse('(&(a=1)(|(b=2)(c=3)))');
+        $this->assertEquals(array('op' => '&', 'sub' => array(
+                                      array('att' => 'a', 'log' => '=', 'val' => '1'),
+                                      array('op' => '|', 'sub' =>
+                                            array(
+                                                array('att' => 'b', 'log' => '=', 'val' => '2'),
+                                                array('att' => 'c', 'log' => '=', 'val' => '3'),
+                                            )))), $a);
+
+        $a = $conn->parseSub('(!(x=2))(b=1)');
+        $this->assertEquals(array(array('op' => '!', 'sub' =>
+                                        array(
+                                            array('att' => 'x', 'log' => '=', 'val' => '2'),
+                                        )
+                                  ),
+                                  array('att' => 'b', 'log' => '=', 'val' => '1'),
+                            ), $a);
+
+        $a = $conn->parse('(&(!(x=2))(b=1))');
+        $this->assertEquals(array('op' => '&', 'sub' => array(
+                                      array('op' => '!', 'sub' =>
+                                            array(
+                                                array('att' => 'x', 'log' => '=', 'val' => '2'),
+                                            )
+                                      ),
+                                      array('att' => 'b', 'log' => '=', 'val' => '1'),
+                                  )), $a);
+
+    }
+
+    /**
+     * Test searching in the simulated LDAP data.
+     *
+     * @return NULL
+     */
+    public function testSearch()
+    {
+        $conn = new Horde_Kolab_Server_Connection_Mock(
+            array(
+                'data' =>
+                array(
+                    'cn=a' => array(
+                        'dn' => 'cn=a',
+                        'data' => array(
+                            'a' => '1',
+                            'b' => '1',
+                            'c' => '1',
+                        )
+                    ),
+                    'cn=b' => array(
+                        'dn' => 'cn=b',
+                        'data' => array(
+                            'a' => '1',
+                            'b' => '2',
+                            'c' => '2',
+                        )
+                    ),
+                    'cn=c' => array(
+                        'dn' => 'cn=c',
+                        'data' => array(
+                            'a' => '1',
+                            'b' => '2',
+                            'c' => '3',
+                        )
+                    ),
+                    'cn=d' => array(
+                        'dn' => 'cn=d',
+                        'data' => array(
+                            'a' => '2',
+                            'b' => '2',
+                            'c' => '1',
+                        )
+                    ),
+                )
+            )
+        );
+
+        $a = $conn->search(null, '(c=1)');
+        $this->assertEquals(
+            array(
+                'cn=a' => array(
+                    'a' => '1',
+                    'b' => '1',
+                    'c' => '1',
+                    'dn' => 'cn=a',
+                ),
+                'cn=d' => array(
+                    'a' => '2',
+                    'b' => '2',
+                    'c' => '1',
+                    'dn' => 'cn=d',
+                ),
+            ),
+            $a->as_struct()
+        );
+
+        $a = $conn->search(null, '(c=3)');
+        $this->assertEquals(
+            array(
+                'cn=c' => array(
+                    'a' => '1',
+                    'b' => '2',
+                    'c' => '3',
+                    'dn' => 'cn=c',
+                ),
+            ),
+            $a->as_struct()
+        );
+
+        $a = $conn->search(null, '(c=3)', array('attributes' => array('a')));
+        $this->assertEquals(
+            array(
+                'cn=c' => array(
+                    'a' => '1',
+                    'dn' => 'cn=c',
+                ),
+            ),
+            $a->as_struct()
+        );
+
+        $a = $conn->search(null, '(&(a=1)(b=2))', array('attributes' => array('a', 'b')));
+        $this->assertEquals(
+            array(
+                'cn=b' => array(
+                    'a' => '1',
+                    'b' => '2',
+                    'dn' => 'cn=b',
+                ),
+                'cn=c' => array(
+                    'a' => '1',
+                    'b' => '2',
+                    'dn' => 'cn=c',
+                ),
+            ),
+            $a->as_struct()
+        );
+
+        $a = $conn->search(null, '(&(b=2))', array('attributes' => array('b')));
+        $this->assertEquals(
+            array(
+                'cn=b' => array(
+                    'b' => '2',
+                    'dn' => 'cn=b',
+                ),
+                'cn=c' => array(
+                    'b' => '2',
+                    'dn' => 'cn=c',
+                ),
+                'cn=d' => array(
+                    'b' => '2',
+                    'dn' => 'cn=d',
+                ),
+            ),
+            $a->as_struct()
+        );
+
+        $a = $conn->search(null, '(!(b=2))', array('attributes' => array('a', 'b')));
+        $this->assertEquals(
+            array(
+                'cn=a' => array(
+                    'a' => '1',
+                    'b' => '1',
+                    'dn' => 'cn=a',
+                ),
+            ),
+            $a->as_struct()
+        );
+
+        $a = $conn->search(null, '(&(!(x=2))(b=1))', array('attributes' => array('b')));
+        $this->assertEquals(
+            array(
+                'cn=a' => array(
+                    'b' => '1',
+                    'dn' => 'cn=a',
+                ),
+            ),
+            $a->as_struct()
+        );
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/AddingObjectsTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/AddingObjectsTest.php
new file mode 100644 (file)
index 0000000..da73702
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Adding objects to the server.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Adding objects to the server.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Integration_AddingObjectsTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Test adding valid users.
+     *
+     * @param array $user The user to add.
+     *
+     * @scenario
+     * @dataProvider validUsers
+     *
+     * @return NULL
+     */
+    public function addingValidUser($user)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a Kolab server object', $user)
+            ->then(
+                'the result should be an object of type',
+                'Horde_Kolab_Server_Object_Kolab_User'
+            );
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/AdminTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/AdminTest.php
new file mode 100644 (file)
index 0000000..1f4ab27
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+/**
+ * Test the admin object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the admin object.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Integration_AdminTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->server = $this->getKolabMockServer();
+    }
+
+    /**
+     * Add an administrator object.
+     *
+     * @return NULL
+     */
+    private function _addValidAdmin()
+    {
+        $this->addToServers($this->provideBasicAdmin());
+    }
+
+    /**
+     * Test ID generation for an admin.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        $admin = $this->provideBasicAdmin();
+        $user  = new Horde_Kolab_Server_Object_Kolab_Administrator($this->server,
+                                                                   null, $admin);
+        $this->assertEquals(
+            'cn=The Administrator,dc=example,dc=org',
+            $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)
+        );
+    }
+
+    /**
+     * Test fetching an admin.
+     *
+     * @return NULL
+     */
+    public function testFetchAdmin()
+    {
+        $this->_addValidAdmin();
+
+        $this->assertEquals(2, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
+        $this->assertContains(
+            'cn=admin,cn=internal,dc=example,dc=org',
+            array_keys($GLOBALS['KOLAB_SERVER_TEST_DATA'])
+        );
+
+        $administrators = $this->server->getGroups(
+            'cn=The Administrator,dc=example,dc=org'
+        );
+        $admin_group    = $this->server->fetch(
+            'cn=admin,cn=internal,dc=example,dc=org'
+        );
+
+        $this->assertTrue($admin_group->exists());
+
+        $admin = $this->server->fetch('cn=The Administrator,dc=example,dc=org');
+        $this->assertEquals(
+            'Horde_Kolab_Server_Object_Kolab_Administrator',
+            get_class($admin)
+        );
+    }
+
+    /**
+     * Test listing the admins.
+     *
+     * @return NULL
+     */
+    public function testToHash()
+    {
+        $this->_addValidAdmin();
+
+        $hash = $this->server->fetch(
+            'cn=The Administrator,dc=example,dc=org'
+        )->toHash();
+        $this->assertContains('uid', array_keys($hash));
+        $this->assertContains('lnfn', array_keys($hash));
+        $this->assertEquals('admin', $hash['uid']);
+    }
+
+    /**
+     * Test listing admins.
+     *
+     * @return NULL
+     */
+    public function testListingGroups()
+    {
+        $this->_addValidAdmin();
+
+        $entries = $this->server->search(
+            '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))'
+        );
+        $this->assertEquals(1, count($entries));
+
+        $list = $this->server->listObjects(
+            'Horde_Kolab_Server_Object_Kolab_Administrator'
+        );
+        $this->assertEquals(1, count($list));
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/DistListHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/DistListHandlingTest.php
new file mode 100644 (file)
index 0000000..3a1bb87
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Handling distribution lists.
+ *
+ * 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__) . '/Scenario.php';
+
+/**
+ * Handling distribution lists.
+ *
+ * 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_DistListHandlingTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /**
+     * Test adding a distribution list.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function creatingDistributionList()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a distribution list')
+            ->then(
+                'the result should be an object of type',
+                'Horde_Kolab_Server_Object_Kolab_Distlist'
+            );
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/GroupHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/GroupHandlingTest.php
new file mode 100644 (file)
index 0000000..460f7d3
--- /dev/null
@@ -0,0 +1,502 @@
+<?php
+/**
+ * Handling groups.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Handling groups.
+ *
+ * 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_GroupHandlingTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Test listing groups if there are no groups.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function listingGroupsOnEmptyServer()
+    {
+        $this->given('several Kolab servers')
+            ->when(
+                'retrieving a hash list with all objects of type',
+                'Horde_Kolab_Server_Object_Kolabgroupofnames'
+            )
+            ->then('the list is an empty array');
+    }
+
+    /**
+     * Test listing groups after adding some groups.
+     *
+     * @param array $group_list The groups to add.
+     *
+     * @scenario
+     * @dataProvider groupLists
+     *
+     * @return NULL
+     */
+    public function listingGroups($group_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object list', $group_list)
+            ->and(
+                'retrieving a hash list with all objects of type',
+                'Horde_Kolab_Server_Object_Kolabgroupofnames'
+            )
+            ->then('the result indicates success.')
+            ->and(
+                'the list has a number of entries equal to',
+                count($group_list)
+            );
+    }
+
+    /**
+     * Test the list of groups for the group id.
+     *
+     * @param array $group_list The groups to add.
+     *
+     * @scenario
+     * @dataProvider groupLists
+     *
+     * @return NULL
+     */
+    public function listingGroupsHasAttributeId($group_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object list', $group_list)
+            ->and(
+                'retrieving a hash list with all objects of type',
+                'Horde_Kolab_Server_Object_Kolabgroupofnames'
+            )
+            ->then(
+                'the provided list and the result list match with regard to these attributes',
+                'mail', 'cn', $group_list
+            );
+    }
+
+    /**
+     * Test the list of groups for the group mail address.
+     *
+     * @param array $group_list The groups to add.
+     *
+     * @scenario
+     * @dataProvider groupLists
+     *
+     * @return NULL
+     */
+    public function listingGroupsHasAttributeMail($group_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object list', $group_list)
+            ->and(
+                'retrieving a hash list with all objects of type',
+                'Horde_Kolab_Server_Object_Kolabgroupofnames'
+            )
+            ->then(
+                'the provided list and the result list match with regard to these attributes',
+                'mail', 'mail', $group_list
+            );
+    }
+
+    /**
+     * Test the list of groups for the group visibility.
+     *
+     * @param array $group_list The groups to add.
+     *
+     * @scenario
+     * @dataProvider groupLists
+     *
+     * @return NULL
+     */
+    public function listingGroupsHasAttributeVisibility($group_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object list', $group_list)
+            ->and(
+                'retrieving a hash list with all objects of type',
+                'Horde_Kolab_Server_Object_Kolabgroupofnames'
+            )
+            ->then(
+                'each element in the result list has an attribute',
+                'visible'
+            );
+    }
+
+    /**
+     * Test adding an invalid group.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function creatingGroupsWithoutMailAddressFails()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group without a mail address')
+            ->then(
+                'the result should indicate an error with',
+                'Adding object failed: The value for "mail" is missing!'
+            );
+    }
+
+    /**
+     * Test adding a group without setting the visibility.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function creatingGroupWithoutVisibilityCreatesVisibleGroup()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object', $this->provideGroupWithoutMembers())
+            ->and(
+                'retrieving a hash list with all objects of type',
+                'Horde_Kolab_Server_Object_Kolabgroupofnames'
+            )
+            ->then(
+                'each element in the result list has an attribute set to a given value',
+                'visible', true
+            );
+    }
+
+    /**
+     * Test modifying a group mail address.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function modifyingGroupMailAddressIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "test@example.org"')
+            ->and('modifying the mail address to "new@example.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The group cannot be modified: Changing the mail address from "test@example.org" to "new@example.org" is not allowed!'
+            );
+    }
+
+    /**
+     * Test modifying a group mail address.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function conflictBetweenGroupMailAndUserMailIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "test@example.org"')
+            ->and('adding a user "Test Test" with the mail address "test@example.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The user cannot be added: Mail address "test@example.org" is already the mail address for the group "test@example.org"!'
+            );
+    }
+
+    /**
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function conflictBetweenUserMailAndGroupMailIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the mail address "test@example.org"')
+            ->and('adding a group with the mail address "test@example.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The group cannot be added: Mail address "test@example.org" is already the mail address of the user "Test Test"!'
+            );
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenGroupMailAndUserAliasIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "test@example.org"')
+            ->and('adding a user with the alias address "test@example.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The user cannot be added: Alias address "test@example.org" is already the mail address of the group "test@example.org"!'
+            );
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenUserAliasAndGroupMailIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the alias address "test@example.org"')
+            ->and('adding a group with the mail address "test@example.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The group cannot be added: Mail address "test@example.org" is already the alias address of the user "Test Test"!'
+            );
+    }
+
+    /**
+     *  kolab/issue890 (Assigning multiple Distribution Lists to user during creation and modification)
+     *
+     * @scenario
+     */
+    public function showGroupsWhenFetchingTheUser()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
+            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
+            ->and('fetching the user "test@example.org"')
+            ->and('listing the groups of this user')
+            ->then('the list should contain "testgroup@example.org"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function allowAddingUserToGroup()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "testgroup@example.org"')
+            ->and('adding a user "cn=Test Test" with the mail address "test@example.org"')
+            ->and('modifying group with the mail address "testgroup@example.org" to contain the member "cn=Test Test".')
+            ->and('fetching the groups "group@example.org"')
+            ->and('listing the members of this group')
+            ->then('the list should contain "test@example.org"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function allowAddingUserToGroupWhenCreatingUser()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "testgroup@example.org"')
+            ->and('adding a user "cn=Test Test" with the mail address "test@example.org" and member of "testgroup@example.org"')
+            ->and('fetching the groups "group@example.org"')
+            ->and('listing the members of this group')
+            ->then('the list should contain "test@example.org"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function allowRemovingUserFromGroup()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
+            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
+            ->and('modifying group with the mail address "testgroup@example.org" to contain no members.')
+            ->and('fetching the groups "group@example.org"')
+            ->and('listing the members of this group')
+            ->then('the list is empty');
+    }
+
+    /**
+     * @scenario
+     */
+    public function deletingUserRemovesUserFromAllDistributionLists()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
+            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
+            ->and('adding a group with the mail address "testgroup2@example.org" and the member "cn=Test Test"')
+            ->and('deleting user "cn=Test Test"')
+            ->and('listing the members of group "testgroup@example.org"')
+            ->and('listing the members of group "testgroup2@example.org"')
+            ->then('the list of group "testgroup@example.org" is empty')
+            ->and('the list of group "testgroup2@example.org" is empty');
+    }
+
+    /**
+     * @scenario
+     */
+    public function modifyingUserIDDoesNotChangeGroupMembership()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
+            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
+            ->and('modifying user "cn=Test Test" to ID "cn=Test2 Test"')
+            ->and('listing the members of group "testgroup@example.org"')
+            ->then('the list of group "testgroup@example.org" contains "cn=Test2 Test"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function addingGroupInUndefinedDomainIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->and('the only served mail domain is "example.org"')
+            ->when('adding a group with the mail address "test@doesnotexist.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The group cannot be added: Domain "doesnotexist.org" is not being handled by this server!'
+            );
+    }
+
+    /**
+     *   kolab/issue1368 (Webinterface allows to create email addresses with slash that cyrus cannot handle)
+     *
+     * @scenario
+     * @dataProvider invalidMails
+     */
+    public function disallowInvalidMailAddresses($address)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with an invalid mail address', $address)
+            ->then(
+                'the result should indicate an error with',
+                "The group cannot be added: Address \"$address\" is not a valid mail address!"
+            );
+    }
+
+    /**
+     * @scenario
+     */
+    public function objectAttributeDescriptionsCanBeRetrieved()
+    {
+        $this->given('several Kolab servers')
+            ->when('retrieving the supported attributes by the object type "group"')
+            ->then('the result is an array of Horde attribute descriptions')
+            ->and('contains the description of "members"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function removingGroupFailsIfGroupDoesNotExist()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "group@example.org"')
+            ->and('deleting the group with the mail address "group@example.org"')
+            ->then(
+                'the result should indicate an error with',
+                'The group cannot be deleted: Group "group@example.org" does not exist!'
+            );
+    }
+
+    /**
+     * @scenario
+     */
+    public function removingGroupByMailSucceeds()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "test@example.org"')
+            ->and('deleting the group with mail address "test@example.org"')
+            ->then('the result indicates success')
+            ->and('listing all groups returns an empty list');
+    }
+
+    /**
+     *      kolab/issue1189 (IMAP login fails on some specific uids)
+     *
+     * @scenario
+     */
+    public function userUidsShouldNotResembleTheLocalPartOfMailAddresses()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a group with the mail address "test@example.org"')
+            ->and('adding a user with the uid "test"')
+            ->then(
+                'the result should indicate an error with',
+                'The user cannot be added: The uid "test" matches the local part of the mail address "test@example.org" assigned to group "test@example.org"!'
+            );
+    }
+
+    /**
+     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
+     *
+     * @scenario
+     */
+    public function addedUserCanLoginIfInAllowedGroup()
+    {
+        $this->given('several Kolab servers')
+            ->and('Horde uses the Kolab auth driver')
+            ->and('only members of group "testgroup@example.org" are allowed')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
+            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
+            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
+            ->then('the result indicates success')
+            ->and('the session shows "test@example.org" as the current user');
+    }
+
+    /**
+     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
+     *
+     * @scenario
+     */
+    public function addedUserCannotLoginIfInNotInAllowedGroup()
+    {
+        $this->given('several Kolab servers')
+            ->and('Horde uses the Kolab auth driver')
+            ->and('only members of group "testgroup@example.org" are allowed')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
+            ->and('adding a group with the mail address "testgroup@example.org" and no members')
+            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
+            ->then('the user may not login');
+    }
+
+    /**
+     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
+     *
+     * @scenario
+     */
+    public function addedUserCanLoginIfInNotInDisallowedGroup()
+    {
+        $this->given('several Kolab servers')
+            ->and('Horde uses the Kolab auth driver')
+            ->and('members of group "testgroup@example.org" may not login')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
+            ->and('adding a group with the mail address "testgroup@example.org" and no members')
+            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
+            ->then('the result indicates success')
+            ->and('the session shows "test@example.org" as the current user');
+    }
+
+    /**
+     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
+     *
+     * @scenario
+     */
+    public function addedUserCannotLoginIfInDisallowedGroup()
+    {
+        $this->given('several Kolab servers')
+            ->and('Horde uses the Kolab auth driver')
+            ->and('members of group "testgroup@example.org" may not login')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
+            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
+            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
+            ->then('the user may not login');
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/GroupTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/GroupTest.php
new file mode 100644 (file)
index 0000000..bf0fdb0
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Test the group object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the group object.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Integration_GroupTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->ldap = $this->getKolabMockServer();
+    }
+
+    /**
+     * Add a group object.
+     *
+     * @return NULL
+     */
+    private function _addValidGroups()
+    {
+        $groups = $this->validGroups();
+        foreach ($groups as $group) {
+            $result = $this->ldap->add($group[0]);
+            $this->assertNoError($result);
+        }
+    }
+
+    /**
+     * Test ID generation for a group.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        $groups = $this->validGroups();
+        $user = new Horde_Kolab_Server_Object_Kolabgroupofnames($this->ldap,
+                                                                null,
+                                                                $groups[0][0]);
+        $this->assertNoError($user);
+        $this->assertEquals(
+            'cn=empty.group@example.org,dc=example,dc=org',
+            $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)
+        );
+    }
+
+    /**
+     * Test fetching a group.
+     *
+     * @return NULL
+     */
+    public function testFetchGroup()
+    {
+        $this->_addValidGroups();
+
+        $group = $this->ldap->fetch('cn=empty.group@example.org,dc=example,dc=org');
+        $this->assertNoError($group);
+        $this->assertEquals(
+            'Horde_Kolab_Server_Object_Kolabgroupofnames',
+            get_class($group)
+        );
+    }
+
+    /**
+     * Test fetching a group.
+     *
+     * @return NULL
+     */
+    public function testToHash()
+    {
+        $this->_addValidGroups();
+
+        $group = $this->ldap->fetch('cn=empty.group@example.org,dc=example,dc=org');
+        $this->assertNoError($group);
+
+        $hash = $group->toHash();
+        $this->assertNoError($hash);
+        $this->assertContains('mail', array_keys($hash));
+        $this->assertContains('id', array_keys($hash));
+        $this->assertContains('visible', array_keys($hash));
+        $this->assertEquals('empty.group@example.org', $hash['mail']);
+        $this->assertEquals('cn=empty.group@example.org', $hash['id']);
+        $this->assertTrue($hash['visible']);
+    }
+
+    /**
+     * Test listing groups.
+     *
+     * @return NULL
+     */
+    public function testListingGroups()
+    {
+        $result = $this->ldap->search(
+            '(&(!(cn=domains))(objectClass=kolabGroupOfNames))',
+            array(),
+            $this->ldap->getBaseUid()
+        );
+        $this->assertEquals(0, count($result));
+
+        $this->_addValidGroups();
+
+        $this->assertEquals(3, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
+        $result = $this->ldap->search(
+            '(&(!(cn=domains))(objectClass=kolabGroupOfNames))',
+            array(),
+            $this->ldap->getBaseUid()
+        );
+        $this->assertEquals(3, count($result));
+
+        $list = $this->ldap->listObjects(
+            'Horde_Kolab_Server_Object_Kolabgroupofnames'
+        );
+        $this->assertNoError($list);
+        $this->assertEquals(3, count($list));
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/InetorgpersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/InetorgpersonTest.php
new file mode 100644 (file)
index 0000000..1fb72f6
--- /dev/null
@@ -0,0 +1,252 @@
+<?php
+/**
+ * Test the inetOrgPerson object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the inetOrgPerson object.
+ *
+ * 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_Integration_InetorgpersonTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default inetOrgPerson */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Inetorgperson',
+            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
+            'Sn'           => 'Mustermann',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+        /* Invalid person (no sn) */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Inetorgperson',
+            'Cn'           => 'Kolab_Server_OrgPersonTest_123',
+            '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',
+            'Sn'           => 'Mustermann',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+    );
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        foreach ($this->servers as $server) {
+            $a = new Horde_Kolab_Server_Object_Inetorgperson($server, null, $this->objects[0]);
+            $this->assertContains('Frank Mustermann',
+                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
+        }
+    }
+
+    /**
+     * Test adding an invalid person.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidPerson()
+    {
+        $this->addToServers($this->objects[1]);
+    }
+
+    /**
+     * Test a person with middle names.
+     *
+     * @return NULL
+     */
+    public function testHandlePersonWithMiddleNames()
+    {
+        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]));
+
+            $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'));
+
+            $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 => ''));
+
+            $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'));
+
+            $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 => ''));
+
+            $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'));
+
+            $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 => ''));
+        }
+    }
+
+    /**
+     * Test handling labeled URIs.
+     *
+     * @return NULL
+     */
+    public function testHandleLabeledUris()
+    {
+        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()));
+
+            $this->assertStoreFetch($person, $server,
+                                    array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => 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'),
+                                                                                                                 'b' => array('http://b.example.com'))));
+
+            $this->assertStoreFetch($person, $server,
+                                    array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => 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'),
+                                                                                                                 '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()));
+
+            $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'))));
+        }
+    }
+
+
+    /**
+     * Test handling the home postal address.
+     *
+     * @return NULL
+     */
+    public function testHandlingHomePostalAddress()
+    {
+        //@todo
+    }
+
+    /**
+     * Test handling easy attributes.
+     *
+     * @return NULL
+     */
+    public function testEasyAttributes()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_SID => ''));
+            $this->assertEasyAttributes($person, $server,
+                                        array(
+                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_SID => array(
+                                                'user',
+                                                '0',
+                                                'somebody',
+                                                null,
+                                                '',
+                                                array('he', 'she'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_ORGANIZATION => array(
+                                                'them',
+                                                '0',
+                                                'somebody',
+                                                null,
+                                                '',
+                                                array('they', 'we'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_BUSINESSCATEGORY => array(
+                                                'them',
+                                                '0',
+                                                'somebody',
+                                                null,
+                                                '',
+                                                array('they', 'we'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_HOMEPHONE => array(
+                                                '123456789',
+                                                '+1234567890',
+                                                array('1', '2'),
+                                                null,
+                                                '0'
+                                            ),
+                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MOBILE => array(
+                                                '123456789',
+                                                '+1234567890',
+                                                array('1', '2'),
+                                                null,
+                                                '0'
+                                            ),
+                                        )
+            );
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/KolabgermanbankarrangementTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/KolabgermanbankarrangementTest.php
new file mode 100644 (file)
index 0000000..39fc2a0
--- /dev/null
@@ -0,0 +1,176 @@
+<?php
+/**
+ * Test the kolabGermanBankArrangement object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the kolabGermanBankArrangement object.
+ *
+ * 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_Integration_KolabgermanbankarrangementTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default bank account owner */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
+            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
+            'Sn'           => 'Mustermann',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+        /* Default account */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabgermanbankarrangement',
+            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER   => '0123456789',
+            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_BANKCODE => '1111111',
+        ),
+    );
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $account_data = $this->objects[1];
+            $account_data[Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID] = $person->getUid();
+            $a = new Horde_Kolab_Server_Object_Kolabgermanbankarrangement($server, null, $account_data);
+            $this->assertContains(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER . '=' . $this->objects[1][Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER],
+                                  $a->get(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_UID));
+        }
+    }
+
+    /**
+     * Test adding an invalid Account.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidAccount()
+    {
+        $this->addToServers($this->objects[1]);
+    }
+
+    /**
+     * Test handling easy attributes.
+     *
+     * @return NULL
+     */
+    public function testEasyAttributes()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $account_data = $this->objects[1];
+            $account_data[Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID] = $person->getUid();
+            $account = $this->assertAdd($server, $account_data,
+                                        array(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID => $person->getUid()));
+            $this->assertEasyAttributes($account, $server,
+                                        array(
+                                            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_HOLDER => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                array('a', 'b'),
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_BANKNAME => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                array('a', 'b'),
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_INFO => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                array('a', 'b'),
+                                                '',
+                                            ),
+                                        )
+            );
+        }
+    }
+
+    /**
+     * Test modifying the account number of an account. This should have an
+     * effect on the UID of the object and needs to rename the object.
+     *
+     * @return NULL
+     */
+    public function testModifyAccountNumber()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $account_data = $this->objects[1];
+            $account_data[Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID] = $person->getUid();
+            $account = $server->add($account_data);
+            $this->assertNoError($account);
+
+            $account = $server->fetch($account->getUid());
+            $this->assertNoError($account);
+
+            $this->assertEquals($this->objects[1][Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER],
+                                $account->get(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER));
+
+            $result = $account->save(array(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER => '66666666'));
+            $this->assertNoError($result);
+
+            $account = $server->fetch($account->getUid());
+            $this->assertNoError($account);
+
+            $this->assertEquals($account->get(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER),
+                                '66666666');
+
+            $result = $server->delete($account->getUid());
+            $this->assertNoError($result);
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/KolabinetorgpersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/KolabinetorgpersonTest.php
new file mode 100644 (file)
index 0000000..6a3a0a9
--- /dev/null
@@ -0,0 +1,295 @@
+<?php
+/**
+ * Test the kolabInetOrgPerson object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the kolabInetOrgPerson object.
+ *
+ * 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_Integration_KolabinetorgpersonTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default kolabInetOrgPerson */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
+            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
+            'Sn'           => 'Mustermann',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+        /* Invalid person (no sn) */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
+            'Cn'           => 'Kolab_Server_OrgPersonTest_123',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+    );
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        foreach ($this->servers as $server) {
+            $a = new Horde_Kolab_Server_Object_Kolabinetorgperson($server, null, $this->objects[0]);
+            $this->assertContains('Frank Mustermann',
+                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
+        }
+    }
+
+    /**
+     * Test adding an invalid person.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidPerson()
+    {
+        $this->addToServers($this->objects[1]);
+    }
+
+    /**
+     * Test handling easy attributes.
+     *
+     * @return NULL
+     */
+    public function testEasyAttributes()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $this->assertEasyAttributes($person, $server,
+                                        array(
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GERMANTAXID => array(
+                                                '01234567890123456789',
+                                                '0',
+                                                '101',
+                                                null,
+                                                'DE',
+                                                array('101', '202'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_HOMESERVER => array(
+                                                'a.b.c',
+                                                '',
+                                                'jodeldodel',
+                                                null,
+                                                array('a.example.com', 'b.example.com'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_QUOTA => array(
+                                                '100',
+                                                null,
+                                                array('0', '1000'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALLOWEDRECIPIENTS => array(
+                                                '-a@example.com', 
+                                                '',
+                                                array('a', 'b'),
+                                                null,
+                                                '0'
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALLOWEDFROM => array(
+                                                '-a@example.com', 
+                                                '',
+                                                array('a', 'b'),
+                                                null,
+                                                '0'
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SALUTATION => array(
+                                                'Herr', 
+                                                'Mrs.',
+                                                null,
+                                                array('Herr', 'Mrs.'),
+                                                '0'
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GENDER => array(
+                                                '1',
+                                                null,
+                                                '0',
+                                                '2',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_BIRTHNAME => array(
+                                                'Adam',
+                                                null,
+                                                '',
+                                                '0',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_PLACEOFBIRTH => array(
+                                                'Jotwede',
+                                                null,
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_COUNTRY => array(
+                                                'DE',
+                                                'SE',
+                                                null,
+                                                'DE',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_COUNTRYCITIZENSHIP => array(
+                                                'DE',
+                                                'SE',
+                                                //@todo: "null" does not work. Why?
+                                                //null,
+                                                'DE',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_LEGALFORM => array(
+                                                'GmbH',
+                                                'Freelancer',
+                                                null,
+                                                'Freelancer',
+                                            ),
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_REGISTEREDCAPITAL => array( */
+                                            /*                                             '1212121211', */
+                                            /*                                             '0', */
+                                            /*                                             null, */
+                                            /*                                             '' */
+                                            /*                                         ), */
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_BYLAWURI => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                             '', */
+                                            /*                                         ), */
+
+                                            //@todo: Alias support
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DATEOFINCORPORATION => array( */
+                                            /*                                             '199911220707Z', */
+                                            /*                                         ), */
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_LEGALREPRESENTATIONPOLICY => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                             '', */
+                                            /*                                         ), */
+
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_VATNUMBER => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                array('a', 'b'),
+                                            ),
+
+                                            //@todo: Undefined
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_OTHERLEGAL => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                         ), */
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_INLIQUIDATION => array( */
+                                            /*                                             'TRUE', */
+                                            /*                                             'FALSE', */
+                                            /*                                             null, */
+                                            /*                                             array('TRUE', 'FALSE'), */
+                                            /*                                         ), */
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRTYPE => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                         ), */
+
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRLOCATION => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                'somewhere',
+                                            ),
+
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRIDENTIFIER => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                'somewhere',
+                                            ),
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRURI => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                         ), */
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRLASTCHANGED => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                         ), */
+
+                                            // @todo: Undefined in object class
+                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DC => array( */
+                                            /*                                             'something', */
+                                            /*                                             'somewhere', */
+                                            /*                                             null, */
+                                            /*                                             array('a', 'b'), */
+                                            /*                                         ), */
+
+                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALIAS => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                array('a', 'b'),
+                                            ),
+
+                                        )
+            );
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/Kolabpop3accountTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/Kolabpop3accountTest.php
new file mode 100644 (file)
index 0000000..084d6a1
--- /dev/null
@@ -0,0 +1,207 @@
+<?php
+/**
+ * Test the kolabExternalPop3Account object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the kolabExternalPop3Account object.
+ *
+ * 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_Integration_Kolabpop3accountTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default bank account owner */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
+            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
+            'Sn'           => 'Mustermann',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+        /* Default account */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabpop3account',
+            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL      => 'frank@example.com',
+            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER    => 'pop.example.com',
+            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_LOGINNAME => 'frank',
+            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PASSWORD  => 'test',
+        ),
+    );
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $account_data = $this->objects[1];
+            $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid();
+            $a = new Horde_Kolab_Server_Object_Kolabpop3account($server, null, $account_data);
+            $this->assertContains(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL . '=' . $this->objects[1][Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL],
+                                  $a->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_UID));
+        }
+    }
+
+    /**
+     * Test adding an invalid Account.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidAccount()
+    {
+        $this->addToServers($this->objects[1]);
+    }
+
+    /**
+     * Test handling easy attributes.
+     *
+     * @return NULL
+     */
+    public function testEasyAttributes()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $account_data = $this->objects[1];
+            $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid();
+            $account = $this->assertAdd($server, $account_data,
+                                        array(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID => $person->getUid()));
+            $this->assertEasyAttributes($account, $server,
+                                        array(
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PASSWORD => array(
+                                                'something',
+                                                'somewhere',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_DESCRIPTION => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => array(
+                                                'something',
+                                                'somewhere',
+                                                array('a', 'b'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PORT => array(
+                                                '110',
+                                                '111',
+                                                null,
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_USESSL => array(
+                                                'TRUE',
+                                                'FALSE',
+                                                null,
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_USETLS => array(
+                                                'TRUE',
+                                                'FALSE',
+                                                null,
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_LOGINMETHOD => array(
+                                                'something',
+                                                'somewhere',
+                                                null,
+                                                array('a', 'b'),
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_CHECKCERTIFICATE => array(
+                                                'TRUE',
+                                                'FALSE',
+                                                null,
+                                                '',
+                                            ),
+                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_KEEPMAILONSERVER => array(
+                                                'TRUE',
+                                                'FALSE',
+                                                null,
+                                                '',
+                                            ),
+                                        )
+            );
+        }
+    }
+
+    /**
+     * Test modifying the attributes required for the UID of the account. This
+     * should lead to renaming object.
+     *
+     * @return NULL
+     */
+    public function testModifyUidElements()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+            $account_data = $this->objects[1];
+            $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid();
+            $account = $server->add($account_data);
+            $account = $server->fetch($account->getUid());
+
+            $this->assertEquals($this->objects[1][Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER],
+                                $account->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER));
+
+            $result = $account->save(array(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => 'pop3s.example.com'));
+
+            $account = $server->fetch($account->getUid());
+
+            $this->assertContains(
+                'pop3s.example.com',
+                $account->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER, false)
+            );
+
+            $this->assertContains('frank@example.com', $account->getUid());
+
+            $result = $server->delete($account->getUid());
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/MockTest.php
new file mode 100644 (file)
index 0000000..7433cdb
--- /dev/null
@@ -0,0 +1,435 @@
+<?php
+/**
+ * Test the test driver.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the test backend.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Integration_MockTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /** The file based mock environment */
+    const ENVIRONMENT_FILE = 'file';
+
+    /**
+     * The environments we provide to the test.
+     *
+     * @var array
+     */
+    protected $_environments = array(
+        self::ENVIRONMENT_MOCK,
+        self::ENVIRONMENT_FILE
+    );
+
+    /**
+     * Prepare the server configuration for the given environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function prepareKolabServerConfiguration($environment)
+    {
+        switch ($environment) {
+        case self::ENVIRONMENT_FILE:
+            /** Prepare a Kolab test server */
+            $config = new stdClass;
+            $config->driver = 'file';
+            $config->params = array(
+                'file'     => Horde::getTempFile('fileTest'),
+                'basedn'   => 'dc=example,dc=org',
+                'hashtype' => 'plain'
+            );
+            $this->world['injector'][$environment]->setInstance('Horde_Kolab_Server_Config', $config);
+            break;
+        default:
+            return parent::prepareKolabServerConfiguration($environment);
+        }
+    }
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    public function setUp()
+    {
+        parent::setUp();
+
+        if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
+            $this->markTestSuiteSkipped('Ldap extension is missing!');
+        };
+
+        /** Hide strict errors from the Net_LDAP2 library */
+        $error_reporting = error_reporting();
+        error_reporting($error_reporting & ~E_STRICT);
+
+        if (!class_exists('Net_LDAP2')) {
+            $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
+        }
+
+        /** Reactivate original error reporting */
+        error_reporting($error_reporting);
+
+        $this->markTestIncomplete('Needs to be fixed');
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+        foreach ($this->servers as $server) {
+            $this->addBasicUsersToServer($server);
+        }
+    }
+
+    /**
+     * Test search base.
+     *
+     * @return NULL
+     */
+    public function testSearchBase()
+    {
+        foreach ($this->servers as $server) {
+            $result = $server->search(
+                '(' . Horde_Kolab_Server_Object::ATTRIBUTE_OC
+                . '=' . Horde_Kolab_Server_Object::OBJECTCLASS_TOP . ')',
+                array(Horde_Kolab_Server_Object::ATTRIBUTE_OC));
+            $this->assertEquals(13, count($result));
+      
+            $result = $server->search(
+                '(' . Horde_Kolab_Server_Object::ATTRIBUTE_OC
+                . '=' . Horde_Kolab_Server_Object::OBJECTCLASS_TOP . ')',
+                array(Horde_Kolab_Server_Object::ATTRIBUTE_OC),
+                'cn=internal,dc=example,dc=org');
+            $this->assertEquals(4, count($result));
+        }
+    }
+
+    /**
+     * Test sorting.
+     *
+     * @return NULL
+     */
+    public function testSorting()
+    {
+        foreach ($this->servers as $server) {
+
+/*         $result = $server->search('(mail=*)', array('mail')); */
+/*         $this->assertEquals(5, count($result)); */
+/*         $server->sort($result, 'mail'); */
+/*         foreach ($result as $object) { */
+/*             if (isset($object['data']['dn'])) { */
+/*                 switch ($object['data']['dn']) { */
+/*                 case 'cn=Test Address,cn=external,dc=example,dc=org': */
+/*                     $this->assertContains('address@example.org', $object['data']['mail']); */
+/*                     break; */
+/*                 case '': */
+/*                     $this->assertContains('address@example.org', $object['data']['mail']); */
+/*                     break; */
+/*                 } */
+/*             } */
+/*         } */
+        }
+    }
+
+    /**
+     * Test listing objects.
+     *
+     * @return NULL
+     */
+    public function testListObjects()
+    {
+        foreach ($this->servers as $server) {
+            $filter     = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
+            $attributes = array(
+                'Sn',
+                'Cn',
+                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_UID,
+                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_MAIL,
+                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DELETED,
+            );
+
+            $sort   = 'Sn';
+            $result = $server->search($filter);
+            $this->assertEquals(2, count($result));
+
+            $result = $server->listObjects('Horde_Kolab_Server_Object_Kolab_User');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class(array_shift($result)));
+
+            $result = $server->listObjects('Horde_Kolab_Server_Object_Kolabsharedfolder');
+            $this->assertEquals(1, count($result));
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolabsharedfolder', get_class(array_shift($result)));
+        }
+    }
+
+    /**
+     * Test handling of object classes.
+     *
+     * @return NULL
+     */
+    public function testGetObjectClasses()
+    {
+        foreach ($this->servers as $server) {
+            $classes = $server->getObjectClasses('cn=Gunnar Wrobel,dc=example,dc=org');
+            $this->assertContains('top', $classes);
+            $this->assertContains('kolabinetorgperson', $classes);
+
+            try {
+                $classes = $server->getObjectClasses('cn=DOES NOT EXIST,dc=example,dc=org');
+            } catch (Horde_Kolab_Server_Exception $classes) {
+            }
+            $this->assertError($classes,
+                               'No such object: cn=DOES NOT EXIST,dc=example,dc=org');
+
+            $classes = $server->getObjectClasses('cn=The Administrator,dc=example,dc=org');
+            $this->assertContains('kolabinetorgperson', $classes);
+        }
+    }
+
+    /**
+     * Test handling of object types.
+     *
+     * @return NULL
+     */
+    public function testDetermineType()
+    {
+        foreach ($this->servers as $server) {
+            $type = $server->determineType('cn=empty.group@example.org,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolabgroupofnames', $type);
+
+            $type = $server->determineType('cn=shared@example.org,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolabsharedfolder', $type);
+
+            $type = $server->determineType('cn=The Administrator,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Administrator', $type);
+
+            $type = $server->determineType('cn=Main Tainer,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Maintainer', $type);
+
+            $type = $server->determineType('cn=Domain Maintainer,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Domainmaintainer', $type);
+
+            $type = $server->determineType('cn=Test Address,cn=external,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Address', $type);
+
+            $type = $server->determineType('cn=Gunnar Wrobel,dc=example,dc=org');
+            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', $type);
+        }
+    }
+
+    /**
+     * Test retrieving a primary mail for a mail or id.
+     *
+     * @return NULL
+     */
+    public function testMailForIdOrMail()
+    {
+        foreach ($this->servers as $server) {
+            $mail = $server->mailForIdOrMail('wrobel');
+            $this->assertEquals('wrobel@example.org', $mail);
+
+            $mail = $server->mailForIdOrMail('wrobel@example.org');
+            $this->assertEquals('wrobel@example.org', $mail);
+
+            $mail = $server->mailForIdOrMail('DOES NOT EXIST');
+            $this->assertSame(false, $mail);
+        }
+    }
+
+    /**
+     * Test retrieving a UID for a mail or id.
+     *
+     * @return NULL
+     */
+    public function testUidForIdOrMail()
+    {
+        foreach ($this->servers as $server) {
+            $uid = $server->uidForIdOrMail('wrobel');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMail('wrobel@example.org');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMail('DOES NOT EXIST');
+            $this->assertSame(false, $uid);
+        }
+    }
+
+    /**
+     * Test retrieving a UID for a mail or id.
+     *
+     * @return NULL
+     */
+    public function testUidForMailOrIdOrAlias()
+    {
+        foreach ($this->servers as $server) {
+            $uid = $server->uidForIdOrMailOrAlias('g.wrobel@example.org');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMailOrAlias('wrobel@example.org');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMailOrAlias('wrobel');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMailOrAlias('DOES NOT EXIST');
+            $this->assertSame(false, $uid);
+        }
+    }
+
+    /**
+     * Test retrieving all addresses for a mail or id.
+     *
+     * @return NULL
+     */
+    public function testAddrsForIdOrMail()
+    {
+        foreach ($this->servers as $server) {
+            $addrs = $server->addrsForIdOrMail('wrobel');
+
+            $testuser = $server->fetch('cn=Test Test,dc=example,dc=org');
+            $this->assertContains('wrobel@example.org',
+                                  $testuser->get(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DELEGATE, false));
+
+            $this->assertContains('wrobel@example.org', $addrs);
+            $this->assertContains('test@example.org', $addrs);
+            $this->assertContains('t.test@example.org', $addrs);
+            $this->assertContains('g.wrobel@example.org', $addrs);
+            $this->assertContains('gunnar@example.org', $addrs);
+
+            $addrs = $server->addrsForIdOrMail('test@example.org');
+            $this->assertContains('test@example.org', $addrs);
+            $this->assertContains('t.test@example.org', $addrs);
+        }
+    }
+
+    /**
+     * Test retrieving a UID for a primary mail.
+     *
+     * @return NULL
+     */
+    public function testUidForMailAddress()
+    {
+        foreach ($this->servers as $server) {
+            $uid = $server->uidForIdOrMailOrAlias('wrobel@example.org');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMailOrAlias('test@example.org');
+            $this->assertEquals('cn=Test Test,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMailOrAlias('gunnar@example.org');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+
+            $uid = $server->uidForIdOrMailOrAlias('wrobel');
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+        }
+    }
+
+    /**
+     * Test retrieving a UID for an attribute.
+     *
+     * @return NULL
+     */
+    public function testUidForAttr()
+    {
+        foreach ($this->servers as $server) {
+            $uid = $server->uidForSearch(array('AND' => array(array('field' => 'alias',
+                                                                    'op' => '=',
+                                                                    'test' => 'g.wrobel@example.org'))));
+            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
+        }
+    }
+
+    /**
+     * Test group membership testing.
+     *
+     * @return NULL
+     */
+    public function testMemberOfGroupAddress()
+    {
+        foreach ($this->servers as $server) {
+            $uid = $server->uidForIdOrMailOrAlias('g.wrobel@example.org');
+            $member = $server->memberOfGroupAddress($uid, 'group@example.org');
+            $this->assertTrue($member);
+
+            $member = $server->memberOfGroupAddress(
+                $server->uidForIdOrMailOrAlias('test@example.org'),
+                'group@example.org');
+            $this->assertTrue($member);
+
+            $member = $server->memberOfGroupAddress(
+                $server->uidForIdOrMailOrAlias('somebody@example.org'),
+                'group@example.org');
+            $this->assertFalse($member);
+        }
+    }
+
+    /**
+     * Test group fetching.
+     *
+     * @return NULL
+     */
+    public function testGetGroups()
+    {
+        foreach ($this->servers as $server) {
+            $filter = '(&(objectClass=kolabGroupOfNames)(member='
+                . Net_LDAP2_Util::escape_filter_value('cn=The Administrator,dc=example,dc=org') . '))';
+            $result = $server->search($filter, array());
+            $this->assertTrue(!empty($result));
+
+            /*         $entry = $server->_firstEntry($result); */
+            /*         $this->assertTrue(!empty($entry)); */
+
+            /*         $uid = $server->_getDn($entry); */
+            /*         $this->assertTrue(!empty($uid)); */
+
+            /*         $entry = $server->_nextEntry($entry); */
+            /*         $this->assertTrue(empty($entry)); */
+
+            /*         $entries = $server->_getDns($result); */
+            /*         $this->assertTrue(!empty($entries)); */
+
+            $groups = $server->getGroups('cn=The Administrator,dc=example,dc=org');
+            $this->assertTrue(!empty($groups));
+
+            $groups = $server->getGroups($server->uidForIdOrMailOrAlias('g.wrobel@example.org'));
+            $this->assertContains('cn=group@example.org,dc=example,dc=org', $groups);
+
+            $groups = $server->getGroupAddresses($server->uidForIdOrMailOrAlias('g.wrobel@example.org'));
+            $this->assertContains('group@example.org', $groups);
+
+            $groups = $server->getGroups($server->uidForIdOrMailOrAlias('test@example.org'));
+            $this->assertContains('cn=group@example.org,dc=example,dc=org', $groups);
+
+            $groups = $server->getGroupAddresses($server->uidForIdOrMailOrAlias('test@example.org'));
+            $this->assertContains('group@example.org', $groups);
+
+            $groups = $server->getGroups('nobody');
+            $this->assertTrue(empty($groups));
+        }
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/ObjectTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/ObjectTest.php
new file mode 100644 (file)
index 0000000..187b34f
--- /dev/null
@@ -0,0 +1,234 @@
+<?php
+/**
+ * Test the object class.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * The the handling of objects.
+ *
+ * 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_ObjectTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /**
+     * Set up a dummy db object that will not be used during the
+     * tests. We just need it so that PHP does not complain about the
+     * inability to refernce the storage class.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->_dummydb = new DummyDB();
+    }
+
+    /**
+     * Provide test data for the ConstructDn test.
+     *
+     * @return array The test object data.
+     */
+    public static function provideConstructDn()
+    {
+        return array(
+            array('test', null, 'test'),
+            array(false, array('dn' => 'test'), 'test'),
+            array(false, array('dn' => array('test')), 'test'),
+            array('test2', array('dn' => array('test')), 'test2'),
+        );
+    }
+
+    /**
+     * Check a few DN values when constructing the object.
+     *
+     * @param string $dn     The uid for the object.
+     * @param string $data   Object data.
+     * @param string $expect Expect this uid.
+     *
+     * @dataProvider provideConstructDn
+     *
+     * @return NULL
+     */
+    public function testConstructDn($dn, $data, $expect)
+    {
+        $ko  = new Horde_Kolab_Server_Object($this->_dummydb, $dn, $data);
+        $ndn = $ko->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_UID);
+        $this->assertNoError($ndn);
+        $this->assertEquals($expect, $ndn);
+    }
+
+    /**
+     * Provide test data for the GetFn test.
+     *
+     * @return array The test object data.
+     */
+    public static function provideGetFn()
+    {
+        return array(
+            array(
+                array(
+                    'dn' => 'test',
+                    'cn' => 'Frank Mustermann',
+                    'sn' => 'Mustermann'),
+                'Frank'));
+    }
+
+    /**
+     * Check the generating of the "First Name" attribute.
+     *
+     * @param string $data   Object data.
+     * @param string $expect Expect this full name.
+     *
+     * @dataProvider provideGetFn
+     *
+     * @return NULL
+     */
+    public function testGetFn($data, $expect)
+    {
+        $ko = &Horde_Kolab_Server_Object::factory('Horde_Kolab_Server_Object_Kolab_User',
+                                                  null, $this->_dummydb, $data);
+        $this->assertNoError($ko);
+        $ndn = $ko->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN);
+        $this->assertNoError($ndn);
+        $this->assertEquals($expect, $ndn);
+    }
+
+
+    /**
+     * Provide test data for the GetFn test.
+     *
+     * @return array The test object data.
+     */
+    public static function provideGetArrayChanges()
+    {
+        return array(
+            array(
+                array(
+                    array(
+                        'a',
+                    ),
+                    array(
+                        'a',
+                    ),
+                ),
+                true,
+            ),
+            array(
+                array(
+                    array(
+                        'a',
+                    ),
+                    array(
+                        'b',
+                    ),
+                ),
+                false,
+            ),
+            array(
+                array(
+                    array(
+                    ),
+                    array(
+                        'a' => 'b',
+                    ),
+                ),
+                false,
+            ),
+            array(
+                array(
+                    array(
+                    ),
+                    array(
+                        'b',
+                    ),
+                ),
+                false,
+            ),
+        );
+    }
+
+    /**
+     * Check the generating of the "First Name" attribute.
+     *
+     * @param string $data   Object data.
+     * @param string $expect Expect this full name.
+     *
+     * @dataProvider provideGetArrayChanges
+     *
+     * @return NULL
+     */
+    public function testGetArrayChanges($data, $expect)
+    {
+        $ko = &Horde_Kolab_Server_Object::factory('Horde_Kolab_Server_Object_Kolab_User',
+                                                  null, $this->_dummydb, array(
+                                                      'dn' => 'test',
+                                                      'cn' => 'Frank Mustermann',
+                                                      'sn' => 'Mustermann'));
+        $this->assertNoError($ko);
+        $c = $ko->getArrayChanges($data[0], $data[1]);
+        $this->assertEquals($expect, empty($c));
+    }
+
+}
+
+/**
+ * A dummy class for testing.
+ *
+ * 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 DummyDB
+{
+    public function getAttributes()
+    {
+        return array(array(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_UID => array(
+                               'method' => 'getUid',
+                           ),
+                           Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN => array(
+                               'method' => 'getFn',
+                           )),
+              array(
+                  'derived'  => array(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_UID,
+                                      Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN,
+                  ),
+                  'locked'   => array(),
+                  'required' => array()));
+    }
+
+    public function read()
+    {
+        return false;
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/OrgPersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/OrgPersonTest.php
new file mode 100644 (file)
index 0000000..f46ff75
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/**
+ * Test the organizationalPerson object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the organizationalPerson object.
+ *
+ * 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_Integration_OrgPersonTest extends Horde_Kolab_Server_Integration_Scenario
+{
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default organizationalPerson */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Organizationalperson',
+            'Cn'           => 'Kolab_Server_OrgPersonTest_123',
+            'Sn'           => 'Kolab_Server_OrgPersonTest_123',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+        /* Invalid person (no sn) */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Organizationalperson',
+            'Cn'           => 'Kolab_Server_OrgPersonTest_123',
+            'Userpassword' => 'Kolab_Server_OrgPersonTest_123',
+        ),
+    );
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        foreach ($this->servers as $server) {
+            $a = new Horde_Kolab_Server_Object_Organizationalperson($server, null, $this->objects[0]);
+            $this->assertContains(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN . '=' . $this->objects[0][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN],
+                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
+        }
+    }
+
+    /**
+     * Test adding an invalid person.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidPerson()
+    {
+        $this->addToServers($this->objects[1]);
+    }
+
+    /**
+     * Test handling simple attributes.
+     *
+     * @return NULL
+     */
+    public function testSimpleAttributes()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_JOBTITLE => ''));
+            $this->assertSimpleAttributes($person, $server,
+                                          array(
+                                          ));
+        }
+    }
+
+    /**
+     * Test handling the postal address.
+     *
+     * @return NULL
+     */
+    public function testHandlingAPostalAddress()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => 'Kolab_Server_OrgPersonTest_123$$ '));
+
+            $this->assertStoreFetch($person, $server,
+                                    array('Sn' => 'Kolab_Server_OrgPersonTest_456'),
+                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_456$$ ')));
+
+            $this->assertStoreFetch($person, $server,
+                                    array('Sn' => 'Kolab_Server_OrgPersonTest_123',
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_STREET => 'Street 1',
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALCODE => '12345',
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_CITY => 'Nowhere'),
+                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_123$Street 1$12345 Nowhere')));
+            $this->assertStoreFetch($person, $server,
+                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTOFFICEBOX => 'öäü/)(="§%$&§§$\'*',
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_STREET => null),
+                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_123$öäü/)(="§%\24&§§\24\'*$12345 Nowhere')));
+
+            $this->assertStoreFetch($person, $server,
+                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_STREET => null,
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALCODE => null,
+                                          //@todo: Why does this need a string?
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => '',
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTOFFICEBOX => null,
+                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_CITY => null),
+                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_123$$ ')));
+        }
+    }
+
+
+    /**
+     * Test handling easy attributes.
+     *
+     * @return NULL
+     */
+    public function testEasyAttributes()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[0],
+                                       array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_JOBTITLE => ''));
+            $this->assertEasyAttributes($person, $server,
+                                        array(
+                                            Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_JOBTITLE => array(
+                                                'Teacher',
+                                                '0',
+                                                'Something',
+                                                null,
+                                                '',
+                                                array('This', 'That'),
+                                            ),
+                                            Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_FAX => array(
+                                                '123456789',
+                                                '+1234567890',
+                                                array('1', '2'),
+                                                '0',
+                                                //@todo: How to delete?
+                                                //null
+                                            )
+                                        )
+            );
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/PersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/PersonTest.php
new file mode 100644 (file)
index 0000000..3dd2fa2
--- /dev/null
@@ -0,0 +1,279 @@
+<?php
+/**
+ * Test the person object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the person object.
+ *
+ * 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_Integration_PersonTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    public $cn = 'Kolab_Server_PersonTest';
+
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default dummy person */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_123',
+            'Sn'           => 'Kolab_Server_PersonTest_123',
+            'Userpassword' => 'Kolab_Server_PersonTest_123',
+        ),
+        /* Invalid person (no sn) */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_123',
+            'Userpassword' => 'Kolab_Server_PersonTest_123',
+        ),
+        /* Person with problematic characters */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_!"$%&()=?',
+            'Sn'           => 'Kolab_Server_PersonTest_!"$%&()=?',
+            'Userpassword' => 'Kolab_Server_PersonTest_!"$%&()=?',
+        ),
+        /* Person with difficult encoding */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_ügöräß§',
+            'Sn'           => 'Kolab_Server_PersonTest_ügöräß§',
+            'Userpassword' => 'Kolab_Server_PersonTest_ügöräß§',
+        ),
+        /* Person with forward slash */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_/',
+            'Sn'           => 'Kolab_Server_PersonTest_/',
+            'Userpassword' => 'Kolab_Server_PersonTest_/',
+        ),
+        /* Person with double cn */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => array('Kolab_Server_PersonTest_cn1',
+                                                                              'Kolab_Server_PersonTest_cn2'),
+            'Sn'           => 'Kolab_Server_PersonTest_cncn',
+            'Userpassword' => 'Kolab_Server_PersonTest_cncn',
+        ),
+        /* Person with name suffix*/
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_123',
+            'Sn'           => 'Kolab_Server_PersonTest_123',
+            'Userpassword' => 'Kolab_Server_PersonTest_123',
+        ),
+        /* Person for telephone number handling*/
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_123456',
+            'Sn'           => 'Kolab_Server_PersonTest_123456',
+            'Userpassword' => 'Kolab_Server_PersonTest_123456',
+        ),
+        /* Person with a creation date*/
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Person',
+            'Cn'           => 'Kolab_Server_PersonTest_123456',
+            'Sn'           => 'Kolab_Server_PersonTest_123456',
+            'Userpassword' => 'Kolab_Server_PersonTest_123456',
+            'Creationdate' => '191008030000Z',
+        ),
+    );
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->initializeEnvironments();
+        $this->servers = $this->getKolabServers();
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        foreach ($this->servers as $server) {
+            $a = new Horde_Kolab_Server_Object_Person($server, null, $this->objects[0]);
+            $this->assertContains('Cn' . '=' . $this->objects[0]['Cn'],
+                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
+        }
+    }
+
+    /**
+     * Test adding an invalid person.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidPerson()
+    {
+        $this->addToServers($this->objects[1]);
+    }
+
+    /**
+     * Test adding a person.
+     *
+     * @return NULL
+     */
+    public function testAddPerson()
+    {
+        foreach ($this->servers as $server) {
+            $adds = array(0, 2, 3, 4);
+            foreach ($adds as $add) {
+                $result = $server->add($this->objects[$add]);
+                $this->assertNoError($result);
+                $cn_result = $server->uidForCn($this->objects[$add]['Cn']);
+                $this->assertNoError($cn_result);
+                $dn_parts = Net_LDAP2_Util::ldap_explode_dn($cn_result, array('casefold' => 'lower'));
+                $dnpart = Net_LDAP2_Util::unescape_dn_value($dn_parts[0]);
+                /**
+                 * @todo: I currently do not really understand why the forward slash
+                 * is not correctly converted back but I lack the time to analyse it
+                 * in detail. The server entry looks okay.
+                 */
+                $dnpart = str_replace('\/', '/', $dnpart);
+                $this->assertContains('Cn' . '=' . $this->objects[$add]['Cn'],
+                                      $dnpart[0]);
+                $result = $server->delete($cn_result);
+                $this->assertNoError($result);
+                $cn_result = $server->uidForCn($this->objects[$add]['Cn']);
+                $this->assertNoError($cn_result);
+                $this->assertFalse($server->uidForCn($this->objects[$add]['Cn']));
+            }
+        }
+    }
+
+    /**
+     * Test modifying the surname of a person.
+     *
+     * @return NULL
+     */
+    public function testModifyPersonSn()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[2],
+                                       array('Cn' => $this->objects[2]['Cn']));
+            $this->assertSimpleSequence($person, $server,
+                                        'Sn',
+                                        array('modified', 'modified_again'), true);
+        }
+    }
+
+    /**
+     * Test modifying the cn of a person. This should have an effect on the UID
+     * of the object and needs to rename the object.
+     *
+     * @return NULL
+     */
+    public function testModifyPersonCn()
+    {
+        foreach ($this->servers as $server) {
+            $person = $server->add($this->objects[2]);
+            $this->assertNoError($person);
+
+            $person = $server->fetch($person->getUid());
+
+            $this->assertEquals($this->objects[2]['Cn'],
+                                $person->get('Cn'));
+
+            $result = $person->save(array('Cn' => 'Kolab_Server_PersonTest_äö'));
+            $cn_result = $server->uidForCn('Kolab_Server_PersonTest_äö');
+            $person = $server->fetch($cn_result);
+            $this->assertEquals($person->get('Cn'),
+                                'Kolab_Server_PersonTest_äö');
+            $result = $server->delete($cn_result);
+            $this->assertNoError($result);
+            $cn_result = $server->uidForCn('Kolab_Server_PersonTest_äö');
+            $this->assertNoError($cn_result);
+            $this->assertFalse($cn_result);
+        }
+    }
+
+    /**
+     * Test adding a person with two common names.
+     *
+     * @return NULL
+     */
+    public function testAddDoubleCnPerson()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[5],
+                                       array());
+
+            $cn_result = $server->uidForCn($this->objects[5]['Cn'][0]);
+            $this->assertNoError($cn_result);
+            $dn_parts = Net_LDAP2_Util::ldap_explode_dn($cn_result, array('casefold' => 'lower'));
+            $dnpart = Net_LDAP2_Util::unescape_dn_value($dn_parts[0]);
+            $this->assertContains('Cn' . '=' . $this->objects[5]['Cn'][0],
+                                  $dnpart[0]);
+        }
+    }
+
+    /**
+     * Test handling a phone number.
+     *
+     * @return NULL
+     */
+    public function testHandlingAPhoneNumaber()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[7],
+                                       array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_TELNO => ''));
+            $this->assertSimpleSequence($person, $server,
+                                        Horde_Kolab_Server_Object_Person::ATTRIBUTE_TELNO,
+                                        array('123456789', '+1234567890', array('1', '2'), null, '0'), true);
+        }
+    }
+
+    /**
+     * Test retrrieving a date.
+     *
+     * @return NULL
+     */
+    public function testGetDate()
+    {
+        foreach ($this->servers as $server) {
+            $person = $this->assertAdd($server, $this->objects[8],
+                                       array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_TELNO => ''));
+            $cdate = $person->get(Horde_Kolab_Server_Object_Person::ATTRDATE_CREATIONDATE);
+            $this->assertEquals('Horde_Date', get_class($cdate));
+            $this->assertEquals('1910-08-03 01:00:00', (string) $cdate);
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/Scenario.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/Scenario.php
new file mode 100644 (file)
index 0000000..e89160f
--- /dev/null
@@ -0,0 +1,1090 @@
+<?php
+/**
+ * Base for PHPUnit scenarios.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Test
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Share
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Base for PHPUnit scenarios.
+ *
+ * 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_Test
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Share
+ */
+class Horde_Kolab_Server_Integration_Scenario extends PHPUnit_Extensions_Story_TestCase
+{
+    /** The mock environment */
+    const ENVIRONMENT_MOCK = 'mock';
+
+    /** The real server environment */
+    const ENVIRONMENT_REAL = 'real';
+
+    /**
+     * The environments we provide to the test.
+     *
+     * @var array
+     */
+    protected $_environments;
+
+    /**
+     * Uid of added objects. Should be removed on tearDown.
+     *
+     * @var array
+     */
+    public $added;
+
+    /**
+     * Handle a "given" step.
+     *
+     * @param array  &$world    Joined "world" of variables.
+     * @param string $action    The description of the step.
+     * @param array  $arguments Additional arguments to the step.
+     *
+     * @return mixed The outcome of the step.
+     */
+    public function runGiven(&$world, $action, $arguments)
+    {
+        switch($action) {
+        case 'several injectors':
+            foreach ($this->getEnvironments() as $environment) {
+                $this->prepareInjector($environment);
+            }
+            break;
+        case 'several Kolab servers':
+        case 'the test environments':
+            $this->initializeEnvironments();
+            break;
+        case 'an empty Kolab server':
+            $world['server'] = $this->prepareKolabServer(self::ENVIRONMENT_MOCK);
+            break;
+        case 'a basic Kolab server':
+            $world['server'] = $this->prepareBasicKolabServer($world);
+            break;
+        default:
+            return $this->notImplemented($action);
+        }
+    }
+
+    /**
+     * Handle a "when" step.
+     *
+     * @param array  &$world    Joined "world" of variables.
+     * @param string $action    The description of the step.
+     * @param array  $arguments Additional arguments to the step.
+     *
+     * @return mixed The outcome of the step.
+     */
+    public function runWhen(&$world, $action, $arguments)
+    {
+        switch($action) {
+        case 'adding a Kolab server object':
+            $world['result']['add'] = $this->addToServers($arguments[0]);
+            break;
+        case 'adding an invalid Kolab server object':
+            try {
+                $world['result']['add'] = $this->addToServers($arguments[0]);
+            } catch (Horde_Kolab_Server_Exception $e) {
+                $world['result']['add'] = $e;
+            }
+            break;
+        case 'adding an object list':
+            foreach ($arguments[0] as $object) {
+                try {
+                    $world['result']['add'][] = $this->addToServers($object);
+                } catch (Horde_Kolab_Server_Exception $e) {
+                    $world['result']['add'] = $e;
+                    return;
+                }
+            }
+            $world['result']['add'] = true;
+            break;
+        case 'adding a distribution list':
+            $world['result']['add'] = $this->addToServers($this->provideDistributionList());
+            break;
+        case 'listing all users':
+            $world['list'] = $this->listObjectsOnServer('Horde_Kolab_Server_Object_Kolab_User');
+            break;
+        case 'listing all groups':
+            $world['list'] = $this->listObjectsOnServer('Horde_Kolab_Server_Object_Kolabgroupofnames');
+            break;
+        case 'listing all objects of type':
+            $world['list'] = $this->listObjectsOnServer($arguments[0]);
+            break;
+        case 'retrieving a hash list with all objects of type':
+            $world['list'] = array();
+            foreach ($this->world['injector'] as $injector) {
+                $server = $injector->getInstance('Horde_Kolab_Server');
+                $world['list'][] = $server->listHash($arguments[0]);
+            }
+            break;
+        default:
+            return $this->notImplemented($action);
+        }
+    }
+
+    /**
+     * Handle a "then" step.
+     *
+     * @param array  &$world    Joined "world" of variables.
+     * @param string $action    The description of the step.
+     * @param array  $arguments Additional arguments to the step.
+     *
+     * @return mixed The outcome of the step.
+     */
+    public function runThen(&$world, $action, $arguments)
+    {
+        switch($action) {
+        case 'the result should be an object of type':
+            if (!isset($world['result'])) {
+                $this->fail('Did not receive a result!');
+            }
+            $this->assertRecursiveType($world['result'], $arguments[0]);
+            break;
+        case 'the result indicates success.':
+            if (!isset($world['result'])) {
+                $this->fail('Did not receive a result!');
+            }
+            $this->assertNoError($world['result']);
+            break;
+        case 'the result should indicate an error with':
+            if (!isset($world['result'])) {
+                $this->fail('Did not receive a result!');
+            }
+            foreach ($world['result'] as $result) {
+                if ($result instanceOf Horde_Kolab_Server_Exception) {
+                    $this->assertEquals($arguments[0], $result->getMessage());
+                } else {
+                    $this->assertEquals($arguments[0], 'Action succeeded without an error.');
+                }
+            }
+            break;
+        case 'the list has a number of entries equal to':
+            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
+                $this->assertEquals('', $world['list']->getMessage());
+            } else {
+                $this->assertEquals($arguments[0], count($world['list']));
+            }
+            break;
+        case 'the list is an empty array':
+            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
+                $this->assertEquals('', $world['list']->getMessage());
+            } else {
+                $this->assertEquals(array(array()), $world['list']);
+            }
+            break;
+        case 'the list is an empty array':
+            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
+                $this->assertEquals('', $world['list']->getMessage());
+            } else {
+                $this->assertEquals(array(), $world['list']);
+            }
+            break;
+        case 'the provided list and the result list match with regard to these attributes':
+            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
+                $this->assertEquals('', $world['list']->getMessage());
+            } else {
+                $provided_vals = array();
+                foreach ($arguments[2] as $provided_element) {
+                    if (isset($provided_element[$arguments[0]])) {
+                        $provided_vals[] = $provided_element[$arguments[0]];
+                    } else {
+                        $this->fail(sprintf('The provided element %s does have no value for %s.',
+                                            print_r($provided_element, true),
+                                            print_r($arguments[0])));
+                    }
+                }
+                $result_vals = array();
+                foreach ($world['list'] as $result_set) {
+                    foreach ($result_set as $result_element) {
+                        if (isset($result_element[$arguments[1]])) {
+                            $result_vals[] = $result_element[$arguments[1]];
+                        } else {
+                            $this->fail(sprintf('The result element %s does have no value for %s.',
+                                                print_r($result_element, true),
+                                                print_r($arguments[1])));
+                        }
+                    }
+                    $this->assertEquals(array(),
+                                        array_diff($provided_vals, $result_vals));
+                }
+            }
+            break;
+        case 'each element in the result list has an attribute':
+            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
+                $this->assertEquals('', $world['list']->getMessage());
+            } else {
+                $result_vals = array();
+                foreach ($world['list'] as $result_set) {
+                    foreach ($result_set as $result_element) {
+                        if (!isset($result_element[$arguments[0]])) {
+                            $this->fail(sprintf('The result element %s does have no value for %s.',
+                                                print_r($result_element, true),
+                                                print_r($arguments[0], true)));
+                        }
+                    }
+                }
+            }
+            break;
+        case 'each element in the result list has an attribute set to a given value':
+            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
+                $this->assertEquals('', $world['list']->getMessage());
+            } else {
+                $result_vals = array();
+                foreach ($world['list'] as $result_set) {
+                    foreach ($result_set as $result_element) {
+                        if (!isset($result_element[$arguments[0]])) {
+                            $this->fail(sprintf('The result element %s does have no value for %s.',
+                                                print_r($result_element, true),
+                                                print_r($arguments[0], true)));
+                        }
+                        if ($result_element[$arguments[0]] != $arguments[1]) {
+                            $this->fail(sprintf('The result element %s has an unexpected value %s for %s.',
+                                                print_r($result_element, true),
+                                                print_r($result_element[$arguments[0]], true),
+                                                print_r($arguments[0], true)));
+                        }
+                    }
+                }
+            }
+            break;
+        case 'the login was successful':
+            $this->assertNoError($world['login']);
+            $this->assertTrue($world['login']);
+            break;
+        case 'the list contains a number of elements equal to':
+            $this->assertEquals($arguments[0], count($world['list']));
+            break;
+        default:
+            return $this->notImplemented($action);
+        }
+    }
+
+    /**
+     * Identify the environments we want to run our tests in.
+     *
+     * @return array The selected environments.
+     */
+    public function getEnvironments()
+    {
+        if (empty($this->_environments)) {
+            /** The mock environment provides our basic test scenario */
+            $this->_environments = array(self::ENVIRONMENT_MOCK);
+            $testing = getenv('KOLAB_TEST');
+            if (!empty($testing)) {
+                $this->_environments[] = array(self::ENVIRONMENT_REAL);
+            }
+        }
+        return $this->_environments;
+    }
+
+    /**
+     * Specifically set the environments we wish to support.
+     *
+     * @param array $environments The selected environments.
+     *
+     * @return NULL
+     */
+    public function setEnvironments($environments)
+    {
+        $this->_environments = $environments;
+    }
+
+    /**
+     * Initialize the environments.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function initializeEnvironments()
+    {
+        foreach ($this->getEnvironments() as $environment) {
+            $this->initializeEnvironment($environment);
+        }
+    }
+
+    /**
+     * Prepare an injector for the given environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function prepareInjector($environment)
+    {
+        if (!isset($this->world['injector'][$environment])) {
+            $this->world['injector'][$environment] = new Horde_Injector(new Horde_Injector_TopLevel());
+        }
+    }
+
+    /**
+     * Prepare the log handler for the given environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function prepareLogger($environment)
+    {
+        $logger  = new Horde_Log_Logger();
+        $handler = new Horde_Log_Handler_Mock();
+        $logger->addHandler($handler);
+
+        $this->world['injector'][$environment]->setInstance('Horde_Log_Logger',
+                                                            $logger);
+    }
+
+    /**
+     * Prepare the server configuration for the given environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function prepareKolabServerConfiguration($environment)
+    {
+        switch ($environment) {
+        case self::ENVIRONMENT_MOCK:
+            /** Prepare a Kolab test server */
+            $config = new stdClass;
+            $config->driver = 'test';
+            $config->params = array(
+                'basedn'   => 'dc=example,dc=org',
+                'hashtype' => 'plain'
+            );
+            $this->world['injector'][$environment]->setInstance('Horde_Kolab_Server_Config', $config);
+            break;
+        default:
+            throw new Horde_Exception('Not implemented!');
+        }
+    }
+
+    /**
+     * Prepare the server for the given environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function prepareKolabServer($environment)
+    {
+        $this->world['injector'][$environment]->bindFactory('Horde_Kolab_Server_Structure',
+                                                            'Horde_Kolab_Server_Factory',
+                                                            'getStructure');
+        $this->world['injector'][$environment]->bindFactory('Horde_Kolab_Server',
+                                                            'Horde_Kolab_Server_Factory',
+                                                            'getServer');
+    }
+
+    /**
+     * Get a server from a specific environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return Horde_Kolab_Server The server.
+     */
+    public function getKolabServer($environment)
+    {
+        return $this->world['injector'][$environment]->getInstance('Horde_Kolab_Server');
+    }
+
+    /**
+     * Initialize the given environment.
+     *
+     * @param string $environment The name of the environment.
+     *
+     * @return NULL
+     */
+    public function initializeEnvironment($environment)
+    {
+        $this->prepareInjector($environment);
+        $this->prepareLogger($environment);
+        $this->prepareKolabServerConfiguration($environment);
+        $this->prepareKolabServer($environment);
+    }
+
+    /**
+     * Shortcut to get a Kolab mock server.
+     *
+     * @return Horde_Kolab_Server The server.
+     */
+    public function getKolabMockServer()
+    {
+        $this->initializeEnvironment(self::ENVIRONMENT_MOCK);
+        return $this->getKolabServer(self::ENVIRONMENT_MOCK);
+    }
+
+    /**
+     * Retrieves the available servers. This assumes all environments have been
+     * initialied.
+     *
+     * @return array The list of test servers.
+     */
+    public function getKolabServers()
+    {
+        $servers = array();
+        foreach ($this->getEnvironments() as $environment) {
+            $servers[] = $this->getKolabServer($environment);
+        }
+        return $servers;
+    }
+
+    /**
+     * Add an object to a server and remember it for the tear down method.
+     *
+     * @param Horde_Kolab_Server $server The server to add the object to.
+     * @param array              $object  The object data to store.
+     *
+     * @return Horde_Kolab_Server_Object The resulting object.
+     */
+    public function addToServer(Horde_Kolab_Server $server, array $object)
+    {
+        $object = $server->add($object);
+        $this->added[] = array($server, $object->getUid());
+        return $object;
+    }
+
+    /**
+     * Add an object to the registered servers.
+     *
+     * @param array $object The object data to store.
+     *
+     * @return array An array of objects.
+     */
+    public function addToServers(array $object)
+    {
+        $result = array();
+        foreach ($this->world['injector'] as $injector) {
+            $server = $injector->getInstance('Horde_Kolab_Server');
+            $result[] = $this->addToServer($server, $object);
+        }
+        return $result;
+    }
+
+    /**
+     * Fill a Kolab Server with test users.
+     *
+     * @param Horde_Kolab_Server $server The server to fill.
+     *
+     * @return NULL
+     */
+    public function addBasicUsersToServer($server)
+    {
+        $result = $this->addToServer($server, $this->provideBasicUserOne());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicUserTwo());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicAddress());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicAdmin());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicDomainMaintainer());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideGroupWithoutMembers());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicGroupOne());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicMaintainer());
+        $this->assertNoError($result);
+        $result = $this->addToServer($server, $this->provideBasicSharedFolder());
+        $this->assertNoError($result);
+    }
+
+    /**
+     * List objects on the registered servers.
+     *
+     * @param array $type The type of objects to list.
+     *
+     * @return array An array of objects.
+     */
+    public function listObjectsOnServer($type)
+    {
+        $result = array();
+        foreach ($this->world['injector'] as $injector) {
+            $server = $injector->getInstance('Horde_Kolab_Server');
+            $objects = $server->listObjects($type);
+            $result[] = $objects;
+        }
+        return $result;
+    }
+
+    /**
+     * Return a test user.
+     *
+     * @return array The test user.
+     */
+    public function provideBasicUserOne()
+    {
+        return array('givenName' => 'Gunnar',
+                      'sn' => 'Wrobel',
+                      'type' => 'Horde_Kolab_Server_Object_Kolab_User',
+                      'mail' => 'wrobel@example.org',
+                      'uid' => 'wrobel',
+                      'userPassword' => 'none',
+                      'kolabHomeServer' => 'home.example.org',
+                      'kolabImapServer' => 'imap.example.org',
+                      'kolabFreeBusyServer' => 'https://fb.example.org/freebusy',
+                      'kolabInvitationPolicy' => array('ACT_REJECT_IF_CONFLICTS'),
+                      'alias' => array('gunnar@example.org',
+                                       'g.wrobel@example.org'),
+                );
+    }
+
+    /**
+     * Return a test user.
+     *
+     * @return array The test user.
+     */
+    public function provideBasicUserTwo()
+    {
+        return array('givenName' => 'Test',
+                     'sn' => 'Test',
+                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
+                     'mail' => 'test@example.org',
+                     'uid' => 'test',
+                     'userPassword' => 'test',
+                     'kolabHomeServer' => 'home.example.org',
+                     'kolabImapServer' => 'home.example.org',
+                     'kolabFreeBusyServer' => 'https://fb.example.org/freebusy',
+                     'alias' => array('t.test@example.org'),
+                     'kolabDelegate' => 'wrobel@example.org',);
+    }
+
+    /**
+     * Return a test address.
+     *
+     * @return array The test address.
+     */
+    public function provideBasicAddress()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Address',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_GIVENNAME    => 'Test',
+                     'Sn'           => 'Address',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_MAIL         => 'address@example.org',
+        );
+    }
+
+    /**
+     * Return a test administrator.
+     *
+     * @return array The test administrator.
+     */
+    public function provideBasicAdmin()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Administrator',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_GIVENNAME    => 'The',
+                     'Sn'           => 'Administrator',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SID          => 'admin',
+                     'Userpassword' => 'none',
+        );
+    }
+
+    /**
+     * Return a test maintainer.
+     *
+     * @return array The test maintainer.
+     */
+    public function provideBasicMaintainer()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Maintainer',
+                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_GIVENNAME    => 'Main',
+                     'Sn'           => 'Tainer',
+                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_SID          => 'maintainer',
+                     'Userpassword' => 'none',
+        );
+    }
+
+    /**
+     * Return a test domain maintainer.
+     *
+     * @return array The test domain maintainer.
+     */
+    public function provideBasicDomainMaintainer()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Domainmaintainer',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_GIVENNAME    => 'Domain',
+                     'Sn'           => 'Maintainer',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_SID          => 'domainmaintainer',
+                     'Userpassword' => 'none',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_DOMAIN       => array('example.com'),
+
+        );
+    }
+
+    /**
+     * Return a test shared folder.
+     *
+     * @return array The test shared folder.
+     */
+    public function provideBasicSharedFolder()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabsharedfolder',
+                     Horde_Kolab_Server_Object_Kolabsharedfolder::ATTRIBUTE_CN         => 'shared@example.org',
+                     Horde_Kolab_Server_Object_Kolabsharedfolder::ATTRIBUTE_HOMESERVER => 'example.org',
+        );
+    }
+
+    /**
+     * Provide a set of valid groups.
+     *
+     * @return array The array of groups.
+     */
+    public function groupLists()
+    {
+        $groups = $this->validGroups();
+        $result = array();
+        foreach ($groups as $group) {
+            $result[] = array($group);
+        }
+        return $result;
+    }
+
+    /**
+     * Provide a set of valid groups.
+     *
+     * @return array The array of groups.
+     */
+    public function validGroups()
+    {
+        return array(
+            array(
+                $this->provideGroupWithoutMembers(),
+            ),
+            array(
+                $this->provideBasicGroupOne(),
+            ),
+            array(
+                $this->provideBasicGroupTwo(),
+            ),
+        );
+    }
+
+    /**
+     * Return a test group.
+     *
+     * @return array The test group.
+     */
+    public function provideGroupWithoutMembers()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'empty.group@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array());
+    }
+
+    /**
+     * Return a test group.
+     *
+     * @return array The test group.
+     */
+    public function provideBasicGroupOne()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'group@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Test Test,dc=example,dc=org',
+                                                                                         'cn=Gunnar Wrobel,dc=example,dc=org')
+        );
+    }
+
+    /**
+     * Return a test group.
+     *
+     * @return array The test group.
+     */
+    public function provideBasicGroupTwo()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'group2@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Gunnar Wrobel,dc=example,dc=org')
+        );
+    }
+
+    public function provideDistributionList()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Distlist',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'distlist@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Test Test,dc=example,dc=org',
+                                                                                         'cn=Gunnar Wrobel,dc=example,dc=org')
+        );
+    }
+
+    public function provideInvalidUserWithoutPassword()
+    {
+        return array('givenName' => 'Test',
+                     'sn' => 'Test',
+                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
+                     'mail' => 'test@example.org');
+    }
+
+    public function provideInvalidUserWithoutGivenName()
+    {
+        return array('sn' => 'Test',
+                     'userPassword' => 'none',
+                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
+                     'mail' => 'test@example.org');
+    }
+
+    public function provideInvalidUserWithoutLastName()
+    {
+        return array('givenName' => 'Test',
+                     'userPassword' => 'none',
+                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
+                     'mail' => 'test@example.org');
+    }
+
+    public function provideInvalidUserWithoutMail()
+    {
+        return array('givenName' => 'Test',
+                     'sn' => 'Test',
+                     'userPassword' => 'none',
+                     'type' => 'Horde_Kolab_Server_Object_Kolab_User');
+    }
+
+    public function provideInvalidUsers()
+    {
+        return array(
+            array(
+                $this->provideInvalidUserWithoutPassword(),
+                'The value for "userPassword" is missing!'
+            ),
+            array(
+                $this->provideInvalidUserWithoutGivenName(),
+                'Either the last name or the given name is missing!'
+            ),
+            array(
+                $this->provideInvalidUserWithoutLastName(),
+                'Either the last name or the given name is missing!'
+            ),
+            array(
+                $this->provideInvalidUserWithoutMail(),
+                'The value for "mail" is missing!'
+            ),
+        );
+    }
+
+    /** @todo: Prefix the stuff below with provide...() */
+
+    public function validUsers()
+    {
+        return array(
+            array(
+                $this->provideBasicUserOne(),
+            ),
+            array(
+                $this->provideBasicUserTwo(),
+            ),
+        );
+    }
+
+    public function validAddresses()
+    {
+        return array(
+            array(
+                $this->provideBasicAddress(),
+            ),
+        );
+    }
+
+    public function validAdmins()
+    {
+        return array(
+            array(
+                $this->provideBasicAdmin(),
+            ),
+        );
+    }
+
+    public function validMaintainers()
+    {
+        return array(
+            array(
+                $this->provideBasicMaintainer(),
+            )
+        );
+    }
+
+    public function validDomainMaintainers()
+    {
+        return array(
+            array(
+                $this->provideBasicDomainMaintainer(),
+            )
+        );
+    }
+
+    public function validSharedFolders()
+    {
+        return array(
+            array('cn' => 'Shared',
+                  'type' => 'Horde_Kolab_Server_Object_Kolabsharedfolder'
+            ),
+        );
+    }
+
+
+    public function userLists()
+    {
+        return array(
+        );
+    }
+
+    public function userListByLetter()
+    {
+        return array(
+        );
+    }
+
+    public function userListByAttribute()
+    {
+        return array(
+        );
+    }
+
+    public function userAdd()
+    {
+        return array(
+        );
+    }
+
+    public function invalidMails()
+    {
+        return array(
+        );
+    }
+
+    public function largeList()
+    {
+        return array(
+        );
+    }
+
+    protected function fetchByCn($server, $cn)
+    {
+        $cn_result = $server->uidForCn($cn);
+        $this->assertNoError($cn_result);
+
+        $object = $server->fetch($cn_result);
+        $this->assertNoError($object);
+
+        return $object;
+    }
+
+    /**
+     * Ensure that the variable contains no Horde_Kolab_Server_Exception and
+     * fail if it does.
+     *
+     * @param mixed $var The variable to check.
+     *
+     * @return NULL.
+     */
+    public function assertNoError($var)
+    {
+        if (is_array($var)) {
+            foreach ($var as $element) {
+                $this->assertNoError($element);
+            }
+        } elseif ($var instanceOf Exception) {
+            $this->assertEquals('', $var->getMessage());
+        } else if ($var instanceOf PEAR_Error) {
+            $this->assertEquals('', $var->getMessage());
+        }
+    }
+
+    /**
+     * Ensure that the variable contains a Horde_Kolab_Server_Exception and fail
+     * if it does not. Optionally compare the error message with the provided
+     * message and fail if both do not match.
+     *
+     * @param mixed  $var The variable to check.
+     * @param string $msg The expected error message.
+     *
+     * @return NULL.
+     */
+    public function assertError($var, $msg = null)
+    {
+        if (!$var instanceOf PEAR_Error) {
+            $this->assertType('Horde_Kolab_Server_Exception', $var);
+            if (isset($msg)) {
+                $this->assertEquals($msg, $var->getMessage());
+            }
+        } else {
+            if (isset($msg)) {
+                $this->assertEquals($msg, $var->getMessage());
+            }
+        }
+    }
+
+    /**
+     * Assert that creating a new object operation yields some predictable
+     * attribute results.
+     *
+     * @param Horde_Kolab_Server         $server The server the object resides on.
+     * @param array                      $store  The information to save.
+     * @param array                      $fetch  The expected results.
+     *
+     * @return NULL.
+     */
+    protected function assertAdd(Horde_Kolab_Server $server,
+                                 array $store, array $fetch)
+    {
+        $object = $server->add($store);
+        $this->assertNoError($object);
+
+        $this->added[] = array($server, $object->getUid());
+        $object = $server->fetch($object->getUid());
+
+        foreach ($fetch as $attribute => $expect) {
+            $this->assertEquals($expect, $object->get($attribute));
+        }
+        return $object;
+    }
+
+    /**
+     * Test simple attributes.
+     *
+     * @dataProvider provideServers
+     *
+     * @return NULL
+     */
+    public function assertSimpleAttributes(Horde_Kolab_Server_Object $object,
+                                           Horde_Kolab_Server $server, array $list)
+    {
+        foreach ($list as $item) {
+            $this->assertSimpleSequence($object, $server,
+                                        $item,
+                                        array($item, 'öäü/)(="§%$&§§$\'*', '', array('a', 'b'), '0'),
+                                        true);
+        }
+    }
+
+    /**
+     * Test easy attributes.
+     *
+     * @dataProvider provideServers
+     *
+     * @return NULL
+     */
+    public function assertEasyAttributes(Horde_Kolab_Server_Object $object,
+                                         Horde_Kolab_Server $server, array $list)
+    {
+        foreach ($list as $key => $items) {
+            $this->assertSimpleSequence($object, $server,
+                                        $key,
+                                        $items,
+                                        true);
+        }
+    }
+
+    /**
+     * Assert that a save() operation yields some predictable attribute results.
+     *
+     * @param Horde_Kolab_Server_Object $object    The object to work on.
+     * @param Horde_Kolab_Server        $server    The server the object resides on.
+     * @param string                    $attribute The attribute to work on.
+     * @param array                     $sequence  The sequence of values to set and expect.
+     *
+     * @return NULL.
+     */
+    protected function assertSimpleSequence(Horde_Kolab_Server_Object $object,
+                                            Horde_Kolab_Server $server,
+                                            $attribute, array $sequence,
+                                            $pop_arrays = false)
+    {
+        foreach ($sequence as $value) {
+            $this->assertStoreFetch($object, $server,
+                                    array($attribute => $value),
+                                    array($attribute => $value),
+                                    $pop_arrays);
+        }
+    }
+
+    /**
+     * Assert that a save() operation yields some predictable attribute results.
+     *
+     * @param Horde_Kolab_Server_Object  $object The object to work on.
+     * @param Horde_Kolab_Server         $server The server the object resides on.
+     * @param array                      $store  The information to save.
+     * @param array                      $fetch  The expected results.
+     *
+     * @return NULL.
+     */
+    protected function assertStoreFetch(Horde_Kolab_Server_Object $object,
+                                        Horde_Kolab_Server $server,
+                                        array $store, array $fetch,
+                                        $pop_arrays = false)
+    {
+        $result = $object->save($store);
+        $this->assertNoError($result);
+
+        $object = $server->fetch($object->getUid());
+
+        foreach ($fetch as $attribute => $expect) {
+            $actual = $object->get($attribute, false);
+            if ($pop_arrays && is_array($actual) && count($actual) == 1) {
+                $actual = array_pop($actual);
+            }
+            $this->assertEquals($expect,
+                                $actual);
+        }
+    }
+
+    public function assertRecursiveType($results, $type)
+    {
+        if (is_array($results)) {
+            foreach ($results as $result) {
+                $this->assertRecursiveType($result, $type);
+            }
+        } else {
+            if ($results instanceOf Exception) {
+                $this->assertEquals('', $results->getMessage());
+            } else {
+                $this->assertType($type, $results);
+            }
+        }
+    }
+
+    /**
+     * Setup function.
+     *
+     * @return NULL.
+     */
+    protected function setUp()
+    {
+        $this->added = array();
+        $this->markTestIncomplete('Needs to be fixed');
+    }
+
+    /**
+     * Cleanup function.
+     *
+     * @return NULL.
+     */
+    protected function tearDown()
+    {
+        if (isset($this->added)) {
+            $added = array_reverse($this->added);
+            foreach ($added as $add) {
+                $result = $add[0]->delete($add[1]);
+                $this->assertNoError($result);
+            }
+        }
+    }
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/UserHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/UserHandlingTest.php
new file mode 100644 (file)
index 0000000..28078c3
--- /dev/null
@@ -0,0 +1,639 @@
+<?php
+/**
+ * Handling 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
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Handling users.
+ *
+ * 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_UserHandlingTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /**
+     * Test listing userss if there are no users.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function listingUsersOnEmptyServer()
+    {
+        $this->given('several Kolab servers')
+            ->when('listing all users')
+            ->then('the list is an empty array');
+    }
+
+    /**
+     * Test listing users after adding some users.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUsersAfterAddingUsers($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object list', $user_list)
+            ->and('listing all users')
+            ->then('the list has a number of entries equal to', count($user_list));
+    }
+
+    /**
+     * Test listing users after adding some users.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUserCount($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding an object list', $user_list)
+            ->and('retriving the result count')
+            ->then('the count equals to', count($user_list));
+    }
+
+    /**
+     * Test the list of users for the user id.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUsersHasAttributeId($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user list', $user_list)
+            ->then('the user list contains the unique ID for each user')
+            ->and('the user list contains the user type for each user');
+    }
+
+    /**
+     * Test the list of users for the user type.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUsersHasAttributeType($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user list', $user_list)
+            ->then('the user list contains the user type for each user');
+    }
+
+    /**
+     * Test the list of users for the user full name.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUsersHasAttributeFullName($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user list', $user_list)
+            ->then('the user list contains the full name for each user');
+    }
+
+    /**
+     * Test the list of users for the user mail.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUsersHasAttributeEmail($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user list', $user_list)
+            ->then('the user list contains the email for each user');
+    }
+
+    /**
+     * Test the list of users for the user uid.
+     *
+     * @param array $user_list The users to add.
+     *
+     * @scenario
+     * @dataProvider userLists
+     *
+     * @return NULL
+     */
+    public function listingUsersHasAttributeUid($user_list)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user list', $user_list)
+            ->then('the list contains the uid for each user');
+    }
+
+    /**
+     * @scenario
+     * @dataProvider userListByLetter
+     */
+    public function listingUsersCanBeRestrictedByStartLetterOfTheLastName($letter, $count)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding user list', $this->largeList())
+            ->and('retrieving the result count of a list restricted by the start letter of the last name', $letter)
+            ->then('the list contains a correct amount of results', $count);
+    }
+
+    /**
+     * @scenario
+     * @dataProvider userListByLetter
+     */
+    public function countingUsersCanBeRestrictedByStartLetterOfTheLastName($letter, $count)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding user list', $this->largeList())
+            ->and('retrieving the result count of a list restricted by the start letter of the last name', $letter)
+            ->then('the count contains a correct number', $count);
+    }
+
+    /**
+     * @scenario
+     * @dataProvider userListByAttribute
+     */
+    public function countingUsersCanBeRestrictedByContentsInAnAttribute($attribute, $content, $count)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding user list', $this->largeList())
+            ->and('retrieving the result count of a list restricted by content in an attribute', $attribute, $content)
+            ->then('the count contains a correct number', $count);
+    }
+
+    /**
+     * @scenario
+     */
+    public function creatingUserWithoutTypeCreatesStandardUser()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user without user type')
+            ->then('a standard user has been created');
+    }
+
+    /**
+     * @scenario
+     */
+    public function creatingUserWithoutInvitationPolicySetsManualPolicy()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user without an invitation policy')
+            ->then('the added user has a manual policy');
+    }
+
+    /**
+     * @scenario
+     */
+    public function creatingUserWithoutHomeServerFails()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user without a home server')
+            ->then('the result should indicate an error with', 'The user cannot be added: The home Kolab server (or network) has not been specified!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function creatingUserForDistributedKolabWithoutImapServerFails()
+    {
+        $this->given('several Kolab servers')
+            ->and('distributed Kolab')
+            ->when('adding a user without an imap server')
+            ->then('the result should indicate an error with', 'The user cannot be added: The home imap server has not been specified!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function creatingUserWithImapServerFailsOnNonDistributedKolab()
+    {
+        $this->given('several Kolab servers')
+            ->and('monolithic Kolab')
+            ->when('adding a user with an imap server')
+            ->then('the result should indicate an error with', 'The user cannot be added: A home imap server is only supported with a distributed Kolab setup!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function creatingUserWithFreeBusyServerFailsOnNonDistributedKolab()
+    {
+        $this->given('several Kolab servers')
+            ->and('monolithic Kolab')
+            ->when('adding a user with a free/busy server')
+            ->then('the result should indicate an error with', 'The user cannot be added: A seperate free/busy server is only supported with a distributed Kolab setup!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function modifyingUserMailAddressIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the mail address "test@example.org"')
+            ->and('modifying the mail address to "new@example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be modified: Changing the mail address from "test@example.org" to "new@example.org" is not allowed!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function modifyingUserHomeServerIsNotAllowd()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the home server "test.example.org"')
+            ->and('modifying the home server to "new.example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be modified: Changing the home server from "test.example.org" to "new.example.org" is not allowed!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function modifyingUserImapServerIsNotAllowd()
+    {
+        $this->given('several Kolab servers')
+            ->and('distributed Kolab')
+            ->when('adding a user with the imap server "test.example.org"')
+            ->and('modifying the imap server to "new.example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be modified: Changing the imap server from "test.example.org" to "new.example.org" is not allowed!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenMailAndMailIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the mail address "test@example.org"')
+            ->and('adding a user "Test2 Test2" with the mail address "test@example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Mail address "test@example.org" is already the mail address of user "Test Test"!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenMailAndAliasIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the mail address "test@example.org"')
+            ->and('adding a user with the alias address "test@example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Alias address "test@example.org" is already the mail address of user "Test Test"!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenAliasAndAliasIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the alias address "test@example.org"')
+            ->and('adding a user with the alias address "test@example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Alias address "test@example.org" is already the alias address of user "Test Test"!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenMailAndUidIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the mail address "test@example.org"')
+            ->and('adding a user with the uid "test@example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Uid "test@example.org" is already the mail address of user "Test Test"!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function conflictBetweenUidAndUidIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "Test Test" with the uid "test"')
+            ->and('adding a user with the uid "test"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Uid "test" is already the uid of user "Test Test"!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function nonExistingDelegateIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the delegate address "test@example.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Delegate address "test@example.org" does not exist!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function addingUserInUndefinedDomainIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->and('the only served mail domain is "example.org"')
+            ->when('adding a user with the mail address "test@doesnotexist.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Domain "doesnotexist.org" is not being handled by this server!');
+    }
+
+    /**
+     *  kolab/issue444 (a kolab user may delegate to an external user which should not be possible)
+     *
+     * @scenario
+     */
+    public function addingUserWithDelegateInUndefinedDomainIsNotAllowed()
+    {
+        $this->given('several Kolab servers')
+            ->and('the only served mail domain is "example.org"')
+            ->when('adding a user with the delegate mail address "test@doesnotexist.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Domain "doesnotexist.org" is not being handled by this server!');
+    }
+
+    /**
+     *   kolab/issue1368 (Webinterface allows to create email addresses with slash that cyrus cannot handle)
+     *
+     * @scenario
+     * @dataProvider invalidMails
+     */
+    public function disallowInvalidMailAddresses($address)
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with an invalid mail address', $address)
+            ->then('the result should indicate an error with', "The user cannot be added: Address \"$address\" is not a valid mail address!");
+    }
+
+    /**
+     * @scenario
+     */
+    public function addingUserOnUndefinedHomeServer()
+    {
+        $this->given('several Kolab servers')
+            ->and('the only home server in the network is "example.org"')
+            ->when('adding a user with the home server "doesnotexist.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Host "doesnotexist.org" is not part of the Kolab network!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function addingUserOnUndefinedImapServer()
+    {
+        $this->given('several Kolab servers')
+            ->and('distributed Kolab')
+            ->and('the only imap server in the network is "example.org"')
+            ->when('adding a user with the imap server "doesnotexist.org"')
+            ->then('the result should indicate an error with', 'The user cannot be added: Imap server "doesnotexist.org" is not part of the Kolab network!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function userAttributesCanBeExtended()
+    {
+        $this->given('several Kolab servers')
+            ->and('an extended attribute "test" has been defined')
+            ->when('adding a user with the attribute "test" set to "FIND ME"')
+            ->then('the result indicates success')
+            ->and('the user can be found using the "test" attribute with the value "FIND ME"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function extendedObjectAttributeDescriptionsCanBeRetrieved()
+    {
+        $this->given('several Kolab servers')
+            ->and('an extended attribute "test" has been defined')
+            ->when('retrieving the supported attributes by the object type "user"')
+            ->then('the result is an array of Horde attribute descriptions')
+            ->and('contains the description of "test"');
+    }
+
+    /**
+     * @scenario
+     */
+    public function removingUserFailsIfUserDoesNotExist()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the ID "cn=Test Test"')
+            ->and('deleting the user with the ID "cn=Dummy Dummy"')
+            ->then('the result should indicate an error with', 'The user cannot be deleted: User "cn=Dummy Dummy" does not exist!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function removingUserByMailSucceeds()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the mail address "test@example.org"')
+            ->and('deleting the user with mail address "test@example.org"')
+            ->then('the result indicates success')
+            ->and('listing all users returns an empty list');
+    }
+
+    /**
+     * @scenario
+     */
+    public function removingUserByIdSucceeds()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the ID "cn=Test Test"')
+            ->and('deleting the user with the ID "cn=Test Test"')
+            ->then('the result indicates success')
+            ->and('listing all users returns an empty list');
+    }
+
+    /**
+     * @scenario
+     */
+    public function addedUserCanLogin()
+    {
+        $this->given('several Kolab servers')
+            ->and('Horde uses the Kolab auth driver')
+            ->when('adding a user with the mail address "test@example.org" and password "test"')
+            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
+            ->then('the result indicates success')
+            ->and('the session shows "test@example.org" as the current user');
+    }
+
+    /**
+     * @scenario
+     */
+    public function allowUserWithExtendedObjectClasses()
+    {
+        $this->given('several Kolab servers')
+            ->and('an extended set of objectclasses')
+            ->when('adding a user with the mail address "test@example.org"')
+            ->and('fetching user "test@example.org"')
+            ->then('has the additional object classes set');
+    }
+
+    /**
+     * @scenario
+     */
+    public function allowToCheckUserPasswords()
+    {
+        $this->given('several Kolab servers')
+            ->and('password check enabled')
+            ->when('adding a user with the mail address "test@example.org" and password "tosimple"')
+            ->then('the result should indicate an error with', 'The user cannot be added: The chosen password is not complex enough!');
+    }
+
+    /**
+     * @scenario
+     */
+    public function allowToSetAttributeDefaults()
+    {
+        $this->given('several Kolab servers')
+            ->and('an extended attribute "test" with the default value "test" has been defined')
+            ->when('adding a user with the mail address "test@example.org" and an empty attribute "test"')
+            ->and('fetching user "test@example.org"')
+            ->then('the user object has the attribute "test" set to "test"');
+    }
+
+    /**
+     * kolab/issue2742 (Have a default quota value when creating new users via the web interface)
+     *
+     * @scenario
+     */
+    public function allowToSetDomainSpecificAttributeDefaults()
+    {
+        $this->given('several Kolab servers')
+            ->and('domain "example.org" is served by the Kolab server')
+            ->and('domain "example2.org" is served by the Kolab server')
+            ->and('an extended attribute "test" with the default value "test" has been defined')
+            ->and('an extended attribute "test" with the default value "test2" has been defined for domain example2.org')
+            ->when('adding a user with the mail address "test@example.org" and an empty attribute "test"')
+            ->and('adding a user with the mail address "test@example2.org" and an empty attribute "test"')
+            ->and('fetching user "test@example.org" and "test@example2.org"')
+            ->then('the user "test@example.org" has the attribute "test" set to "test"')
+            ->and('the user "test@example2.org" has the attribute "test" set to "test2"');
+    }
+
+    /**
+     *     kolab/issue3035 (Initialise internal Horde parameters when creating a user)
+     *
+     * @scenario
+     * @dataProvider userAdd
+     */
+    public function addedUserHasPreferencesInitialized()
+    {
+        $this->given('several Kolab servers')
+            ->and('Horde uses the Kolab auth driver')
+            ->when('adding a user', $user)
+            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
+            ->then('the preferences are automatically set to the user information', $user);
+    }
+
+    /**
+     *      kolab/issue1189 (IMAP login fails on some specific uids)
+     *
+     * @scenario
+     */
+    public function userUidsShouldNotResembleTheLocalPartOfMailAddresses()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
+            ->and('adding a user with the uid "test"')
+            ->then('the result should indicate an error with', 'The user cannot be added: The uid "test" matches the local part of the mail address "test@example.org" assigned to user "cn=Test Test"!');
+    }
+
+    /**
+     *  kolab/issue606 (It is not possible to register people with middlename correctly)
+     *
+     * @scenario
+     */
+    public function allowToSetTheMiddleName()
+    {
+        $this->given('several Kolab servers')
+            ->and('an extended attribute "middleName" has been defined')
+            ->when('adding a user with the mail address "test@example.org" and the middle name "Middle"')
+            ->and('fetching user "test@example.org"')
+            ->then('the user object has the attribute "middleName" set to "Middle"');
+    }
+
+    /**
+     *   kolab/issue1880 (Poor handling of apostrophes in ldap and admin webpages)
+     *
+     * @scenario
+     */
+    public function correctlyEscapeApostrophesInNames()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the mail address "test@example.org" and the last name "O\'Donnell"')
+            ->and('fetching user "test@example.org"')
+            ->then('the user name has the attribute "sn" set to "O\'Donnell"');
+    }
+
+    /**
+     *    kolab/issue1677 (Allow a user to use an external address as sender)
+     *
+     * @scenario
+     */
+    public function allowUserToUseExternalAddressAsSender()
+    {
+        $this->given('several Kolab servers')
+            ->when('adding a user with the mail address "test@example.org" and the external address "other@doesnotexist.org"')
+            ->and('fetching user "test@example.org"')
+            ->then('the user has the attribute external address "other@doesnotexist.org"');
+    }
+
+    /**
+     *     kolab/issue3036 (cn = "givenName sn" ?)
+     *
+     * @scenario
+     */
+    public function allowCustomFullnameHandling()
+    {
+        $this->given('several Kolab servers')
+            ->and('an extended attribute "middleName" has been defined')
+            ->and('custom full name handling has been set to "lastname, firstname middlename"')
+            ->when('adding a user with the mail address "test@example.org", the last name "Test", the first name "Test", and the middle name "Middle"')
+            ->and('fetching user "test@example.org"')
+            ->then('the user has the attribute full name "Test, Test Middle"');
+    }
+
+}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/UserTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Integration/UserTest.php
new file mode 100644 (file)
index 0000000..423f860
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+/**
+ * Test the user object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Require our basic test case definition
+ */
+require_once dirname(__FILE__) . '/Scenario.php';
+
+/**
+ * Test the user object.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Integration_UserTest extends Horde_Kolab_Server_Integration_Scenario
+{
+
+    /**
+     * Set up testing.
+     *
+     * @return NULL
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->server = $this->getKolabMockServer();
+        $users        = $this->validUsers();
+        foreach ($users as $user) {
+            $result = $this->server->add($user[0]);
+        }
+    }
+
+    /**
+     * Test ID generation for a user.
+     *
+     * @return NULL
+     */
+    public function testGenerateId()
+    {
+        $users = $this->validUsers();
+        $user = new Horde_Kolab_Server_Object_Kolab_User($this->server, null, $users[0][0]);
+        $this->assertNoError($user);
+        $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID));
+    }
+
+    /**
+     * Test adding invalid user.
+     *
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidUser()
+    {
+        $user   = $this->provideInvalidUserWithoutGivenName();
+        $result = $this->server->add($user);
+    }
+
+    /**
+     * Test fetching a user.
+     *
+     * @return NULL
+     */
+    public function testFetchUser()
+    {
+        $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
+        $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
+        $this->assertEquals('Gunnar Wrobel', $user->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FNLN));
+    }
+
+    /**
+     * Test fetching server information.
+     *
+     * @return NULL
+     */
+    public function testGetServer()
+    {
+        $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
+        $imap = $user->getServer('imap');
+        $this->assertEquals('imap.example.org', $imap);
+
+        $user = $this->server->fetch('cn=Test Test,dc=example,dc=org');
+        $imap = $user->getServer('imap');
+        $this->assertEquals('home.example.org', $imap);
+
+        $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
+        $attr = $user->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FREEBUSYHOST);
+        $this->assertEquals('https://fb.example.org/freebusy', $attr);
+
+        $imap = $user->getServer('freebusy');
+        $this->assertEquals('https://fb.example.org/freebusy', $imap);
+    }
+
+}
index 6580c3f..c7026d9 100644 (file)
@@ -40,7 +40,7 @@ class Horde_Kolab_Server_LdapBase extends PHPUnit_Framework_TestCase
 
         /** Hide strict errors from the Net_LDAP2 library */
         $error_reporting = error_reporting();
-        error_reporting($error_reporting E_STRICT);
+        error_reporting($error_reporting & ~E_STRICT);
 
         if (!class_exists('Net_LDAP2')) {
             $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/AddingObjectsTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/AddingObjectsTest.php
deleted file mode 100644 (file)
index d0cfe07..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Adding objects to the server.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Adding objects to the server.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Object_AddingObjectsTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Test adding valid users.
-     *
-     * @param array $user The user to add.
-     *
-     * @scenario
-     * @dataProvider validUsers
-     *
-     * @return NULL
-     */
-    public function addingValidUser($user)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a Kolab server object', $user)
-            ->then(
-                'the result should be an object of type',
-                'Horde_Kolab_Server_Object_Kolab_User'
-            );
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/AdminTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/AdminTest.php
deleted file mode 100644 (file)
index 1503cfb..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-/**
- * Test the admin object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the admin object.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Object_AdminTest extends Horde_Kolab_Server_Scenario
-{
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->server = $this->getKolabMockServer();
-    }
-
-    /**
-     * Add an administrator object.
-     *
-     * @return NULL
-     */
-    private function _addValidAdmin()
-    {
-        $this->addToServers($this->provideBasicAdmin());
-    }
-
-    /**
-     * Test ID generation for an admin.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        $admin = $this->provideBasicAdmin();
-        $user  = new Horde_Kolab_Server_Object_Kolab_Administrator($this->server,
-                                                                   null, $admin);
-        $this->assertEquals(
-            'cn=The Administrator,dc=example,dc=org',
-            $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)
-        );
-    }
-
-    /**
-     * Test fetching an admin.
-     *
-     * @return NULL
-     */
-    public function testFetchAdmin()
-    {
-        $this->_addValidAdmin();
-
-        $this->assertEquals(2, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
-        $this->assertContains(
-            'cn=admin,cn=internal,dc=example,dc=org',
-            array_keys($GLOBALS['KOLAB_SERVER_TEST_DATA'])
-        );
-
-        $administrators = $this->server->getGroups(
-            'cn=The Administrator,dc=example,dc=org'
-        );
-        $admin_group    = $this->server->fetch(
-            'cn=admin,cn=internal,dc=example,dc=org'
-        );
-
-        $this->assertTrue($admin_group->exists());
-
-        $admin = $this->server->fetch('cn=The Administrator,dc=example,dc=org');
-        $this->assertEquals(
-            'Horde_Kolab_Server_Object_Kolab_Administrator',
-            get_class($admin)
-        );
-    }
-
-    /**
-     * Test listing the admins.
-     *
-     * @return NULL
-     */
-    public function testToHash()
-    {
-        $this->_addValidAdmin();
-
-        $hash = $this->server->fetch(
-            'cn=The Administrator,dc=example,dc=org'
-        )->toHash();
-        $this->assertContains('uid', array_keys($hash));
-        $this->assertContains('lnfn', array_keys($hash));
-        $this->assertEquals('admin', $hash['uid']);
-    }
-
-    /**
-     * Test listing admins.
-     *
-     * @return NULL
-     */
-    public function testListingGroups()
-    {
-        $this->_addValidAdmin();
-
-        $entries = $this->server->search(
-            '(&(cn=*)(objectClass=inetOrgPerson)(!(uid=manager))(sn=*))'
-        );
-        $this->assertEquals(1, count($entries));
-
-        $list = $this->server->listObjects(
-            'Horde_Kolab_Server_Object_Kolab_Administrator'
-        );
-        $this->assertEquals(1, count($list));
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/DistListHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/DistListHandlingTest.php
deleted file mode 100644 (file)
index dbc4693..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * Handling distribution lists.
- *
- * 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';
-
-/**
- * Handling distribution lists.
- *
- * 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_DistListHandlingTest extends Horde_Kolab_Server_Scenario
-{
-
-    /**
-     * Test adding a distribution list.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function creatingDistributionList()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a distribution list')
-            ->then(
-                'the result should be an object of type',
-                'Horde_Kolab_Server_Object_Kolab_Distlist'
-            );
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/GroupHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/GroupHandlingTest.php
deleted file mode 100644 (file)
index 1dd05c8..0000000
+++ /dev/null
@@ -1,502 +0,0 @@
-<?php
-/**
- * Handling groups.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Handling groups.
- *
- * 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_GroupHandlingTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Test listing groups if there are no groups.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function listingGroupsOnEmptyServer()
-    {
-        $this->given('several Kolab servers')
-            ->when(
-                'retrieving a hash list with all objects of type',
-                'Horde_Kolab_Server_Object_Kolabgroupofnames'
-            )
-            ->then('the list is an empty array');
-    }
-
-    /**
-     * Test listing groups after adding some groups.
-     *
-     * @param array $group_list The groups to add.
-     *
-     * @scenario
-     * @dataProvider groupLists
-     *
-     * @return NULL
-     */
-    public function listingGroups($group_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object list', $group_list)
-            ->and(
-                'retrieving a hash list with all objects of type',
-                'Horde_Kolab_Server_Object_Kolabgroupofnames'
-            )
-            ->then('the result indicates success.')
-            ->and(
-                'the list has a number of entries equal to',
-                count($group_list)
-            );
-    }
-
-    /**
-     * Test the list of groups for the group id.
-     *
-     * @param array $group_list The groups to add.
-     *
-     * @scenario
-     * @dataProvider groupLists
-     *
-     * @return NULL
-     */
-    public function listingGroupsHasAttributeId($group_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object list', $group_list)
-            ->and(
-                'retrieving a hash list with all objects of type',
-                'Horde_Kolab_Server_Object_Kolabgroupofnames'
-            )
-            ->then(
-                'the provided list and the result list match with regard to these attributes',
-                'mail', 'cn', $group_list
-            );
-    }
-
-    /**
-     * Test the list of groups for the group mail address.
-     *
-     * @param array $group_list The groups to add.
-     *
-     * @scenario
-     * @dataProvider groupLists
-     *
-     * @return NULL
-     */
-    public function listingGroupsHasAttributeMail($group_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object list', $group_list)
-            ->and(
-                'retrieving a hash list with all objects of type',
-                'Horde_Kolab_Server_Object_Kolabgroupofnames'
-            )
-            ->then(
-                'the provided list and the result list match with regard to these attributes',
-                'mail', 'mail', $group_list
-            );
-    }
-
-    /**
-     * Test the list of groups for the group visibility.
-     *
-     * @param array $group_list The groups to add.
-     *
-     * @scenario
-     * @dataProvider groupLists
-     *
-     * @return NULL
-     */
-    public function listingGroupsHasAttributeVisibility($group_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object list', $group_list)
-            ->and(
-                'retrieving a hash list with all objects of type',
-                'Horde_Kolab_Server_Object_Kolabgroupofnames'
-            )
-            ->then(
-                'each element in the result list has an attribute',
-                'visible'
-            );
-    }
-
-    /**
-     * Test adding an invalid group.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function creatingGroupsWithoutMailAddressFails()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group without a mail address')
-            ->then(
-                'the result should indicate an error with',
-                'Adding object failed: The value for "mail" is missing!'
-            );
-    }
-
-    /**
-     * Test adding a group without setting the visibility.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function creatingGroupWithoutVisibilityCreatesVisibleGroup()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object', $this->provideGroupWithoutMembers())
-            ->and(
-                'retrieving a hash list with all objects of type',
-                'Horde_Kolab_Server_Object_Kolabgroupofnames'
-            )
-            ->then(
-                'each element in the result list has an attribute set to a given value',
-                'visible', true
-            );
-    }
-
-    /**
-     * Test modifying a group mail address.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function modifyingGroupMailAddressIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "test@example.org"')
-            ->and('modifying the mail address to "new@example.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The group cannot be modified: Changing the mail address from "test@example.org" to "new@example.org" is not allowed!'
-            );
-    }
-
-    /**
-     * Test modifying a group mail address.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function conflictBetweenGroupMailAndUserMailIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "test@example.org"')
-            ->and('adding a user "Test Test" with the mail address "test@example.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The user cannot be added: Mail address "test@example.org" is already the mail address for the group "test@example.org"!'
-            );
-    }
-
-    /**
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function conflictBetweenUserMailAndGroupMailIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the mail address "test@example.org"')
-            ->and('adding a group with the mail address "test@example.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The group cannot be added: Mail address "test@example.org" is already the mail address of the user "Test Test"!'
-            );
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenGroupMailAndUserAliasIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "test@example.org"')
-            ->and('adding a user with the alias address "test@example.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The user cannot be added: Alias address "test@example.org" is already the mail address of the group "test@example.org"!'
-            );
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenUserAliasAndGroupMailIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the alias address "test@example.org"')
-            ->and('adding a group with the mail address "test@example.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The group cannot be added: Mail address "test@example.org" is already the alias address of the user "Test Test"!'
-            );
-    }
-
-    /**
-     *  kolab/issue890 (Assigning multiple Distribution Lists to user during creation and modification)
-     *
-     * @scenario
-     */
-    public function showGroupsWhenFetchingTheUser()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
-            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
-            ->and('fetching the user "test@example.org"')
-            ->and('listing the groups of this user')
-            ->then('the list should contain "testgroup@example.org"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function allowAddingUserToGroup()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "testgroup@example.org"')
-            ->and('adding a user "cn=Test Test" with the mail address "test@example.org"')
-            ->and('modifying group with the mail address "testgroup@example.org" to contain the member "cn=Test Test".')
-            ->and('fetching the groups "group@example.org"')
-            ->and('listing the members of this group')
-            ->then('the list should contain "test@example.org"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function allowAddingUserToGroupWhenCreatingUser()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "testgroup@example.org"')
-            ->and('adding a user "cn=Test Test" with the mail address "test@example.org" and member of "testgroup@example.org"')
-            ->and('fetching the groups "group@example.org"')
-            ->and('listing the members of this group')
-            ->then('the list should contain "test@example.org"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function allowRemovingUserFromGroup()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
-            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
-            ->and('modifying group with the mail address "testgroup@example.org" to contain no members.')
-            ->and('fetching the groups "group@example.org"')
-            ->and('listing the members of this group')
-            ->then('the list is empty');
-    }
-
-    /**
-     * @scenario
-     */
-    public function deletingUserRemovesUserFromAllDistributionLists()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
-            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
-            ->and('adding a group with the mail address "testgroup2@example.org" and the member "cn=Test Test"')
-            ->and('deleting user "cn=Test Test"')
-            ->and('listing the members of group "testgroup@example.org"')
-            ->and('listing the members of group "testgroup2@example.org"')
-            ->then('the list of group "testgroup@example.org" is empty')
-            ->and('the list of group "testgroup2@example.org" is empty');
-    }
-
-    /**
-     * @scenario
-     */
-    public function modifyingUserIDDoesNotChangeGroupMembership()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
-            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
-            ->and('modifying user "cn=Test Test" to ID "cn=Test2 Test"')
-            ->and('listing the members of group "testgroup@example.org"')
-            ->then('the list of group "testgroup@example.org" contains "cn=Test2 Test"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function addingGroupInUndefinedDomainIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->and('the only served mail domain is "example.org"')
-            ->when('adding a group with the mail address "test@doesnotexist.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The group cannot be added: Domain "doesnotexist.org" is not being handled by this server!'
-            );
-    }
-
-    /**
-     *   kolab/issue1368 (Webinterface allows to create email addresses with slash that cyrus cannot handle)
-     *
-     * @scenario
-     * @dataProvider invalidMails
-     */
-    public function disallowInvalidMailAddresses($address)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with an invalid mail address', $address)
-            ->then(
-                'the result should indicate an error with',
-                "The group cannot be added: Address \"$address\" is not a valid mail address!"
-            );
-    }
-
-    /**
-     * @scenario
-     */
-    public function objectAttributeDescriptionsCanBeRetrieved()
-    {
-        $this->given('several Kolab servers')
-            ->when('retrieving the supported attributes by the object type "group"')
-            ->then('the result is an array of Horde attribute descriptions')
-            ->and('contains the description of "members"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function removingGroupFailsIfGroupDoesNotExist()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "group@example.org"')
-            ->and('deleting the group with the mail address "group@example.org"')
-            ->then(
-                'the result should indicate an error with',
-                'The group cannot be deleted: Group "group@example.org" does not exist!'
-            );
-    }
-
-    /**
-     * @scenario
-     */
-    public function removingGroupByMailSucceeds()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "test@example.org"')
-            ->and('deleting the group with mail address "test@example.org"')
-            ->then('the result indicates success')
-            ->and('listing all groups returns an empty list');
-    }
-
-    /**
-     *      kolab/issue1189 (IMAP login fails on some specific uids)
-     *
-     * @scenario
-     */
-    public function userUidsShouldNotResembleTheLocalPartOfMailAddresses()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a group with the mail address "test@example.org"')
-            ->and('adding a user with the uid "test"')
-            ->then(
-                'the result should indicate an error with',
-                'The user cannot be added: The uid "test" matches the local part of the mail address "test@example.org" assigned to group "test@example.org"!'
-            );
-    }
-
-    /**
-     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
-     *
-     * @scenario
-     */
-    public function addedUserCanLoginIfInAllowedGroup()
-    {
-        $this->given('several Kolab servers')
-            ->and('Horde uses the Kolab auth driver')
-            ->and('only members of group "testgroup@example.org" are allowed')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
-            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
-            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
-            ->then('the result indicates success')
-            ->and('the session shows "test@example.org" as the current user');
-    }
-
-    /**
-     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
-     *
-     * @scenario
-     */
-    public function addedUserCannotLoginIfInNotInAllowedGroup()
-    {
-        $this->given('several Kolab servers')
-            ->and('Horde uses the Kolab auth driver')
-            ->and('only members of group "testgroup@example.org" are allowed')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
-            ->and('adding a group with the mail address "testgroup@example.org" and no members')
-            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
-            ->then('the user may not login');
-    }
-
-    /**
-     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
-     *
-     * @scenario
-     */
-    public function addedUserCanLoginIfInNotInDisallowedGroup()
-    {
-        $this->given('several Kolab servers')
-            ->and('Horde uses the Kolab auth driver')
-            ->and('members of group "testgroup@example.org" may not login')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
-            ->and('adding a group with the mail address "testgroup@example.org" and no members')
-            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
-            ->then('the result indicates success')
-            ->and('the session shows "test@example.org" as the current user');
-    }
-
-    /**
-     * kolab/issue2207 (Make it possible to enable and disable users to be able to use the webclient.)
-     *
-     * @scenario
-     */
-    public function addedUserCannotLoginIfInDisallowedGroup()
-    {
-        $this->given('several Kolab servers')
-            ->and('Horde uses the Kolab auth driver')
-            ->and('members of group "testgroup@example.org" may not login')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org" and password "test"')
-            ->and('adding a group with the mail address "testgroup@example.org" and the member "cn=Test Test"')
-            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
-            ->then('the user may not login');
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/GroupTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/GroupTest.php
deleted file mode 100644 (file)
index 698257e..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-/**
- * Test the group object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the group object.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Object_GroupTest extends Horde_Kolab_Server_Scenario
-{
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->ldap = $this->getKolabMockServer();
-    }
-
-    /**
-     * Add a group object.
-     *
-     * @return NULL
-     */
-    private function _addValidGroups()
-    {
-        $groups = $this->validGroups();
-        foreach ($groups as $group) {
-            $result = $this->ldap->add($group[0]);
-            $this->assertNoError($result);
-        }
-    }
-
-    /**
-     * Test ID generation for a group.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        $groups = $this->validGroups();
-        $user = new Horde_Kolab_Server_Object_Kolabgroupofnames($this->ldap,
-                                                                null,
-                                                                $groups[0][0]);
-        $this->assertNoError($user);
-        $this->assertEquals(
-            'cn=empty.group@example.org,dc=example,dc=org',
-            $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)
-        );
-    }
-
-    /**
-     * Test fetching a group.
-     *
-     * @return NULL
-     */
-    public function testFetchGroup()
-    {
-        $this->_addValidGroups();
-
-        $group = $this->ldap->fetch('cn=empty.group@example.org,dc=example,dc=org');
-        $this->assertNoError($group);
-        $this->assertEquals(
-            'Horde_Kolab_Server_Object_Kolabgroupofnames',
-            get_class($group)
-        );
-    }
-
-    /**
-     * Test fetching a group.
-     *
-     * @return NULL
-     */
-    public function testToHash()
-    {
-        $this->_addValidGroups();
-
-        $group = $this->ldap->fetch('cn=empty.group@example.org,dc=example,dc=org');
-        $this->assertNoError($group);
-
-        $hash = $group->toHash();
-        $this->assertNoError($hash);
-        $this->assertContains('mail', array_keys($hash));
-        $this->assertContains('id', array_keys($hash));
-        $this->assertContains('visible', array_keys($hash));
-        $this->assertEquals('empty.group@example.org', $hash['mail']);
-        $this->assertEquals('cn=empty.group@example.org', $hash['id']);
-        $this->assertTrue($hash['visible']);
-    }
-
-    /**
-     * Test listing groups.
-     *
-     * @return NULL
-     */
-    public function testListingGroups()
-    {
-        $result = $this->ldap->search(
-            '(&(!(cn=domains))(objectClass=kolabGroupOfNames))',
-            array(),
-            $this->ldap->getBaseUid()
-        );
-        $this->assertEquals(0, count($result));
-
-        $this->_addValidGroups();
-
-        $this->assertEquals(3, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
-        $result = $this->ldap->search(
-            '(&(!(cn=domains))(objectClass=kolabGroupOfNames))',
-            array(),
-            $this->ldap->getBaseUid()
-        );
-        $this->assertEquals(3, count($result));
-
-        $list = $this->ldap->listObjects(
-            'Horde_Kolab_Server_Object_Kolabgroupofnames'
-        );
-        $this->assertNoError($list);
-        $this->assertEquals(3, count($list));
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/InetorgpersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/InetorgpersonTest.php
deleted file mode 100644 (file)
index 157238b..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-<?php
-/**
- * Test the inetOrgPerson object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the inetOrgPerson object.
- *
- * 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_Object_InetorgpersonTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Objects used within this test
-     *
-     * @var array
-     */
-    private $objects = array(
-        /* Default inetOrgPerson */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Inetorgperson',
-            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
-            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_SN           => 'Mustermann',
-            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-        /* Invalid person (no sn) */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Inetorgperson',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_OrgPersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_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',
-            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_SN           => 'Mustermann',
-            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-    );
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-    }
-
-    /**
-     * Test ID generation for a person.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        foreach ($this->servers as $server) {
-            $a = new Horde_Kolab_Server_Object_Inetorgperson($server, null, $this->objects[0]);
-            $this->assertContains('Frank Mustermann',
-                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
-        }
-    }
-
-    /**
-     * Test adding an invalid person.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidPerson()
-    {
-        $this->addToServers($this->objects[1]);
-    }
-
-    /**
-     * Test a person with middle names.
-     *
-     * @return NULL
-     */
-    public function testHandlePersonWithMiddleNames()
-    {
-        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]));
-
-            $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'));
-
-            $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 => ''));
-
-            $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'));
-
-            $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 => ''));
-
-            $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'));
-
-            $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 => ''));
-        }
-    }
-
-    /**
-     * Test handling labeled URIs.
-     *
-     * @return NULL
-     */
-    public function testHandleLabeledUris()
-    {
-        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()));
-
-            $this->assertStoreFetch($person, $server,
-                                    array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => 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'),
-                                                                                                                 'b' => array('http://b.example.com'))));
-
-            $this->assertStoreFetch($person, $server,
-                                    array(Horde_Kolab_Server_Object_Inetorgperson::ATTRARRAY_LABELEDURI => 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'),
-                                                                                                                 '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()));
-
-            $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'))));
-        }
-    }
-
-
-    /**
-     * Test handling the home postal address.
-     *
-     * @return NULL
-     */
-    public function testHandlingHomePostalAddress()
-    {
-        //FIXME
-    }
-
-    /**
-     * Test handling easy attributes.
-     *
-     * @return NULL
-     */
-    public function testEasyAttributes()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_SID => ''));
-            $this->assertEasyAttributes($person, $server,
-                                        array(
-                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_SID => array(
-                                                'user',
-                                                '0',
-                                                'somebody',
-                                                null,
-                                                '',
-                                                array('he', 'she'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_ORGANIZATION => array(
-                                                'them',
-                                                '0',
-                                                'somebody',
-                                                null,
-                                                '',
-                                                array('they', 'we'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_BUSINESSCATEGORY => array(
-                                                'them',
-                                                '0',
-                                                'somebody',
-                                                null,
-                                                '',
-                                                array('they', 'we'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_HOMEPHONE => array(
-                                                '123456789',
-                                                '+1234567890',
-                                                array('1', '2'),
-                                                null,
-                                                '0'
-                                            ),
-                                            Horde_Kolab_Server_Object_Inetorgperson::ATTRIBUTE_MOBILE => array(
-                                                '123456789',
-                                                '+1234567890',
-                                                array('1', '2'),
-                                                null,
-                                                '0'
-                                            ),
-                                        )
-            );
-        }
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/KolabgermanbankarrangementTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/KolabgermanbankarrangementTest.php
deleted file mode 100644 (file)
index 3cf9637..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-/**
- * Test the kolabGermanBankArrangement object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the kolabGermanBankArrangement object.
- *
- * 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_Object_KolabgermanbankarrangementTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Objects used within this test
-     *
-     * @var array
-     */
-    private $objects = array(
-        /* Default bank account owner */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SN           => 'Mustermann',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-        /* Default account */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Kolabgermanbankarrangement',
-            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER   => '0123456789',
-            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_BANKCODE => '1111111',
-        ),
-    );
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-    }
-
-    /**
-     * Test ID generation for a person.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $account_data = $this->objects[1];
-            $account_data[Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID] = $person->getUid();
-            $a = new Horde_Kolab_Server_Object_Kolabgermanbankarrangement($server, null, $account_data);
-            $this->assertContains(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER . '=' . $this->objects[1][Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER],
-                                  $a->get(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_UID));
-        }
-    }
-
-    /**
-     * Test adding an invalid Account.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidAccount()
-    {
-        $this->addToServers($this->objects[1]);
-    }
-
-    /**
-     * Test handling easy attributes.
-     *
-     * @return NULL
-     */
-    public function testEasyAttributes()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $account_data = $this->objects[1];
-            $account_data[Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID] = $person->getUid();
-            $account = $this->assertAdd($server, $account_data,
-                                        array(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID => $person->getUid()));
-            $this->assertEasyAttributes($account, $server,
-                                        array(
-                                            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_HOLDER => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                array('a', 'b'),
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_BANKNAME => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                array('a', 'b'),
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_INFO => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                array('a', 'b'),
-                                                '',
-                                            ),
-                                        )
-            );
-        }
-    }
-
-    /**
-     * Test modifying the account number of an account. This should have an
-     * effect on the UID of the object and needs to rename the object.
-     *
-     * @return NULL
-     */
-    public function testModifyAccountNumber()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $account_data = $this->objects[1];
-            $account_data[Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_OWNERUID] = $person->getUid();
-            $account = $server->add($account_data);
-            $this->assertNoError($account);
-
-            $account = $server->fetch($account->getUid());
-            $this->assertNoError($account);
-
-            $this->assertEquals($this->objects[1][Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER],
-                                $account->get(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER));
-
-            $result = $account->save(array(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER => '66666666'));
-            $this->assertNoError($result);
-
-            $account = $server->fetch($account->getUid());
-            $this->assertNoError($account);
-
-            $this->assertEquals($account->get(Horde_Kolab_Server_Object_Kolabgermanbankarrangement::ATTRIBUTE_NUMBER),
-                                '66666666');
-
-            $result = $server->delete($account->getUid());
-            $this->assertNoError($result);
-        }
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/KolabinetorgpersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/KolabinetorgpersonTest.php
deleted file mode 100644 (file)
index 5458422..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-<?php
-/**
- * Test the kolabInetOrgPerson object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the kolabInetOrgPerson object.
- *
- * 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_Object_KolabinetorgpersonTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Objects used within this test
-     *
-     * @var array
-     */
-    private $objects = array(
-        /* Default kolabInetOrgPerson */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SN           => 'Mustermann',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-        /* Invalid person (no sn) */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_OrgPersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-    );
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-    }
-
-    /**
-     * Test ID generation for a person.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        foreach ($this->servers as $server) {
-            $a = new Horde_Kolab_Server_Object_Kolabinetorgperson($server, null, $this->objects[0]);
-            $this->assertContains('Frank Mustermann',
-                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
-        }
-    }
-
-    /**
-     * Test adding an invalid person.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidPerson()
-    {
-        $this->addToServers($this->objects[1]);
-    }
-
-    /**
-     * Test handling easy attributes.
-     *
-     * @return NULL
-     */
-    public function testEasyAttributes()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $this->assertEasyAttributes($person, $server,
-                                        array(
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GERMANTAXID => array(
-                                                '01234567890123456789',
-                                                '0',
-                                                '101',
-                                                null,
-                                                'DE',
-                                                array('101', '202'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_HOMESERVER => array(
-                                                'a.b.c',
-                                                '',
-                                                'jodeldodel',
-                                                null,
-                                                array('a.example.com', 'b.example.com'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_QUOTA => array(
-                                                '100',
-                                                null,
-                                                array('0', '1000'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALLOWEDRECIPIENTS => array(
-                                                '-a@example.com', 
-                                                '',
-                                                array('a', 'b'),
-                                                null,
-                                                '0'
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALLOWEDFROM => array(
-                                                '-a@example.com', 
-                                                '',
-                                                array('a', 'b'),
-                                                null,
-                                                '0'
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SALUTATION => array(
-                                                'Herr', 
-                                                'Mrs.',
-                                                null,
-                                                array('Herr', 'Mrs.'),
-                                                '0'
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GENDER => array(
-                                                '1',
-                                                null,
-                                                '0',
-                                                '2',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_BIRTHNAME => array(
-                                                'Adam',
-                                                null,
-                                                '',
-                                                '0',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_PLACEOFBIRTH => array(
-                                                'Jotwede',
-                                                null,
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_COUNTRY => array(
-                                                'DE',
-                                                'SE',
-                                                null,
-                                                'DE',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_COUNTRYCITIZENSHIP => array(
-                                                'DE',
-                                                'SE',
-                                                //FIXME: "null" does not work. Why?
-                                                //null,
-                                                'DE',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_LEGALFORM => array(
-                                                'GmbH',
-                                                'Freelancer',
-                                                null,
-                                                'Freelancer',
-                                            ),
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_REGISTEREDCAPITAL => array( */
-                                            /*                                             '1212121211', */
-                                            /*                                             '0', */
-                                            /*                                             null, */
-                                            /*                                             '' */
-                                            /*                                         ), */
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_BYLAWURI => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                             '', */
-                                            /*                                         ), */
-
-                                            //FIXME: Alias support
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DATEOFINCORPORATION => array( */
-                                            /*                                             '199911220707Z', */
-                                            /*                                         ), */
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_LEGALREPRESENTATIONPOLICY => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                             '', */
-                                            /*                                         ), */
-
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_VATNUMBER => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                array('a', 'b'),
-                                            ),
-
-                                            //FIXME: Undefined
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_OTHERLEGAL => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                         ), */
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_INLIQUIDATION => array( */
-                                            /*                                             'TRUE', */
-                                            /*                                             'FALSE', */
-                                            /*                                             null, */
-                                            /*                                             array('TRUE', 'FALSE'), */
-                                            /*                                         ), */
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRTYPE => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                         ), */
-
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRLOCATION => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                'somewhere',
-                                            ),
-
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRIDENTIFIER => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                'somewhere',
-                                            ),
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRURI => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                         ), */
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRLASTCHANGED => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                         ), */
-
-                                            // FIXME: Undefined in object class
-                                            /*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DC => array( */
-                                            /*                                             'something', */
-                                            /*                                             'somewhere', */
-                                            /*                                             null, */
-                                            /*                                             array('a', 'b'), */
-                                            /*                                         ), */
-
-                                            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALIAS => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                array('a', 'b'),
-                                            ),
-
-                                        )
-            );
-        }
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/Kolabpop3accountTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/Kolabpop3accountTest.php
deleted file mode 100644 (file)
index 6aa3726..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-<?php
-/**
- * Test the kolabExternalPop3Account object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the kolabExternalPop3Account object.
- *
- * 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_Object_Kolabpop3accountTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Objects used within this test
-     *
-     * @var array
-     */
-    private $objects = array(
-        /* Default bank account owner */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SN           => 'Mustermann',
-            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-        /* Default account */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Kolabpop3account',
-            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL      => 'frank@example.com',
-            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER    => 'pop.example.com',
-            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_LOGINNAME => 'frank',
-            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PASSWORD  => 'test',
-        ),
-    );
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-    }
-
-    /**
-     * Test ID generation for a person.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $account_data = $this->objects[1];
-            $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid();
-            $a = new Horde_Kolab_Server_Object_Kolabpop3account($server, null, $account_data);
-            $this->assertContains(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL . '=' . $this->objects[1][Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL],
-                                  $a->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_UID));
-        }
-    }
-
-    /**
-     * Test adding an invalid Account.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidAccount()
-    {
-        $this->addToServers($this->objects[1]);
-    }
-
-    /**
-     * Test handling easy attributes.
-     *
-     * @return NULL
-     */
-    public function testEasyAttributes()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $account_data = $this->objects[1];
-            $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid();
-            $account = $this->assertAdd($server, $account_data,
-                                        array(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID => $person->getUid()));
-            $this->assertEasyAttributes($account, $server,
-                                        array(
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PASSWORD => array(
-                                                'something',
-                                                'somewhere',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_DESCRIPTION => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => array(
-                                                'something',
-                                                'somewhere',
-                                                array('a', 'b'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PORT => array(
-                                                '110',
-                                                '111',
-                                                null,
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_USESSL => array(
-                                                'TRUE',
-                                                'FALSE',
-                                                null,
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_USETLS => array(
-                                                'TRUE',
-                                                'FALSE',
-                                                null,
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_LOGINMETHOD => array(
-                                                'something',
-                                                'somewhere',
-                                                null,
-                                                array('a', 'b'),
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_CHECKCERTIFICATE => array(
-                                                'TRUE',
-                                                'FALSE',
-                                                null,
-                                                '',
-                                            ),
-                                            Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_KEEPMAILONSERVER => array(
-                                                'TRUE',
-                                                'FALSE',
-                                                null,
-                                                '',
-                                            ),
-                                        )
-            );
-        }
-    }
-
-    /**
-     * Test modifying the attributes required for the UID of the account. This
-     * should lead to renaming object.
-     *
-     * @return NULL
-     */
-    public function testModifyUidElements()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
-            $account_data = $this->objects[1];
-            $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid();
-            $account = $server->add($account_data);
-            $account = $server->fetch($account->getUid());
-
-            $this->assertEquals($this->objects[1][Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER],
-                                $account->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER));
-
-            $result = $account->save(array(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => 'pop3s.example.com'));
-
-            $account = $server->fetch($account->getUid());
-
-            $this->assertContains(
-                'pop3s.example.com',
-                $account->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER, false)
-            );
-
-            $this->assertContains('frank@example.com', $account->getUid());
-
-            $result = $server->delete($account->getUid());
-        }
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/ObjectTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/ObjectTest.php
deleted file mode 100644 (file)
index f34fa6a..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-<?php
-/**
- * Test the object class.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * The the handling of objects.
- *
- * 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_ObjectTest extends Horde_Kolab_Server_Scenario
-{
-
-    /**
-     * Set up a dummy db object that will not be used during the
-     * tests. We just need it so that PHP does not complain about the
-     * inability to refernce the storage class.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->_dummydb = new DummyDB();
-    }
-
-    /**
-     * Provide test data for the ConstructDn test.
-     *
-     * @return array The test object data.
-     */
-    public static function provideConstructDn()
-    {
-        return array(
-            array('test', null, 'test'),
-            array(false, array('dn' => 'test'), 'test'),
-            array(false, array('dn' => array('test')), 'test'),
-            array('test2', array('dn' => array('test')), 'test2'),
-        );
-    }
-
-    /**
-     * Check a few DN values when constructing the object.
-     *
-     * @param string $dn     The uid for the object.
-     * @param string $data   Object data.
-     * @param string $expect Expect this uid.
-     *
-     * @dataProvider provideConstructDn
-     *
-     * @return NULL
-     */
-    public function testConstructDn($dn, $data, $expect)
-    {
-        $ko  = new Horde_Kolab_Server_Object($this->_dummydb, $dn, $data);
-        $ndn = $ko->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_UID);
-        $this->assertNoError($ndn);
-        $this->assertEquals($expect, $ndn);
-    }
-
-    /**
-     * Provide test data for the GetFn test.
-     *
-     * @return array The test object data.
-     */
-    public static function provideGetFn()
-    {
-        return array(
-            array(
-                array(
-                    'dn' => 'test',
-                    'cn' => 'Frank Mustermann',
-                    'sn' => 'Mustermann'),
-                'Frank'));
-    }
-
-    /**
-     * Check the generating of the "First Name" attribute.
-     *
-     * @param string $data   Object data.
-     * @param string $expect Expect this full name.
-     *
-     * @dataProvider provideGetFn
-     *
-     * @return NULL
-     */
-    public function testGetFn($data, $expect)
-    {
-        $ko = &Horde_Kolab_Server_Object::factory('Horde_Kolab_Server_Object_Kolab_User',
-                                                  null, $this->_dummydb, $data);
-        $this->assertNoError($ko);
-        $ndn = $ko->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN);
-        $this->assertNoError($ndn);
-        $this->assertEquals($expect, $ndn);
-    }
-
-
-    /**
-     * Provide test data for the GetFn test.
-     *
-     * @return array The test object data.
-     */
-    public static function provideGetArrayChanges()
-    {
-        return array(
-            array(
-                array(
-                    array(
-                        'a',
-                    ),
-                    array(
-                        'a',
-                    ),
-                ),
-                true,
-            ),
-            array(
-                array(
-                    array(
-                        'a',
-                    ),
-                    array(
-                        'b',
-                    ),
-                ),
-                false,
-            ),
-            array(
-                array(
-                    array(
-                    ),
-                    array(
-                        'a' => 'b',
-                    ),
-                ),
-                false,
-            ),
-            array(
-                array(
-                    array(
-                    ),
-                    array(
-                        'b',
-                    ),
-                ),
-                false,
-            ),
-        );
-    }
-
-    /**
-     * Check the generating of the "First Name" attribute.
-     *
-     * @param string $data   Object data.
-     * @param string $expect Expect this full name.
-     *
-     * @dataProvider provideGetArrayChanges
-     *
-     * @return NULL
-     */
-    public function testGetArrayChanges($data, $expect)
-    {
-        $ko = &Horde_Kolab_Server_Object::factory('Horde_Kolab_Server_Object_Kolab_User',
-                                                  null, $this->_dummydb, array(
-                                                      'dn' => 'test',
-                                                      'cn' => 'Frank Mustermann',
-                                                      'sn' => 'Mustermann'));
-        $this->assertNoError($ko);
-        $c = $ko->getArrayChanges($data[0], $data[1]);
-        $this->assertEquals($expect, empty($c));
-    }
-
-}
-
-/**
- * A dummy class for testing.
- *
- * 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 DummyDB
-{
-    public function getAttributes()
-    {
-        return array(array(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_UID => array(
-                               'method' => 'getUid',
-                           ),
-                           Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN => array(
-                               'method' => 'getFn',
-                           )),
-              array(
-                  'derived'  => array(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_UID,
-                                      Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN,
-                  ),
-                  'locked'   => array(),
-                  'required' => array()));
-    }
-
-    public function read()
-    {
-        return false;
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/OrgPersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/OrgPersonTest.php
deleted file mode 100644 (file)
index 9ff4ce9..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/**
- * Test the organizationalPerson object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the organizationalPerson object.
- *
- * 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_Object_OrgPersonTest extends Horde_Kolab_Server_Scenario
-{
-    /**
-     * Objects used within this test
-     *
-     * @var array
-     */
-    private $objects = array(
-        /* Default organizationalPerson */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Organizationalperson',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_OrgPersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_OrgPersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-        /* Invalid person (no sn) */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Organizationalperson',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_OrgPersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
-        ),
-    );
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-    }
-
-    /**
-     * Test ID generation for a person.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        foreach ($this->servers as $server) {
-            $a = new Horde_Kolab_Server_Object_Organizationalperson($server, null, $this->objects[0]);
-            $this->assertContains(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN . '=' . $this->objects[0][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN],
-                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
-        }
-    }
-
-    /**
-     * Test adding an invalid person.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidPerson()
-    {
-        $this->addToServers($this->objects[1]);
-    }
-
-    /**
-     * Test handling simple attributes.
-     *
-     * @return NULL
-     */
-    public function testSimpleAttributes()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_JOBTITLE => ''));
-            $this->assertSimpleAttributes($person, $server,
-                                          array(
-                                          ));
-        }
-    }
-
-    /**
-     * Test handling the postal address.
-     *
-     * @return NULL
-     */
-    public function testHandlingAPostalAddress()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => 'Kolab_Server_OrgPersonTest_123$$ '));
-
-            $this->assertStoreFetch($person, $server,
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_SN => 'Kolab_Server_OrgPersonTest_456'),
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_456$$ ')));
-
-            $this->assertStoreFetch($person, $server,
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_SN => 'Kolab_Server_OrgPersonTest_123',
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_STREET => 'Street 1',
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALCODE => '12345',
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_CITY => 'Nowhere'),
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_123$Street 1$12345 Nowhere')));
-            $this->assertStoreFetch($person, $server,
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTOFFICEBOX => 'öäü/)(="§%$&§§$\'*',
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_STREET => null),
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_123$öäü/)(="§%\24&§§\24\'*$12345 Nowhere')));
-
-            $this->assertStoreFetch($person, $server,
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_STREET => null,
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALCODE => null,
-                                          //FIXME: Why does this need a string?
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => '',
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTOFFICEBOX => null,
-                                          Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_CITY => null),
-                                    array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_POSTALADDRESS => array('Kolab_Server_OrgPersonTest_123$$ ')));
-        }
-    }
-
-
-    /**
-     * Test handling easy attributes.
-     *
-     * @return NULL
-     */
-    public function testEasyAttributes()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[0],
-                                       array(Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_JOBTITLE => ''));
-            $this->assertEasyAttributes($person, $server,
-                                        array(
-                                            Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_JOBTITLE => array(
-                                                'Teacher',
-                                                '0',
-                                                'Something',
-                                                null,
-                                                '',
-                                                array('This', 'That'),
-                                            ),
-                                            Horde_Kolab_Server_Object_Organizationalperson::ATTRIBUTE_FAX => array(
-                                                '123456789',
-                                                '+1234567890',
-                                                array('1', '2'),
-                                                '0',
-                                                //FIXME: How to delete?
-                                                //null
-                                            )
-                                        )
-            );
-        }
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/PersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/PersonTest.php
deleted file mode 100644 (file)
index cfdc297..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-<?php
-/**
- * Test the person object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the person object.
- *
- * 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_Object_PersonTest extends Horde_Kolab_Server_Scenario
-{
-
-    public $cn = 'Kolab_Server_PersonTest';
-
-    /**
-     * Objects used within this test
-     *
-     * @var array
-     */
-    private $objects = array(
-        /* Default dummy person */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_123',
-        ),
-        /* Invalid person (no sn) */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_123',
-        ),
-        /* Person with problematic characters */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_!"$%&()=?',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_!"$%&()=?',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_!"$%&()=?',
-        ),
-        /* Person with difficult encoding */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_ügöräß§',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_ügöräß§',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_ügöräß§',
-        ),
-        /* Person with forward slash */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_/',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_/',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_/',
-        ),
-        /* Person with double cn */
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => array('Kolab_Server_PersonTest_cn1',
-                                                                              'Kolab_Server_PersonTest_cn2'),
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_cncn',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_cncn',
-        ),
-        /* Person with name suffix*/
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_123',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_123',
-        ),
-        /* Person for telephone number handling*/
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_123456',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_123456',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_123456',
-        ),
-        /* Person with a creation date*/
-        array(
-            'type' => 'Horde_Kolab_Server_Object_Person',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_PersonTest_123456',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN           => 'Kolab_Server_PersonTest_123456',
-            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_PersonTest_123456',
-            'Creationdate' => '191008030000Z',
-        ),
-    );
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-    }
-
-    /**
-     * Test ID generation for a person.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        foreach ($this->servers as $server) {
-            $a = new Horde_Kolab_Server_Object_Person($server, null, $this->objects[0]);
-            $this->assertContains(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN . '=' . $this->objects[0][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN],
-                                  $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
-        }
-    }
-
-    /**
-     * Test adding an invalid person.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidPerson()
-    {
-        $this->addToServers($this->objects[1]);
-    }
-
-    /**
-     * Test adding a person.
-     *
-     * @return NULL
-     */
-    public function testAddPerson()
-    {
-        foreach ($this->servers as $server) {
-            $adds = array(0, 2, 3, 4);
-            foreach ($adds as $add) {
-                $result = $server->add($this->objects[$add]);
-                $this->assertNoError($result);
-                $cn_result = $server->uidForCn($this->objects[$add][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN]);
-                $this->assertNoError($cn_result);
-                $dn_parts = Net_LDAP2_Util::ldap_explode_dn($cn_result, array('casefold' => 'lower'));
-                $dnpart = Net_LDAP2_Util::unescape_dn_value($dn_parts[0]);
-                /**
-                 * FIXME: I currently do not really understand why the forward slash
-                 * is not correctly converted back but I lack the time to analyse it
-                 * in detail. The server entry looks okay.
-                 */
-                $dnpart = str_replace('\/', '/', $dnpart);
-                $this->assertContains(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN . '=' . $this->objects[$add][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN],
-                                      $dnpart[0]);
-                $result = $server->delete($cn_result);
-                $this->assertNoError($result);
-                $cn_result = $server->uidForCn($this->objects[$add][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN]);
-                $this->assertNoError($cn_result);
-                $this->assertFalse($server->uidForCn($this->objects[$add][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN]));
-            }
-        }
-    }
-
-    /**
-     * Test modifying the surname of a person.
-     *
-     * @return NULL
-     */
-    public function testModifyPersonSn()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[2],
-                                       array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN => $this->objects[2][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN]));
-            $this->assertSimpleSequence($person, $server,
-                                        Horde_Kolab_Server_Object_Person::ATTRIBUTE_SN,
-                                        array('modified', 'modified_again'), true);
-        }
-    }
-
-    /**
-     * Test modifying the cn of a person. This should have an effect on the UID
-     * of the object and needs to rename the object.
-     *
-     * @return NULL
-     */
-    public function testModifyPersonCn()
-    {
-        foreach ($this->servers as $server) {
-            $person = $server->add($this->objects[2]);
-            $this->assertNoError($person);
-
-            $person = $server->fetch($person->getUid());
-
-            $this->assertEquals($this->objects[2][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN],
-                                $person->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN));
-
-            $result = $person->save(array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN => 'Kolab_Server_PersonTest_äö'));
-            $cn_result = $server->uidForCn('Kolab_Server_PersonTest_äö');
-            $person = $server->fetch($cn_result);
-            $this->assertEquals($person->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN),
-                                'Kolab_Server_PersonTest_äö');
-            $result = $server->delete($cn_result);
-            $this->assertNoError($result);
-            $cn_result = $server->uidForCn('Kolab_Server_PersonTest_äö');
-            $this->assertNoError($cn_result);
-            $this->assertFalse($cn_result);
-        }
-    }
-
-    /**
-     * Test adding a person with two common names.
-     *
-     * @return NULL
-     */
-    public function testAddDoubleCnPerson()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[5],
-                                       array());
-
-            $cn_result = $server->uidForCn($this->objects[5][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN][0]);
-            $this->assertNoError($cn_result);
-            $dn_parts = Net_LDAP2_Util::ldap_explode_dn($cn_result, array('casefold' => 'lower'));
-            $dnpart = Net_LDAP2_Util::unescape_dn_value($dn_parts[0]);
-            $this->assertContains(Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN . '=' . $this->objects[5][Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN][0],
-                                  $dnpart[0]);
-        }
-    }
-
-    /**
-     * Test handling a phone number.
-     *
-     * @return NULL
-     */
-    public function testHandlingAPhoneNumaber()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[7],
-                                       array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_TELNO => ''));
-            $this->assertSimpleSequence($person, $server,
-                                        Horde_Kolab_Server_Object_Person::ATTRIBUTE_TELNO,
-                                        array('123456789', '+1234567890', array('1', '2'), null, '0'), true);
-        }
-    }
-
-    /**
-     * Test retrrieving a date.
-     *
-     * @return NULL
-     */
-    public function testGetDate()
-    {
-        foreach ($this->servers as $server) {
-            $person = $this->assertAdd($server, $this->objects[8],
-                                       array(Horde_Kolab_Server_Object_Person::ATTRIBUTE_TELNO => ''));
-            $cdate = $person->get(Horde_Kolab_Server_Object_Person::ATTRDATE_CREATIONDATE);
-            $this->assertEquals('Horde_Date', get_class($cdate));
-            $this->assertEquals('1910-08-03 01:00:00', (string) $cdate);
-        }
-    }
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/UserHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/UserHandlingTest.php
deleted file mode 100644 (file)
index a12e306..0000000
+++ /dev/null
@@ -1,639 +0,0 @@
-<?php
-/**
- * Handling 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';
-
-/**
- * Handling users.
- *
- * 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_UserHandlingTest extends Horde_Kolab_Server_Scenario
-{
-
-    /**
-     * Test listing userss if there are no users.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function listingUsersOnEmptyServer()
-    {
-        $this->given('several Kolab servers')
-            ->when('listing all users')
-            ->then('the list is an empty array');
-    }
-
-    /**
-     * Test listing users after adding some users.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUsersAfterAddingUsers($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object list', $user_list)
-            ->and('listing all users')
-            ->then('the list has a number of entries equal to', count($user_list));
-    }
-
-    /**
-     * Test listing users after adding some users.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUserCount($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding an object list', $user_list)
-            ->and('retriving the result count')
-            ->then('the count equals to', count($user_list));
-    }
-
-    /**
-     * Test the list of users for the user id.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUsersHasAttributeId($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user list', $user_list)
-            ->then('the user list contains the unique ID for each user')
-            ->and('the user list contains the user type for each user');
-    }
-
-    /**
-     * Test the list of users for the user type.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUsersHasAttributeType($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user list', $user_list)
-            ->then('the user list contains the user type for each user');
-    }
-
-    /**
-     * Test the list of users for the user full name.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUsersHasAttributeFullName($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user list', $user_list)
-            ->then('the user list contains the full name for each user');
-    }
-
-    /**
-     * Test the list of users for the user mail.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUsersHasAttributeEmail($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user list', $user_list)
-            ->then('the user list contains the email for each user');
-    }
-
-    /**
-     * Test the list of users for the user uid.
-     *
-     * @param array $user_list The users to add.
-     *
-     * @scenario
-     * @dataProvider userLists
-     *
-     * @return NULL
-     */
-    public function listingUsersHasAttributeUid($user_list)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user list', $user_list)
-            ->then('the list contains the uid for each user');
-    }
-
-    /**
-     * @scenario
-     * @dataProvider userListByLetter
-     */
-    public function listingUsersCanBeRestrictedByStartLetterOfTheLastName($letter, $count)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding user list', $this->largeList())
-            ->and('retrieving the result count of a list restricted by the start letter of the last name', $letter)
-            ->then('the list contains a correct amount of results', $count);
-    }
-
-    /**
-     * @scenario
-     * @dataProvider userListByLetter
-     */
-    public function countingUsersCanBeRestrictedByStartLetterOfTheLastName($letter, $count)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding user list', $this->largeList())
-            ->and('retrieving the result count of a list restricted by the start letter of the last name', $letter)
-            ->then('the count contains a correct number', $count);
-    }
-
-    /**
-     * @scenario
-     * @dataProvider userListByAttribute
-     */
-    public function countingUsersCanBeRestrictedByContentsInAnAttribute($attribute, $content, $count)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding user list', $this->largeList())
-            ->and('retrieving the result count of a list restricted by content in an attribute', $attribute, $content)
-            ->then('the count contains a correct number', $count);
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithoutTypeCreatesStandardUser()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user without user type')
-            ->then('a standard user has been created');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithoutInvitationPolicySetsManualPolicy()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user without an invitation policy')
-            ->then('the added user has a manual policy');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithoutHomeServerFails()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user without a home server')
-            ->then('the result should indicate an error with', 'The user cannot be added: The home Kolab server (or network) has not been specified!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserForDistributedKolabWithoutImapServerFails()
-    {
-        $this->given('several Kolab servers')
-            ->and('distributed Kolab')
-            ->when('adding a user without an imap server')
-            ->then('the result should indicate an error with', 'The user cannot be added: The home imap server has not been specified!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithImapServerFailsOnNonDistributedKolab()
-    {
-        $this->given('several Kolab servers')
-            ->and('monolithic Kolab')
-            ->when('adding a user with an imap server')
-            ->then('the result should indicate an error with', 'The user cannot be added: A home imap server is only supported with a distributed Kolab setup!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithFreeBusyServerFailsOnNonDistributedKolab()
-    {
-        $this->given('several Kolab servers')
-            ->and('monolithic Kolab')
-            ->when('adding a user with a free/busy server')
-            ->then('the result should indicate an error with', 'The user cannot be added: A seperate free/busy server is only supported with a distributed Kolab setup!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function modifyingUserMailAddressIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the mail address "test@example.org"')
-            ->and('modifying the mail address to "new@example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be modified: Changing the mail address from "test@example.org" to "new@example.org" is not allowed!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function modifyingUserHomeServerIsNotAllowd()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the home server "test.example.org"')
-            ->and('modifying the home server to "new.example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be modified: Changing the home server from "test.example.org" to "new.example.org" is not allowed!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function modifyingUserImapServerIsNotAllowd()
-    {
-        $this->given('several Kolab servers')
-            ->and('distributed Kolab')
-            ->when('adding a user with the imap server "test.example.org"')
-            ->and('modifying the imap server to "new.example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be modified: Changing the imap server from "test.example.org" to "new.example.org" is not allowed!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenMailAndMailIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the mail address "test@example.org"')
-            ->and('adding a user "Test2 Test2" with the mail address "test@example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Mail address "test@example.org" is already the mail address of user "Test Test"!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenMailAndAliasIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the mail address "test@example.org"')
-            ->and('adding a user with the alias address "test@example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Alias address "test@example.org" is already the mail address of user "Test Test"!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenAliasAndAliasIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the alias address "test@example.org"')
-            ->and('adding a user with the alias address "test@example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Alias address "test@example.org" is already the alias address of user "Test Test"!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenMailAndUidIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the mail address "test@example.org"')
-            ->and('adding a user with the uid "test@example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Uid "test@example.org" is already the mail address of user "Test Test"!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function conflictBetweenUidAndUidIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "Test Test" with the uid "test"')
-            ->and('adding a user with the uid "test"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Uid "test" is already the uid of user "Test Test"!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function nonExistingDelegateIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the delegate address "test@example.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Delegate address "test@example.org" does not exist!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function addingUserInUndefinedDomainIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->and('the only served mail domain is "example.org"')
-            ->when('adding a user with the mail address "test@doesnotexist.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Domain "doesnotexist.org" is not being handled by this server!');
-    }
-
-    /**
-     *  kolab/issue444 (a kolab user may delegate to an external user which should not be possible)
-     *
-     * @scenario
-     */
-    public function addingUserWithDelegateInUndefinedDomainIsNotAllowed()
-    {
-        $this->given('several Kolab servers')
-            ->and('the only served mail domain is "example.org"')
-            ->when('adding a user with the delegate mail address "test@doesnotexist.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Domain "doesnotexist.org" is not being handled by this server!');
-    }
-
-    /**
-     *   kolab/issue1368 (Webinterface allows to create email addresses with slash that cyrus cannot handle)
-     *
-     * @scenario
-     * @dataProvider invalidMails
-     */
-    public function disallowInvalidMailAddresses($address)
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with an invalid mail address', $address)
-            ->then('the result should indicate an error with', "The user cannot be added: Address \"$address\" is not a valid mail address!");
-    }
-
-    /**
-     * @scenario
-     */
-    public function addingUserOnUndefinedHomeServer()
-    {
-        $this->given('several Kolab servers')
-            ->and('the only home server in the network is "example.org"')
-            ->when('adding a user with the home server "doesnotexist.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Host "doesnotexist.org" is not part of the Kolab network!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function addingUserOnUndefinedImapServer()
-    {
-        $this->given('several Kolab servers')
-            ->and('distributed Kolab')
-            ->and('the only imap server in the network is "example.org"')
-            ->when('adding a user with the imap server "doesnotexist.org"')
-            ->then('the result should indicate an error with', 'The user cannot be added: Imap server "doesnotexist.org" is not part of the Kolab network!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function userAttributesCanBeExtended()
-    {
-        $this->given('several Kolab servers')
-            ->and('an extended attribute "test" has been defined')
-            ->when('adding a user with the attribute "test" set to "FIND ME"')
-            ->then('the result indicates success')
-            ->and('the user can be found using the "test" attribute with the value "FIND ME"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function extendedObjectAttributeDescriptionsCanBeRetrieved()
-    {
-        $this->given('several Kolab servers')
-            ->and('an extended attribute "test" has been defined')
-            ->when('retrieving the supported attributes by the object type "user"')
-            ->then('the result is an array of Horde attribute descriptions')
-            ->and('contains the description of "test"');
-    }
-
-    /**
-     * @scenario
-     */
-    public function removingUserFailsIfUserDoesNotExist()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the ID "cn=Test Test"')
-            ->and('deleting the user with the ID "cn=Dummy Dummy"')
-            ->then('the result should indicate an error with', 'The user cannot be deleted: User "cn=Dummy Dummy" does not exist!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function removingUserByMailSucceeds()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the mail address "test@example.org"')
-            ->and('deleting the user with mail address "test@example.org"')
-            ->then('the result indicates success')
-            ->and('listing all users returns an empty list');
-    }
-
-    /**
-     * @scenario
-     */
-    public function removingUserByIdSucceeds()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the ID "cn=Test Test"')
-            ->and('deleting the user with the ID "cn=Test Test"')
-            ->then('the result indicates success')
-            ->and('listing all users returns an empty list');
-    }
-
-    /**
-     * @scenario
-     */
-    public function addedUserCanLogin()
-    {
-        $this->given('several Kolab servers')
-            ->and('Horde uses the Kolab auth driver')
-            ->when('adding a user with the mail address "test@example.org" and password "test"')
-            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
-            ->then('the result indicates success')
-            ->and('the session shows "test@example.org" as the current user');
-    }
-
-    /**
-     * @scenario
-     */
-    public function allowUserWithExtendedObjectClasses()
-    {
-        $this->given('several Kolab servers')
-            ->and('an extended set of objectclasses')
-            ->when('adding a user with the mail address "test@example.org"')
-            ->and('fetching user "test@example.org"')
-            ->then('has the additional object classes set');
-    }
-
-    /**
-     * @scenario
-     */
-    public function allowToCheckUserPasswords()
-    {
-        $this->given('several Kolab servers')
-            ->and('password check enabled')
-            ->when('adding a user with the mail address "test@example.org" and password "tosimple"')
-            ->then('the result should indicate an error with', 'The user cannot be added: The chosen password is not complex enough!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function allowToSetAttributeDefaults()
-    {
-        $this->given('several Kolab servers')
-            ->and('an extended attribute "test" with the default value "test" has been defined')
-            ->when('adding a user with the mail address "test@example.org" and an empty attribute "test"')
-            ->and('fetching user "test@example.org"')
-            ->then('the user object has the attribute "test" set to "test"');
-    }
-
-    /**
-     * kolab/issue2742 (Have a default quota value when creating new users via the web interface)
-     *
-     * @scenario
-     */
-    public function allowToSetDomainSpecificAttributeDefaults()
-    {
-        $this->given('several Kolab servers')
-            ->and('domain "example.org" is served by the Kolab server')
-            ->and('domain "example2.org" is served by the Kolab server')
-            ->and('an extended attribute "test" with the default value "test" has been defined')
-            ->and('an extended attribute "test" with the default value "test2" has been defined for domain example2.org')
-            ->when('adding a user with the mail address "test@example.org" and an empty attribute "test"')
-            ->and('adding a user with the mail address "test@example2.org" and an empty attribute "test"')
-            ->and('fetching user "test@example.org" and "test@example2.org"')
-            ->then('the user "test@example.org" has the attribute "test" set to "test"')
-            ->and('the user "test@example2.org" has the attribute "test" set to "test2"');
-    }
-
-    /**
-     *     kolab/issue3035 (Initialise internal Horde parameters when creating a user)
-     *
-     * @scenario
-     * @dataProvider userAdd
-     */
-    public function addedUserHasPreferencesInitialized()
-    {
-        $this->given('several Kolab servers')
-            ->and('Horde uses the Kolab auth driver')
-            ->when('adding a user', $user)
-            ->and('trying to login to Horde with "test@example.org" and passowrd "test"')
-            ->then('the preferences are automatically set to the user information', $user);
-    }
-
-    /**
-     *      kolab/issue1189 (IMAP login fails on some specific uids)
-     *
-     * @scenario
-     */
-    public function userUidsShouldNotResembleTheLocalPartOfMailAddresses()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user "cn=Test Test" with the mail address "test@example.org"')
-            ->and('adding a user with the uid "test"')
-            ->then('the result should indicate an error with', 'The user cannot be added: The uid "test" matches the local part of the mail address "test@example.org" assigned to user "cn=Test Test"!');
-    }
-
-    /**
-     *  kolab/issue606 (It is not possible to register people with middlename correctly)
-     *
-     * @scenario
-     */
-    public function allowToSetTheMiddleName()
-    {
-        $this->given('several Kolab servers')
-            ->and('an extended attribute "middleName" has been defined')
-            ->when('adding a user with the mail address "test@example.org" and the middle name "Middle"')
-            ->and('fetching user "test@example.org"')
-            ->then('the user object has the attribute "middleName" set to "Middle"');
-    }
-
-    /**
-     *   kolab/issue1880 (Poor handling of apostrophes in ldap and admin webpages)
-     *
-     * @scenario
-     */
-    public function correctlyEscapeApostrophesInNames()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the mail address "test@example.org" and the last name "O\'Donnell"')
-            ->and('fetching user "test@example.org"')
-            ->then('the user name has the attribute "sn" set to "O\'Donnell"');
-    }
-
-    /**
-     *    kolab/issue1677 (Allow a user to use an external address as sender)
-     *
-     * @scenario
-     */
-    public function allowUserToUseExternalAddressAsSender()
-    {
-        $this->given('several Kolab servers')
-            ->when('adding a user with the mail address "test@example.org" and the external address "other@doesnotexist.org"')
-            ->and('fetching user "test@example.org"')
-            ->then('the user has the attribute external address "other@doesnotexist.org"');
-    }
-
-    /**
-     *     kolab/issue3036 (cn = "givenName sn" ?)
-     *
-     * @scenario
-     */
-    public function allowCustomFullnameHandling()
-    {
-        $this->given('several Kolab servers')
-            ->and('an extended attribute "middleName" has been defined')
-            ->and('custom full name handling has been set to "lastname, firstname middlename"')
-            ->when('adding a user with the mail address "test@example.org", the last name "Test", the first name "Test", and the middle name "Middle"')
-            ->and('fetching user "test@example.org"')
-            ->then('the user has the attribute full name "Test, Test Middle"');
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Object/UserTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Object/UserTest.php
deleted file mode 100644 (file)
index 8acceaf..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-/**
- * Test the user object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the user object.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Object_UserTest extends Horde_Kolab_Server_Scenario
-{
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->server = $this->getKolabMockServer();
-        $users        = $this->validUsers();
-        foreach ($users as $user) {
-            $result = $this->server->add($user[0]);
-        }
-    }
-
-    /**
-     * Test ID generation for a user.
-     *
-     * @return NULL
-     */
-    public function testGenerateId()
-    {
-        $users = $this->validUsers();
-        $user = new Horde_Kolab_Server_Object_Kolab_User($this->server, null, $users[0][0]);
-        $this->assertNoError($user);
-        $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID));
-    }
-
-    /**
-     * Test adding invalid user.
-     *
-     * @expectedException Horde_Kolab_Server_Exception
-     *
-     * @return NULL
-     */
-    public function testAddInvalidUser()
-    {
-        $user   = $this->provideInvalidUserWithoutGivenName();
-        $result = $this->server->add($user);
-    }
-
-    /**
-     * Test fetching a user.
-     *
-     * @return NULL
-     */
-    public function testFetchUser()
-    {
-        $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
-        $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
-        $this->assertEquals('Gunnar Wrobel', $user->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FNLN));
-    }
-
-    /**
-     * Test fetching server information.
-     *
-     * @return NULL
-     */
-    public function testGetServer()
-    {
-        $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
-        $imap = $user->getServer('imap');
-        $this->assertEquals('imap.example.org', $imap);
-
-        $user = $this->server->fetch('cn=Test Test,dc=example,dc=org');
-        $imap = $user->getServer('imap');
-        $this->assertEquals('home.example.org', $imap);
-
-        $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
-        $attr = $user->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FREEBUSYHOST);
-        $this->assertEquals('https://fb.example.org/freebusy', $attr);
-
-        $imap = $user->getServer('freebusy');
-        $this->assertEquals('https://fb.example.org/freebusy', $imap);
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Objects/ServerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Objects/ServerTest.php
new file mode 100644 (file)
index 0000000..415540e
--- /dev/null
@@ -0,0 +1,132 @@
+<?php
+/**
+ * Test the server class.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Tests for the main server class.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Objects_ServerTest extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->markTestIncomplete('Needs to be fixed');
+    }
+
+    /**
+     * Provide a mock server.
+     *
+     * @return Horde_Kolab_Server The mock server.
+     */
+    protected function getMockServer()
+    {
+        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+        $config = new stdClass;
+        $config->driver = 'none';
+        $injector->setInstance('Horde_Kolab_Server_Config', $config);
+        $injector->bindFactory('Horde_Kolab_Server_Structure',
+                               'Horde_Kolab_Server_Factory',
+                               'getStructure');
+        $injector->bindFactory('Horde_Kolab_Server',
+                               'Horde_Kolab_Server_Factory',
+                               'getServer');
+        return $injector->getInstance('Horde_Kolab_Server');
+    }
+
+    /**
+     * The generating a uid for an object.
+     *
+     * @return NULL
+     */
+    public function testGenerateUid()
+    {
+        $ks   = $this->getMockServer();
+        $user = new Horde_Kolab_Server_Object($ks, null, null);
+        $this->assertEquals(preg_replace('/[0-9a-f]*/', '', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)), '');
+    }
+
+    /**
+     * Test creating the server object.
+     *
+     * @return NULL
+     */
+    public function testCreation()
+    {
+        try {
+            $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+            $config = new stdClass;
+            $config->driver = 'dummy';
+            $injector->setInstance('Horde_Kolab_Server_Config', $config);
+            $injector->bindFactory('Horde_Kolab_Server_Structure',
+                                   'Horde_Kolab_Server_Factory',
+                                   'getStructure');
+            $injector->bindFactory('Horde_Kolab_Server',
+                                   'Horde_Kolab_Server_Factory',
+                                   'getServer');
+            Horde_Kolab_Server_Factory::getServer($injector);
+            $this->assertFail('No error!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals('Server type definition "Horde_Kolab_Server_Dummy" missing.',
+                                $e->getMessage());
+        }
+    }
+
+    /**
+     * The base class provides no abilities for reading data. So it
+     * should mainly return error. But it should be capable of
+     * returning a dummy Kolab user object.
+     *
+     * @return NULL
+     */
+    public function testFetch()
+    {
+        $ks   = $this->getMockServer();
+        $user = $ks->fetch('test');
+        $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
+
+        $ks   = $this->getMockServer();
+        $user = $ks->fetch();
+        $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
+    }
+
+    /**
+     * Test listing objects.
+     *
+     * @return NULL
+     */
+    public function testList()
+    {
+        $ks   = $this->getMockServer();
+        $hash = $ks->listHash('Horde_Kolab_Server_Object');
+        $this->assertEquals($hash, array());
+
+        $ks   = $this->getMockServer();
+        $hash = $ks->listHash('Horde_Kolab_Server_Object');
+        $this->assertEquals($hash, array());
+    }
+
+}
index f01a794..2f6eef1 100644 (file)
@@ -174,7 +174,7 @@ class Horde_Kolab_Server_Query_LdapTest extends Horde_Kolab_Server_LdapBase
 
         /** Hide strict errors from the Net_LDAP2 library */
         $error_reporting = error_reporting();
-        error_reporting($error_reporting E_STRICT);
+        error_reporting($error_reporting & ~E_STRICT);
 
         try {
             $query->convertOr($or)->asString();
index 4da773a..668a68e 100644 (file)
@@ -12,9 +12,9 @@
  */
 
 /**
- * Prepare the test setup.
+ * Require our basic test case definition
  */
-require_once dirname(__FILE__) . '/../Autoload.php';
+require_once dirname(__FILE__) . '/../LdapBase.php';
 
 /**
  * Test the LDAP result handler.
@@ -30,19 +30,8 @@ require_once dirname(__FILE__) . '/../Autoload.php';
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Kolab_Server
  */
-class Horde_Kolab_Server_Result_LdapTest extends PHPUnit_Framework_TestCase
+class Horde_Kolab_Server_Result_LdapTest extends Horde_Kolab_Server_LdapBase
 {
-    public function setUp()
-    {
-        if (!extension_loaded('ldap') && !@dl('ldap.' . PHP_SHLIB_SUFFIX)) {
-            $this->markTestSuiteSkipped('Ldap extension is missing!');
-        };
-
-        if (!class_exists('Net_LDAP2')) {
-            $this->markTestSuiteSkipped('PEAR package Net_LDAP2 is not installed!');
-        }
-    }
-
     public function testMethodConstructHasParameterNetldap2searchSearchResult()
     {
         $search = $this->getMock(
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Scenario.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Scenario.php
deleted file mode 100644 (file)
index 9248f8f..0000000
+++ /dev/null
@@ -1,1085 +0,0 @@
-<?php
-/**
- * Base for PHPUnit scenarios.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Test
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Share
- */
-
-/**
- * Base for PHPUnit scenarios.
- *
- * 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_Test
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Share
- */
-class Horde_Kolab_Server_Scenario extends PHPUnit_Extensions_Story_TestCase
-{
-    /** The mock environment */
-    const ENVIRONMENT_MOCK = 'mock';
-
-    /** The real server environment */
-    const ENVIRONMENT_REAL = 'real';
-
-    /**
-     * The environments we provide to the test.
-     *
-     * @var array
-     */
-    protected $_environments;
-
-    /**
-     * Uid of added objects. Should be removed on tearDown.
-     *
-     * @var array
-     */
-    public $added;
-
-    /**
-     * Handle a "given" step.
-     *
-     * @param array  &$world    Joined "world" of variables.
-     * @param string $action    The description of the step.
-     * @param array  $arguments Additional arguments to the step.
-     *
-     * @return mixed The outcome of the step.
-     */
-    public function runGiven(&$world, $action, $arguments)
-    {
-        switch($action) {
-        case 'several injectors':
-            foreach ($this->getEnvironments() as $environment) {
-                $this->prepareInjector($environment);
-            }
-            break;
-        case 'several Kolab servers':
-        case 'the test environments':
-            $this->initializeEnvironments();
-            break;
-        case 'an empty Kolab server':
-            $world['server'] = $this->prepareKolabServer(self::ENVIRONMENT_MOCK);
-            break;
-        case 'a basic Kolab server':
-            $world['server'] = $this->prepareBasicKolabServer($world);
-            break;
-        default:
-            return $this->notImplemented($action);
-        }
-    }
-
-    /**
-     * Handle a "when" step.
-     *
-     * @param array  &$world    Joined "world" of variables.
-     * @param string $action    The description of the step.
-     * @param array  $arguments Additional arguments to the step.
-     *
-     * @return mixed The outcome of the step.
-     */
-    public function runWhen(&$world, $action, $arguments)
-    {
-        switch($action) {
-        case 'adding a Kolab server object':
-            $world['result']['add'] = $this->addToServers($arguments[0]);
-            break;
-        case 'adding an invalid Kolab server object':
-            try {
-                $world['result']['add'] = $this->addToServers($arguments[0]);
-            } catch (Horde_Kolab_Server_Exception $e) {
-                $world['result']['add'] = $e;
-            }
-            break;
-        case 'adding an object list':
-            foreach ($arguments[0] as $object) {
-                try {
-                    $world['result']['add'][] = $this->addToServers($object);
-                } catch (Horde_Kolab_Server_Exception $e) {
-                    $world['result']['add'] = $e;
-                    return;
-                }
-            }
-            $world['result']['add'] = true;
-            break;
-        case 'adding a distribution list':
-            $world['result']['add'] = $this->addToServers($this->provideDistributionList());
-            break;
-        case 'listing all users':
-            $world['list'] = $this->listObjectsOnServer('Horde_Kolab_Server_Object_Kolab_User');
-            break;
-        case 'listing all groups':
-            $world['list'] = $this->listObjectsOnServer('Horde_Kolab_Server_Object_Kolabgroupofnames');
-            break;
-        case 'listing all objects of type':
-            $world['list'] = $this->listObjectsOnServer($arguments[0]);
-            break;
-        case 'retrieving a hash list with all objects of type':
-            $world['list'] = array();
-            foreach ($this->world['injector'] as $injector) {
-                $server = $injector->getInstance('Horde_Kolab_Server');
-                $world['list'][] = $server->listHash($arguments[0]);
-            }
-            break;
-        default:
-            return $this->notImplemented($action);
-        }
-    }
-
-    /**
-     * Handle a "then" step.
-     *
-     * @param array  &$world    Joined "world" of variables.
-     * @param string $action    The description of the step.
-     * @param array  $arguments Additional arguments to the step.
-     *
-     * @return mixed The outcome of the step.
-     */
-    public function runThen(&$world, $action, $arguments)
-    {
-        switch($action) {
-        case 'the result should be an object of type':
-            if (!isset($world['result'])) {
-                $this->fail('Did not receive a result!');
-            }
-            $this->assertRecursiveType($world['result'], $arguments[0]);
-            break;
-        case 'the result indicates success.':
-            if (!isset($world['result'])) {
-                $this->fail('Did not receive a result!');
-            }
-            $this->assertNoError($world['result']);
-            break;
-        case 'the result should indicate an error with':
-            if (!isset($world['result'])) {
-                $this->fail('Did not receive a result!');
-            }
-            foreach ($world['result'] as $result) {
-                if ($result instanceOf Horde_Kolab_Server_Exception) {
-                    $this->assertEquals($arguments[0], $result->getMessage());
-                } else {
-                    $this->assertEquals($arguments[0], 'Action succeeded without an error.');
-                }
-            }
-            break;
-        case 'the list has a number of entries equal to':
-            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
-                $this->assertEquals('', $world['list']->getMessage());
-            } else {
-                $this->assertEquals($arguments[0], count($world['list']));
-            }
-            break;
-        case 'the list is an empty array':
-            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
-                $this->assertEquals('', $world['list']->getMessage());
-            } else {
-                $this->assertEquals(array(array()), $world['list']);
-            }
-            break;
-        case 'the list is an empty array':
-            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
-                $this->assertEquals('', $world['list']->getMessage());
-            } else {
-                $this->assertEquals(array(), $world['list']);
-            }
-            break;
-        case 'the provided list and the result list match with regard to these attributes':
-            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
-                $this->assertEquals('', $world['list']->getMessage());
-            } else {
-                $provided_vals = array();
-                foreach ($arguments[2] as $provided_element) {
-                    if (isset($provided_element[$arguments[0]])) {
-                        $provided_vals[] = $provided_element[$arguments[0]];
-                    } else {
-                        $this->fail(sprintf('The provided element %s does have no value for %s.',
-                                            print_r($provided_element, true),
-                                            print_r($arguments[0])));
-                    }
-                }
-                $result_vals = array();
-                foreach ($world['list'] as $result_set) {
-                    foreach ($result_set as $result_element) {
-                        if (isset($result_element[$arguments[1]])) {
-                            $result_vals[] = $result_element[$arguments[1]];
-                        } else {
-                            $this->fail(sprintf('The result element %s does have no value for %s.',
-                                                print_r($result_element, true),
-                                                print_r($arguments[1])));
-                        }
-                    }
-                    $this->assertEquals(array(),
-                                        array_diff($provided_vals, $result_vals));
-                }
-            }
-            break;
-        case 'each element in the result list has an attribute':
-            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
-                $this->assertEquals('', $world['list']->getMessage());
-            } else {
-                $result_vals = array();
-                foreach ($world['list'] as $result_set) {
-                    foreach ($result_set as $result_element) {
-                        if (!isset($result_element[$arguments[0]])) {
-                            $this->fail(sprintf('The result element %s does have no value for %s.',
-                                                print_r($result_element, true),
-                                                print_r($arguments[0], true)));
-                        }
-                    }
-                }
-            }
-            break;
-        case 'each element in the result list has an attribute set to a given value':
-            if ($world['list'] instanceOf Horde_Kolab_Server_Exception) {
-                $this->assertEquals('', $world['list']->getMessage());
-            } else {
-                $result_vals = array();
-                foreach ($world['list'] as $result_set) {
-                    foreach ($result_set as $result_element) {
-                        if (!isset($result_element[$arguments[0]])) {
-                            $this->fail(sprintf('The result element %s does have no value for %s.',
-                                                print_r($result_element, true),
-                                                print_r($arguments[0], true)));
-                        }
-                        if ($result_element[$arguments[0]] != $arguments[1]) {
-                            $this->fail(sprintf('The result element %s has an unexpected value %s for %s.',
-                                                print_r($result_element, true),
-                                                print_r($result_element[$arguments[0]], true),
-                                                print_r($arguments[0], true)));
-                        }
-                    }
-                }
-            }
-            break;
-        case 'the login was successful':
-            $this->assertNoError($world['login']);
-            $this->assertTrue($world['login']);
-            break;
-        case 'the list contains a number of elements equal to':
-            $this->assertEquals($arguments[0], count($world['list']));
-            break;
-        default:
-            return $this->notImplemented($action);
-        }
-    }
-
-    /**
-     * Identify the environments we want to run our tests in.
-     *
-     * @return array The selected environments.
-     */
-    public function getEnvironments()
-    {
-        if (empty($this->_environments)) {
-            /** The mock environment provides our basic test scenario */
-            $this->_environments = array(self::ENVIRONMENT_MOCK);
-            $testing = getenv('KOLAB_TEST');
-            if (!empty($testing)) {
-                $this->_environments[] = array(self::ENVIRONMENT_REAL);
-            }
-        }
-        return $this->_environments;
-    }
-
-    /**
-     * Specifically set the environments we wish to support.
-     *
-     * @param array $environments The selected environments.
-     *
-     * @return NULL
-     */
-    public function setEnvironments($environments)
-    {
-        $this->_environments = $environments;
-    }
-
-    /**
-     * Initialize the environments.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function initializeEnvironments()
-    {
-        foreach ($this->getEnvironments() as $environment) {
-            $this->initializeEnvironment($environment);
-        }
-    }
-
-    /**
-     * Prepare an injector for the given environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function prepareInjector($environment)
-    {
-        if (!isset($this->world['injector'][$environment])) {
-            $this->world['injector'][$environment] = new Horde_Injector(new Horde_Injector_TopLevel());
-        }
-    }
-
-    /**
-     * Prepare the log handler for the given environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function prepareLogger($environment)
-    {
-        $logger  = new Horde_Log_Logger();
-        $handler = new Horde_Log_Handler_Mock();
-        $logger->addHandler($handler);
-
-        $this->world['injector'][$environment]->setInstance('Horde_Log_Logger',
-                                                            $logger);
-    }
-
-    /**
-     * Prepare the server configuration for the given environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function prepareKolabServerConfiguration($environment)
-    {
-        switch ($environment) {
-        case self::ENVIRONMENT_MOCK:
-            /** Prepare a Kolab test server */
-            $config = new stdClass;
-            $config->driver = 'test';
-            $config->params = array(
-                'basedn'   => 'dc=example,dc=org',
-                'hashtype' => 'plain'
-            );
-            $this->world['injector'][$environment]->setInstance('Horde_Kolab_Server_Config', $config);
-            break;
-        default:
-            throw new Horde_Exception('Not implemented!');
-        }
-    }
-
-    /**
-     * Prepare the server for the given environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function prepareKolabServer($environment)
-    {
-        $this->world['injector'][$environment]->bindFactory('Horde_Kolab_Server_Structure',
-                                                            'Horde_Kolab_Server_Factory',
-                                                            'getStructure');
-        $this->world['injector'][$environment]->bindFactory('Horde_Kolab_Server',
-                                                            'Horde_Kolab_Server_Factory',
-                                                            'getServer');
-    }
-
-    /**
-     * Get a server from a specific environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return Horde_Kolab_Server The server.
-     */
-    public function getKolabServer($environment)
-    {
-        return $this->world['injector'][$environment]->getInstance('Horde_Kolab_Server');
-    }
-
-    /**
-     * Initialize the given environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function initializeEnvironment($environment)
-    {
-        $this->prepareInjector($environment);
-        $this->prepareLogger($environment);
-        $this->prepareKolabServerConfiguration($environment);
-        $this->prepareKolabServer($environment);
-    }
-
-    /**
-     * Shortcut to get a Kolab mock server.
-     *
-     * @return Horde_Kolab_Server The server.
-     */
-    public function getKolabMockServer()
-    {
-        $this->initializeEnvironment(self::ENVIRONMENT_MOCK);
-        return $this->getKolabServer(self::ENVIRONMENT_MOCK);
-    }
-
-    /**
-     * Retrieves the available servers. This assumes all environments have been
-     * initialied.
-     *
-     * @return array The list of test servers.
-     */
-    public function getKolabServers()
-    {
-        $servers = array();
-        foreach ($this->getEnvironments() as $environment) {
-            $servers[] = $this->getKolabServer($environment);
-        }
-        return $servers;
-    }
-
-    /**
-     * Add an object to a server and remember it for the tear down method.
-     *
-     * @param Horde_Kolab_Server $server The server to add the object to.
-     * @param array              $object  The object data to store.
-     *
-     * @return Horde_Kolab_Server_Object The resulting object.
-     */
-    public function addToServer(Horde_Kolab_Server $server, array $object)
-    {
-        $object = $server->add($object);
-        $this->added[] = array($server, $object->getUid());
-        return $object;
-    }
-
-    /**
-     * Add an object to the registered servers.
-     *
-     * @param array $object The object data to store.
-     *
-     * @return array An array of objects.
-     */
-    public function addToServers(array $object)
-    {
-        $result = array();
-        foreach ($this->world['injector'] as $injector) {
-            $server = $injector->getInstance('Horde_Kolab_Server');
-            $result[] = $this->addToServer($server, $object);
-        }
-        return $result;
-    }
-
-    /**
-     * Fill a Kolab Server with test users.
-     *
-     * @param Horde_Kolab_Server $server The server to fill.
-     *
-     * @return NULL
-     */
-    public function addBasicUsersToServer($server)
-    {
-        $result = $this->addToServer($server, $this->provideBasicUserOne());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicUserTwo());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicAddress());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicAdmin());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicDomainMaintainer());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideGroupWithoutMembers());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicGroupOne());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicMaintainer());
-        $this->assertNoError($result);
-        $result = $this->addToServer($server, $this->provideBasicSharedFolder());
-        $this->assertNoError($result);
-    }
-
-    /**
-     * List objects on the registered servers.
-     *
-     * @param array $type The type of objects to list.
-     *
-     * @return array An array of objects.
-     */
-    public function listObjectsOnServer($type)
-    {
-        $result = array();
-        foreach ($this->world['injector'] as $injector) {
-            $server = $injector->getInstance('Horde_Kolab_Server');
-            $objects = $server->listObjects($type);
-            $result[] = $objects;
-        }
-        return $result;
-    }
-
-    /**
-     * Return a test user.
-     *
-     * @return array The test user.
-     */
-    public function provideBasicUserOne()
-    {
-        return array('givenName' => 'Gunnar',
-                      'sn' => 'Wrobel',
-                      'type' => 'Horde_Kolab_Server_Object_Kolab_User',
-                      'mail' => 'wrobel@example.org',
-                      'uid' => 'wrobel',
-                      'userPassword' => 'none',
-                      'kolabHomeServer' => 'home.example.org',
-                      'kolabImapServer' => 'imap.example.org',
-                      'kolabFreeBusyServer' => 'https://fb.example.org/freebusy',
-                      'kolabInvitationPolicy' => array('ACT_REJECT_IF_CONFLICTS'),
-                      'alias' => array('gunnar@example.org',
-                                       'g.wrobel@example.org'),
-                );
-    }
-
-    /**
-     * Return a test user.
-     *
-     * @return array The test user.
-     */
-    public function provideBasicUserTwo()
-    {
-        return array('givenName' => 'Test',
-                     'sn' => 'Test',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
-                     'mail' => 'test@example.org',
-                     'uid' => 'test',
-                     'userPassword' => 'test',
-                     'kolabHomeServer' => 'home.example.org',
-                     'kolabImapServer' => 'home.example.org',
-                     'kolabFreeBusyServer' => 'https://fb.example.org/freebusy',
-                     'alias' => array('t.test@example.org'),
-                     'kolabDelegate' => 'wrobel@example.org',);
-    }
-
-    /**
-     * Return a test address.
-     *
-     * @return array The test address.
-     */
-    public function provideBasicAddress()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Address',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_GIVENNAME    => 'Test',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SN           => 'Address',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_MAIL         => 'address@example.org',
-        );
-    }
-
-    /**
-     * Return a test administrator.
-     *
-     * @return array The test administrator.
-     */
-    public function provideBasicAdmin()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Administrator',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_GIVENNAME    => 'The',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SN           => 'Administrator',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SID          => 'admin',
-                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_USERPASSWORD => 'none',
-        );
-    }
-
-    /**
-     * Return a test maintainer.
-     *
-     * @return array The test maintainer.
-     */
-    public function provideBasicMaintainer()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Maintainer',
-                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_GIVENNAME    => 'Main',
-                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_SN           => 'Tainer',
-                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_SID          => 'maintainer',
-                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_USERPASSWORD => 'none',
-        );
-    }
-
-    /**
-     * Return a test domain maintainer.
-     *
-     * @return array The test domain maintainer.
-     */
-    public function provideBasicDomainMaintainer()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Domainmaintainer',
-                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_GIVENNAME    => 'Domain',
-                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_SN           => 'Maintainer',
-                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_SID          => 'domainmaintainer',
-                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_USERPASSWORD => 'none',
-                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_DOMAIN       => array('example.com'),
-
-        );
-    }
-
-    /**
-     * Return a test shared folder.
-     *
-     * @return array The test shared folder.
-     */
-    public function provideBasicSharedFolder()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolabsharedfolder',
-                     Horde_Kolab_Server_Object_Kolabsharedfolder::ATTRIBUTE_CN         => 'shared@example.org',
-                     Horde_Kolab_Server_Object_Kolabsharedfolder::ATTRIBUTE_HOMESERVER => 'example.org',
-        );
-    }
-
-    /**
-     * Provide a set of valid groups.
-     *
-     * @return array The array of groups.
-     */
-    public function groupLists()
-    {
-        $groups = $this->validGroups();
-        $result = array();
-        foreach ($groups as $group) {
-            $result[] = array($group);
-        }
-        return $result;
-    }
-
-    /**
-     * Provide a set of valid groups.
-     *
-     * @return array The array of groups.
-     */
-    public function validGroups()
-    {
-        return array(
-            array(
-                $this->provideGroupWithoutMembers(),
-            ),
-            array(
-                $this->provideBasicGroupOne(),
-            ),
-            array(
-                $this->provideBasicGroupTwo(),
-            ),
-        );
-    }
-
-    /**
-     * Return a test group.
-     *
-     * @return array The test group.
-     */
-    public function provideGroupWithoutMembers()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'empty.group@example.org',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array());
-    }
-
-    /**
-     * Return a test group.
-     *
-     * @return array The test group.
-     */
-    public function provideBasicGroupOne()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'group@example.org',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Test Test,dc=example,dc=org',
-                                                                                         'cn=Gunnar Wrobel,dc=example,dc=org')
-        );
-    }
-
-    /**
-     * Return a test group.
-     *
-     * @return array The test group.
-     */
-    public function provideBasicGroupTwo()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'group2@example.org',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Gunnar Wrobel,dc=example,dc=org')
-        );
-    }
-
-    public function provideDistributionList()
-    {
-        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Distlist',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'distlist@example.org',
-                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Test Test,dc=example,dc=org',
-                                                                                         'cn=Gunnar Wrobel,dc=example,dc=org')
-        );
-    }
-
-    public function provideInvalidUserWithoutPassword()
-    {
-        return array('givenName' => 'Test',
-                     'sn' => 'Test',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
-                     'mail' => 'test@example.org');
-    }
-
-    public function provideInvalidUserWithoutGivenName()
-    {
-        return array('sn' => 'Test',
-                     'userPassword' => 'none',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
-                     'mail' => 'test@example.org');
-    }
-
-    public function provideInvalidUserWithoutLastName()
-    {
-        return array('givenName' => 'Test',
-                     'userPassword' => 'none',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_User',
-                     'mail' => 'test@example.org');
-    }
-
-    public function provideInvalidUserWithoutMail()
-    {
-        return array('givenName' => 'Test',
-                     'sn' => 'Test',
-                     'userPassword' => 'none',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_User');
-    }
-
-    public function provideInvalidUsers()
-    {
-        return array(
-            array(
-                $this->provideInvalidUserWithoutPassword(),
-                'The value for "userPassword" is missing!'
-            ),
-            array(
-                $this->provideInvalidUserWithoutGivenName(),
-                'Either the last name or the given name is missing!'
-            ),
-            array(
-                $this->provideInvalidUserWithoutLastName(),
-                'Either the last name or the given name is missing!'
-            ),
-            array(
-                $this->provideInvalidUserWithoutMail(),
-                'The value for "mail" is missing!'
-            ),
-        );
-    }
-
-    /** FIXME: Prefix the stuff below with provide...() */
-
-    public function validUsers()
-    {
-        return array(
-            array(
-                $this->provideBasicUserOne(),
-            ),
-            array(
-                $this->provideBasicUserTwo(),
-            ),
-        );
-    }
-
-    public function validAddresses()
-    {
-        return array(
-            array(
-                $this->provideBasicAddress(),
-            ),
-        );
-    }
-
-    public function validAdmins()
-    {
-        return array(
-            array(
-                $this->provideBasicAdmin(),
-            ),
-        );
-    }
-
-    public function validMaintainers()
-    {
-        return array(
-            array(
-                $this->provideBasicMaintainer(),
-            )
-        );
-    }
-
-    public function validDomainMaintainers()
-    {
-        return array(
-            array(
-                $this->provideBasicDomainMaintainer(),
-            )
-        );
-    }
-
-    public function validSharedFolders()
-    {
-        return array(
-            array('cn' => 'Shared',
-                  'type' => 'Horde_Kolab_Server_Object_Kolabsharedfolder'
-            ),
-        );
-    }
-
-
-    public function userLists()
-    {
-        return array(
-        );
-    }
-
-    public function userListByLetter()
-    {
-        return array(
-        );
-    }
-
-    public function userListByAttribute()
-    {
-        return array(
-        );
-    }
-
-    public function userAdd()
-    {
-        return array(
-        );
-    }
-
-    public function invalidMails()
-    {
-        return array(
-        );
-    }
-
-    public function largeList()
-    {
-        return array(
-        );
-    }
-
-    protected function fetchByCn($server, $cn)
-    {
-        $cn_result = $server->uidForCn($cn);
-        $this->assertNoError($cn_result);
-
-        $object = $server->fetch($cn_result);
-        $this->assertNoError($object);
-
-        return $object;
-    }
-
-    /**
-     * Ensure that the variable contains no Horde_Kolab_Server_Exception and
-     * fail if it does.
-     *
-     * @param mixed $var The variable to check.
-     *
-     * @return NULL.
-     */
-    public function assertNoError($var)
-    {
-        if (is_array($var)) {
-            foreach ($var as $element) {
-                $this->assertNoError($element);
-            }
-        } elseif ($var instanceOf Exception) {
-            $this->assertEquals('', $var->getMessage());
-        } else if ($var instanceOf PEAR_Error) {
-            $this->assertEquals('', $var->getMessage());
-        }
-    }
-
-    /**
-     * Ensure that the variable contains a Horde_Kolab_Server_Exception and fail
-     * if it does not. Optionally compare the error message with the provided
-     * message and fail if both do not match.
-     *
-     * @param mixed  $var The variable to check.
-     * @param string $msg The expected error message.
-     *
-     * @return NULL.
-     */
-    public function assertError($var, $msg = null)
-    {
-        if (!$var instanceOf PEAR_Error) {
-            $this->assertType('Horde_Kolab_Server_Exception', $var);
-            if (isset($msg)) {
-                $this->assertEquals($msg, $var->getMessage());
-            }
-        } else {
-            if (isset($msg)) {
-                $this->assertEquals($msg, $var->getMessage());
-            }
-        }
-    }
-
-    /**
-     * Assert that creating a new object operation yields some predictable
-     * attribute results.
-     *
-     * @param Horde_Kolab_Server         $server The server the object resides on.
-     * @param array                      $store  The information to save.
-     * @param array                      $fetch  The expected results.
-     *
-     * @return NULL.
-     */
-    protected function assertAdd(Horde_Kolab_Server $server,
-                                 array $store, array $fetch)
-    {
-        $object = $server->add($store);
-        $this->assertNoError($object);
-
-        $this->added[] = array($server, $object->getUid());
-        $object = $server->fetch($object->getUid());
-
-        foreach ($fetch as $attribute => $expect) {
-            $this->assertEquals($expect, $object->get($attribute));
-        }
-        return $object;
-    }
-
-    /**
-     * Test simple attributes.
-     *
-     * @dataProvider provideServers
-     *
-     * @return NULL
-     */
-    public function assertSimpleAttributes(Horde_Kolab_Server_Object $object,
-                                           Horde_Kolab_Server $server, array $list)
-    {
-        foreach ($list as $item) {
-            $this->assertSimpleSequence($object, $server,
-                                        $item,
-                                        array($item, 'öäü/)(="§%$&§§$\'*', '', array('a', 'b'), '0'),
-                                        true);
-        }
-    }
-
-    /**
-     * Test easy attributes.
-     *
-     * @dataProvider provideServers
-     *
-     * @return NULL
-     */
-    public function assertEasyAttributes(Horde_Kolab_Server_Object $object,
-                                         Horde_Kolab_Server $server, array $list)
-    {
-        foreach ($list as $key => $items) {
-            $this->assertSimpleSequence($object, $server,
-                                        $key,
-                                        $items,
-                                        true);
-        }
-    }
-
-    /**
-     * Assert that a save() operation yields some predictable attribute results.
-     *
-     * @param Horde_Kolab_Server_Object $object    The object to work on.
-     * @param Horde_Kolab_Server        $server    The server the object resides on.
-     * @param string                    $attribute The attribute to work on.
-     * @param array                     $sequence  The sequence of values to set and expect.
-     *
-     * @return NULL.
-     */
-    protected function assertSimpleSequence(Horde_Kolab_Server_Object $object,
-                                            Horde_Kolab_Server $server,
-                                            $attribute, array $sequence,
-                                            $pop_arrays = false)
-    {
-        foreach ($sequence as $value) {
-            $this->assertStoreFetch($object, $server,
-                                    array($attribute => $value),
-                                    array($attribute => $value),
-                                    $pop_arrays);
-        }
-    }
-
-    /**
-     * Assert that a save() operation yields some predictable attribute results.
-     *
-     * @param Horde_Kolab_Server_Object  $object The object to work on.
-     * @param Horde_Kolab_Server         $server The server the object resides on.
-     * @param array                      $store  The information to save.
-     * @param array                      $fetch  The expected results.
-     *
-     * @return NULL.
-     */
-    protected function assertStoreFetch(Horde_Kolab_Server_Object $object,
-                                        Horde_Kolab_Server $server,
-                                        array $store, array $fetch,
-                                        $pop_arrays = false)
-    {
-        $result = $object->save($store);
-        $this->assertNoError($result);
-
-        $object = $server->fetch($object->getUid());
-
-        foreach ($fetch as $attribute => $expect) {
-            $actual = $object->get($attribute, false);
-            if ($pop_arrays && is_array($actual) && count($actual) == 1) {
-                $actual = array_pop($actual);
-            }
-            $this->assertEquals($expect,
-                                $actual);
-        }
-    }
-
-    public function assertRecursiveType($results, $type)
-    {
-        if (is_array($results)) {
-            foreach ($results as $result) {
-                $this->assertRecursiveType($result, $type);
-            }
-        } else {
-            if ($results instanceOf Exception) {
-                $this->assertEquals('', $results->getMessage());
-            } else {
-                $this->assertType($type, $results);
-            }
-        }
-    }
-
-    /**
-     * Setup function.
-     *
-     * @return NULL.
-     */
-    protected function setUp()
-    {
-        $this->added = array();
-        $this->markTestIncomplete('Needs to be fixed');
-    }
-
-    /**
-     * Cleanup function.
-     *
-     * @return NULL.
-     */
-    protected function tearDown()
-    {
-        if (isset($this->added)) {
-            $added = array_reverse($this->added);
-            foreach ($added as $add) {
-                $result = $add[0]->delete($add[1]);
-                $this->assertNoError($result);
-            }
-        }
-    }
-}
index b9b0433..99faf2c 100644 (file)
@@ -30,96 +30,198 @@ require_once dirname(__FILE__) . '/../Autoload.php';
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Kolab_Server
  */
-class Horde_Kolab_Server_Server_FactoryTest extends Horde_Kolab_Server_Scenario
+class Horde_Kolab_Server_Server_FactoryTest extends PHPUnit_Framework_TestCase
 {
     public function setUp()
     {
-        $this->markTestIncomplete('Needs to be fixed');
+        $this->injector = new Horde_Injector(new Horde_Injector_TopLevel());
     }
 
     public function testMethodSetupHasPostconditionThatAObjectHandlerOfTypeBaseIsBoundToObjects()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        Horde_Kolab_Server_Factory::setup(array(), $injector);
+        Horde_Kolab_Server_Factory::setup($this->injector, array());
         $this->assertType(
             'Horde_Kolab_Server_Objects_Base',
-            $injector->getInstance('Horde_Kolab_Server_Objects')
+            $this->injector->getInstance('Horde_Kolab_Server_Objects')
         );
     }
 
     public function testMethodSetupHasPostconditionThatASchemaHandlerOfTypeBaseIsBoundToSchema()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        Horde_Kolab_Server_Factory::setup(array(), $injector);
+        Horde_Kolab_Server_Factory::setup($this->injector, array());
         $this->assertType(
             'Horde_Kolab_Server_Schema_Base',
-            $injector->getInstance('Horde_Kolab_Server_Schema')
+            $this->injector->getInstance('Horde_Kolab_Server_Schema')
         );
     }
 
     public function testMethodSetupHasPostconditionThatASearchHandlerOfTypeBaseIsBoundToSearch()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        Horde_Kolab_Server_Factory::setup(array(), $injector);
+        Horde_Kolab_Server_Factory::setup($this->injector, array());
         $this->assertType(
             'Horde_Kolab_Server_Search_Base',
-            $injector->getInstance('Horde_Kolab_Server_Search')
+            $this->injector->getInstance('Horde_Kolab_Server_Search')
         );
     }
 
-    public function testMethodSetupHasPostconditionThatAStructureOfTypeBaseIsBoundToStructure()
+    public function testMethodSetupHasPostconditionThatAStructureOfTypeKolabIsBoundToStructure()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        Horde_Kolab_Server_Factory::setup(array(), $injector);
+        Horde_Kolab_Server_Factory::setup($this->injector, array());
         $this->assertType(
             'Horde_Kolab_Server_Structure_Kolab',
-            $injector->getInstance('Horde_Kolab_Server_Structure')
+            $this->injector->getInstance('Horde_Kolab_Server_Structure')
         );
     }
 
     public function testMethodSetupHasPostconditionThatAStructureHandlerOfTypeLdapIsBoundToStructureIfConfiguredThatWay()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
         Horde_Kolab_Server_Factory::setup(
-            array('structure' => array('driver' => 'ldap')),
-            $injector
+            $this->injector,
+            array('structure' => array('driver' => 'ldap'))
         );
         $this->assertType(
             'Horde_Kolab_Server_Structure_Ldap',
-            $injector->getInstance('Horde_Kolab_Server_Structure')
+            $this->injector->getInstance('Horde_Kolab_Server_Structure')
         );
     }
 
     public function testMethodSetupHasPostconditionThatAServerOfTypeLdapIsBoundToServer()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        Horde_Kolab_Server_Factory::setup(array(), $injector);
+        Horde_Kolab_Server_Factory::setup($this->injector, array('basedn' => 'dc=example,dc=com'));
         $this->assertType(
-            'Horde_Kolab_Server_Ldap',
-            $injector->getInstance('Horde_Kolab_Server')
+            'Horde_Kolab_Server_Ldap_Standard',
+            $this->injector->getInstance('Horde_Kolab_Server')
         );
     }
 
-    public function testMethodSetupHasPostconditionThatAServerOfTypeLdapIsBoundToServerIfConfiguredThatWay()
+    public function testMethodSetupHasPostconditionThatAServerOfTypeFileIsBoundToServerIfConfiguredThatWay()
     {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
         Horde_Kolab_Server_Factory::setup(
-            array('driver' => 'file', 'params' => array('file' => '/tmp/nix')),
-            $injector
+            $this->injector,
+            array('driver' => 'file', 'params' => array('basedn' => '', 'file' => '/tmp/nix'))
         );
         $this->assertType(
-            'Horde_Kolab_Server_File',
-            $injector->getInstance('Horde_Kolab_Server')
+            'Horde_Kolab_Server_Ldap_Standard',
+            $this->injector->getInstance('Horde_Kolab_Server')
         );
     }
 
+    public function testMethodSetupHasPostconditionThatAServerOfTypeFilteredLdapIsBoundToServerIfAFilterHasBeenProvided()
+    {
+        Horde_Kolab_Server_Factory::setup(
+            $this->injector,
+            array('basedn' => 'dc=example,dc=com', 'filter' => 'test')
+        );
+        $this->assertType(
+            'Horde_Kolab_Server_Ldap_Filtered',
+            $this->injector->getInstance('Horde_Kolab_Server')
+        );
+    }
+
+    public function testMethodSetupHasPostconditionThatAMappedServerIsBoundToServerIfAMapHasBeenProvided()
+    {
+        Horde_Kolab_Server_Factory::setup(
+            $this->injector,
+            array(
+                'basedn' => 'dc=example,dc=com',
+                'map' => array('a' => 'b'),
+            )
+        );
+        $this->assertType(
+            'Horde_Kolab_Server_Mapped',
+            $this->injector->getInstance('Horde_Kolab_Server')
+        );
+    }
+
+    public function testMethodSetupHasPostconditionThatALoggedServerIsBoundToServerIfALoggerHasBeenProvided()
+    {
+        Horde_Kolab_Server_Factory::setup(
+            $this->injector,
+            array(
+                'basedn' => 'dc=example,dc=com',
+                'logger' => $this->getMock('Horde_Log_Logger'),
+            )
+        );
+        $this->assertType(
+            'Horde_Kolab_Server_Logged',
+            $this->injector->getInstance('Horde_Kolab_Server')
+        );
+    }
+
+    public function testMethodGetserverHasPostconditionThatTheConnectionParametersGetRewrittenIfNecessary()
+    {
+        Horde_Kolab_Server_Factory::setup(
+            $this->injector,
+            array(
+                'server' => 'localhost',
+                'phpdn' => 'a',
+                'phppw' => 'a',
+                'basedn' => 'dc=example,dc=com'
+            )
+        );
+        $this->injector->getInstance('Horde_Kolab_Server');
+        /**@todo: Actually not testable as we can't read the configuration again */
+    }
+
+    public function testMethodGetserverHasPostconditionThatTheConnectionIsSplittedIfRequired()
+    {
+        Horde_Kolab_Server_Factory::setup(
+            $this->injector,
+            array(
+                'host' => 'localhost',
+                'host_master' => 'writehost',
+                'basedn' => 'dc=example,dc=com'
+            )
+        );
+        $this->injector->getInstance('Horde_Kolab_Server');
+        /**@todo: Actually not testable as we can't read the configuration again */
+    }
+
+    public function testMethodGetserverThrowsExceptionIfTheBasednIsMissing()
+    {
+        try {
+            Horde_Kolab_Server_Factory::setup(
+                $this->injector,
+                array('dummy')
+            );
+            $this->injector->getInstance('Horde_Kolab_Server');
+            $this->fail('No exception!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals(
+                'The base DN is missing', $e->getMessage()
+            );
+        }
+    }
+
+    public function testMethodGetserverThrowsExceptionIfTheDriverIsUnknown()
+    {
+        try {
+            Horde_Kolab_Server_Factory::setup(
+                $this->injector,
+                array('driver' => 'unknown')
+            );
+            $this->injector->getInstance('Horde_Kolab_Server');
+            $this->fail('No exception!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals(
+                'Invalid server configuration!', $e->getMessage()
+            );
+        }
+    }
+
     public function testMethodSingletonReturnsTheSameInstanceWithTheSameParameters()
     {
-        Horde_Kolab_Server_Factory::singleton();
+        $result1 = Horde_Kolab_Server_Factory::singleton(array('basedn' => 'dc=example,dc=com'));
+        $result2 = Horde_Kolab_Server_Factory::singleton(array('basedn' => 'dc=example,dc=com'));
+        $this->assertSame($result1, $result2);
     }
 
     public function testMethodSingletonReturnsDifferentInstancesWithDifferentParameters()
     {
-        Horde_Kolab_Server_Factory::singleton();
+        global $conf;
+        $conf['kolab']['ldap']['basedn'] = 'test';
+        $result1 = Horde_Kolab_Server_Factory::singleton(array('basedn' => 'dc=example,dc=com'));
+        $result2 = Horde_Kolab_Server_Factory::singleton();
+        $this->assertTrue($result1 !== $result2);
     }
 }
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Server/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Server/MockTest.php
deleted file mode 100644 (file)
index 78bb162..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-<?php
-/**
- * Test the test driver.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the test backend.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Server_MockTest extends Horde_Kolab_Server_Scenario
-{
-
-    /** The file based mock environment */
-    const ENVIRONMENT_FILE = 'file';
-
-    /**
-     * The environments we provide to the test.
-     *
-     * @var array
-     */
-    protected $_environments = array(
-        self::ENVIRONMENT_MOCK,
-        self::ENVIRONMENT_FILE
-    );
-
-    /**
-     * Prepare the server configuration for the given environment.
-     *
-     * @param string $environment The name of the environment.
-     *
-     * @return NULL
-     */
-    public function prepareKolabServerConfiguration($environment)
-    {
-        switch ($environment) {
-        case self::ENVIRONMENT_FILE:
-            /** Prepare a Kolab test server */
-            $config = new stdClass;
-            $config->driver = 'file';
-            $config->params = array(
-                'file'     => Horde::getTempFile('fileTest'),
-                'basedn'   => 'dc=example,dc=org',
-                'hashtype' => 'plain'
-            );
-            $this->world['injector'][$environment]->setInstance('Horde_Kolab_Server_Config', $config);
-            break;
-        default:
-            return parent::prepareKolabServerConfiguration($environment);
-        }
-    }
-
-    /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-
-        $this->markTestIncomplete('Needs to be fixed');
-
-        $this->initializeEnvironments();
-        $this->servers = $this->getKolabServers();
-        foreach ($this->servers as $server) {
-            $this->addBasicUsersToServer($server);
-        }
-    }
-
-    /**
-     * Test search base.
-     *
-     * @return NULL
-     */
-    public function testSearchBase()
-    {
-        foreach ($this->servers as $server) {
-            $result = $server->search(
-                '(' . Horde_Kolab_Server_Object::ATTRIBUTE_OC
-                . '=' . Horde_Kolab_Server_Object::OBJECTCLASS_TOP . ')',
-                array(Horde_Kolab_Server_Object::ATTRIBUTE_OC));
-            $this->assertEquals(13, count($result));
-      
-            $result = $server->search(
-                '(' . Horde_Kolab_Server_Object::ATTRIBUTE_OC
-                . '=' . Horde_Kolab_Server_Object::OBJECTCLASS_TOP . ')',
-                array(Horde_Kolab_Server_Object::ATTRIBUTE_OC),
-                'cn=internal,dc=example,dc=org');
-            $this->assertEquals(4, count($result));
-        }
-    }
-
-    /**
-     * Test sorting.
-     *
-     * @return NULL
-     */
-    public function testSorting()
-    {
-        foreach ($this->servers as $server) {
-
-/*         $result = $server->search('(mail=*)', array('mail')); */
-/*         $this->assertEquals(5, count($result)); */
-/*         $server->sort($result, 'mail'); */
-/*         foreach ($result as $object) { */
-/*             if (isset($object['data']['dn'])) { */
-/*                 switch ($object['data']['dn']) { */
-/*                 case 'cn=Test Address,cn=external,dc=example,dc=org': */
-/*                     $this->assertContains('address@example.org', $object['data']['mail']); */
-/*                     break; */
-/*                 case '': */
-/*                     $this->assertContains('address@example.org', $object['data']['mail']); */
-/*                     break; */
-/*                 } */
-/*             } */
-/*         } */
-        }
-    }
-
-    /**
-     * Test listing objects.
-     *
-     * @return NULL
-     */
-    public function testListObjects()
-    {
-        foreach ($this->servers as $server) {
-            $filter     = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
-            $attributes = array(
-                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SN,
-                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_CN,
-                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_UID,
-                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_MAIL,
-                Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DELETED,
-            );
-
-            $sort   = Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SN;
-            $result = $server->search($filter);
-            $this->assertEquals(2, count($result));
-
-            $result = $server->listObjects('Horde_Kolab_Server_Object_Kolab_User');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class(array_shift($result)));
-
-            $result = $server->listObjects('Horde_Kolab_Server_Object_Kolabsharedfolder');
-            $this->assertEquals(1, count($result));
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolabsharedfolder', get_class(array_shift($result)));
-        }
-    }
-
-    /**
-     * Test handling of object classes.
-     *
-     * @return NULL
-     */
-    public function testGetObjectClasses()
-    {
-        foreach ($this->servers as $server) {
-            $classes = $server->getObjectClasses('cn=Gunnar Wrobel,dc=example,dc=org');
-            $this->assertContains('top', $classes);
-            $this->assertContains('kolabinetorgperson', $classes);
-
-            try {
-                $classes = $server->getObjectClasses('cn=DOES NOT EXIST,dc=example,dc=org');
-            } catch (Horde_Kolab_Server_Exception $classes) {
-            }
-            $this->assertError($classes,
-                               'No such object: cn=DOES NOT EXIST,dc=example,dc=org');
-
-            $classes = $server->getObjectClasses('cn=The Administrator,dc=example,dc=org');
-            $this->assertContains('kolabinetorgperson', $classes);
-        }
-    }
-
-    /**
-     * Test handling of object types.
-     *
-     * @return NULL
-     */
-    public function testDetermineType()
-    {
-        foreach ($this->servers as $server) {
-            $type = $server->determineType('cn=empty.group@example.org,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolabgroupofnames', $type);
-
-            $type = $server->determineType('cn=shared@example.org,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolabsharedfolder', $type);
-
-            $type = $server->determineType('cn=The Administrator,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Administrator', $type);
-
-            $type = $server->determineType('cn=Main Tainer,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Maintainer', $type);
-
-            $type = $server->determineType('cn=Domain Maintainer,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Domainmaintainer', $type);
-
-            $type = $server->determineType('cn=Test Address,cn=external,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_Address', $type);
-
-            $type = $server->determineType('cn=Gunnar Wrobel,dc=example,dc=org');
-            $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', $type);
-        }
-    }
-
-    /**
-     * Test retrieving a primary mail for a mail or id.
-     *
-     * @return NULL
-     */
-    public function testMailForIdOrMail()
-    {
-        foreach ($this->servers as $server) {
-            $mail = $server->mailForIdOrMail('wrobel');
-            $this->assertEquals('wrobel@example.org', $mail);
-
-            $mail = $server->mailForIdOrMail('wrobel@example.org');
-            $this->assertEquals('wrobel@example.org', $mail);
-
-            $mail = $server->mailForIdOrMail('DOES NOT EXIST');
-            $this->assertSame(false, $mail);
-        }
-    }
-
-    /**
-     * Test retrieving a UID for a mail or id.
-     *
-     * @return NULL
-     */
-    public function testUidForIdOrMail()
-    {
-        foreach ($this->servers as $server) {
-            $uid = $server->uidForIdOrMail('wrobel');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMail('wrobel@example.org');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMail('DOES NOT EXIST');
-            $this->assertSame(false, $uid);
-        }
-    }
-
-    /**
-     * Test retrieving a UID for a mail or id.
-     *
-     * @return NULL
-     */
-    public function testUidForMailOrIdOrAlias()
-    {
-        foreach ($this->servers as $server) {
-            $uid = $server->uidForIdOrMailOrAlias('g.wrobel@example.org');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMailOrAlias('wrobel@example.org');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMailOrAlias('wrobel');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMailOrAlias('DOES NOT EXIST');
-            $this->assertSame(false, $uid);
-        }
-    }
-
-    /**
-     * Test retrieving all addresses for a mail or id.
-     *
-     * @return NULL
-     */
-    public function testAddrsForIdOrMail()
-    {
-        foreach ($this->servers as $server) {
-            $addrs = $server->addrsForIdOrMail('wrobel');
-
-            $testuser = $server->fetch('cn=Test Test,dc=example,dc=org');
-            $this->assertContains('wrobel@example.org',
-                                  $testuser->get(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DELEGATE, false));
-
-            $this->assertContains('wrobel@example.org', $addrs);
-            $this->assertContains('test@example.org', $addrs);
-            $this->assertContains('t.test@example.org', $addrs);
-            $this->assertContains('g.wrobel@example.org', $addrs);
-            $this->assertContains('gunnar@example.org', $addrs);
-
-            $addrs = $server->addrsForIdOrMail('test@example.org');
-            $this->assertContains('test@example.org', $addrs);
-            $this->assertContains('t.test@example.org', $addrs);
-        }
-    }
-
-    /**
-     * Test retrieving a UID for a primary mail.
-     *
-     * @return NULL
-     */
-    public function testUidForMailAddress()
-    {
-        foreach ($this->servers as $server) {
-            $uid = $server->uidForIdOrMailOrAlias('wrobel@example.org');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMailOrAlias('test@example.org');
-            $this->assertEquals('cn=Test Test,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMailOrAlias('gunnar@example.org');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-
-            $uid = $server->uidForIdOrMailOrAlias('wrobel');
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-        }
-    }
-
-    /**
-     * Test retrieving a UID for an attribute.
-     *
-     * @return NULL
-     */
-    public function testUidForAttr()
-    {
-        foreach ($this->servers as $server) {
-            $uid = $server->uidForSearch(array('AND' => array(array('field' => 'alias',
-                                                                    'op' => '=',
-                                                                    'test' => 'g.wrobel@example.org'))));
-            $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
-        }
-    }
-
-    /**
-     * Test group membership testing.
-     *
-     * @return NULL
-     */
-    public function testMemberOfGroupAddress()
-    {
-        foreach ($this->servers as $server) {
-            $uid = $server->uidForIdOrMailOrAlias('g.wrobel@example.org');
-            $member = $server->memberOfGroupAddress($uid, 'group@example.org');
-            $this->assertTrue($member);
-
-            $member = $server->memberOfGroupAddress(
-                $server->uidForIdOrMailOrAlias('test@example.org'),
-                'group@example.org');
-            $this->assertTrue($member);
-
-            $member = $server->memberOfGroupAddress(
-                $server->uidForIdOrMailOrAlias('somebody@example.org'),
-                'group@example.org');
-            $this->assertFalse($member);
-        }
-    }
-
-    /**
-     * Test group fetching.
-     *
-     * @return NULL
-     */
-    public function testGetGroups()
-    {
-        foreach ($this->servers as $server) {
-            $filter = '(&(objectClass=kolabGroupOfNames)(member='
-                . Net_LDAP2_Util::escape_filter_value('cn=The Administrator,dc=example,dc=org') . '))';
-            $result = $server->search($filter, array());
-            $this->assertTrue(!empty($result));
-
-            /*         $entry = $server->_firstEntry($result); */
-            /*         $this->assertTrue(!empty($entry)); */
-
-            /*         $uid = $server->_getDn($entry); */
-            /*         $this->assertTrue(!empty($uid)); */
-
-            /*         $entry = $server->_nextEntry($entry); */
-            /*         $this->assertTrue(empty($entry)); */
-
-            /*         $entries = $server->_getDns($result); */
-            /*         $this->assertTrue(!empty($entries)); */
-
-            $groups = $server->getGroups('cn=The Administrator,dc=example,dc=org');
-            $this->assertTrue(!empty($groups));
-
-            $groups = $server->getGroups($server->uidForIdOrMailOrAlias('g.wrobel@example.org'));
-            $this->assertContains('cn=group@example.org,dc=example,dc=org', $groups);
-
-            $groups = $server->getGroupAddresses($server->uidForIdOrMailOrAlias('g.wrobel@example.org'));
-            $this->assertContains('group@example.org', $groups);
-
-            $groups = $server->getGroups($server->uidForIdOrMailOrAlias('test@example.org'));
-            $this->assertContains('cn=group@example.org,dc=example,dc=org', $groups);
-
-            $groups = $server->getGroupAddresses($server->uidForIdOrMailOrAlias('test@example.org'));
-            $this->assertContains('group@example.org', $groups);
-
-            $groups = $server->getGroups('nobody');
-            $this->assertTrue(empty($groups));
-        }
-    }
-
-    /**
-     * Test parsing of LDAP filters.
-     *
-     * @return NULL
-     */
-    public function testFilterParse()
-    {
-        $db = $this->getKolabMockServer();
-
-        $a = $db->parse('(a=b)');
-        $this->assertEquals(array('att' => 'a', 'log' => '=', 'val' => 'b'),
-                            $a);
-
-        $a = $db->parse('(&(a=b)(c=d))');
-        $this->assertEquals(array('op' => '&', 'sub' => array(
-                                      array('att' => 'a', 'log' => '=', 'val' => 'b'),
-                                      array('att' => 'c', 'log' => '=', 'val' => 'd'),
-                                  )), $a);
-
-        $a = $db->parse('(&(a=1)(|(b=2)(c=3)))');
-        $this->assertEquals(array('op' => '&', 'sub' => array(
-                                      array('att' => 'a', 'log' => '=', 'val' => '1'),
-                                      array('op' => '|', 'sub' =>
-                                            array(
-                                                array('att' => 'b', 'log' => '=', 'val' => '2'),
-                                                array('att' => 'c', 'log' => '=', 'val' => '3'),
-                                            )))), $a);
-
-        $a = $db->parseSub('(!(x=2))(b=1)');
-        $this->assertEquals(array(array('op' => '!', 'sub' =>
-                                        array(
-                                            array('att' => 'x', 'log' => '=', 'val' => '2'),
-                                        )
-                                  ),
-                                  array('att' => 'b', 'log' => '=', 'val' => '1'),
-                            ), $a);
-
-        $a = $db->parse('(&(!(x=2))(b=1))');
-        $this->assertEquals(array('op' => '&', 'sub' => array(
-                                      array('op' => '!', 'sub' =>
-                                            array(
-                                                array('att' => 'x', 'log' => '=', 'val' => '2'),
-                                            )
-                                      ),
-                                      array('att' => 'b', 'log' => '=', 'val' => '1'),
-                                  )), $a);
-
-    }
-
-    /**
-     * Test searching in the simulated LDAP data.
-     *
-     * @return NULL
-     */
-    public function testSearch()
-    {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        $config = new stdClass;
-        $config->driver = 'test';
-        $config->params = array(
-            'data' =>
-            array(
-                'cn=a' => array(
-                    'dn' => 'cn=a',
-                    'data' => array(
-                        'a' => '1',
-                        'b' => '1',
-                        'c' => '1',
-                    )
-                ),
-                'cn=b' => array(
-                    'dn' => 'cn=b',
-                    'data' => array(
-                        'a' => '1',
-                        'b' => '2',
-                        'c' => '2',
-                    )
-                ),
-                'cn=c' => array(
-                    'dn' => 'cn=c',
-                    'data' => array(
-                        'a' => '1',
-                        'b' => '2',
-                        'c' => '3',
-                    )
-                ),
-                'cn=d' => array(
-                    'dn' => 'cn=d',
-                    'data' => array(
-                        'a' => '2',
-                        'b' => '2',
-                        'c' => '1',
-                    )
-                ),
-            )
-        );
-        $injector->setInstance('Horde_Kolab_Server_Config', $config);
-        $injector->bindFactory('Horde_Kolab_Server_Structure',
-                               'Horde_Kolab_Server_Factory',
-                               'getStructure');
-        $injector->bindFactory('Horde_Kolab_Server',
-                               'Horde_Kolab_Server_Factory',
-                               'getServer');
-        $db = $injector->getInstance('Horde_Kolab_Server');
-
-        $a = $db->search('(c=1)');
-        $this->assertEquals(
-            array(
-                'cn=a' => array(
-                    'a' => '1',
-                    'b' => '1',
-                    'c' => '1',
-                    'dn' => 'cn=a',
-                ),
-                'cn=d' => array(
-                    'a' => '2',
-                    'b' => '2',
-                    'c' => '1',
-                    'dn' => 'cn=d',
-                ),
-            ),
-            $a
-        );
-
-        $a = $db->search('(c=3)');
-        $this->assertEquals(
-            array(
-                'cn=c' => array(
-                    'a' => '1',
-                    'b' => '2',
-                    'c' => '3',
-                    'dn' => 'cn=c',
-                ),
-            ),
-            $a
-        );
-
-        $a = $db->search('(c=3)', array('attributes' => array('a')));
-        $this->assertEquals(
-            array(
-                'cn=c' => array(
-                    'a' => '1',
-                    'dn' => 'cn=c',
-                ),
-            ),
-            $a
-        );
-
-        $a = $db->search('(&(a=1)(b=2))', array('attributes' => array('a', 'b')));
-        $this->assertEquals(
-            array(
-                'cn=b' => array(
-                    'a' => '1',
-                    'b' => '2',
-                    'dn' => 'cn=b',
-                ),
-                'cn=c' => array(
-                    'a' => '1',
-                    'b' => '2',
-                    'dn' => 'cn=c',
-                ),
-            ),
-            $a
-        );
-
-        $a = $db->search('(&(b=2))', array('attributes' => array('b')));
-        $this->assertEquals(
-            array(
-                'cn=b' => array(
-                    'b' => '2',
-                    'dn' => 'cn=b',
-                ),
-                'cn=c' => array(
-                    'b' => '2',
-                    'dn' => 'cn=c',
-                ),
-                'cn=d' => array(
-                    'b' => '2',
-                    'dn' => 'cn=d',
-                ),
-            ),
-            $a
-        );
-
-        $a = $db->search('(!(b=2))', array('attributes' => array('a', 'b')));
-        $this->assertEquals(
-            array(
-                'cn=a' => array(
-                    'a' => '1',
-                    'b' => '1',
-                    'dn' => 'cn=a',
-                ),
-            ),
-            $a
-        );
-
-        $a = $db->search('(&(!(x=2))(b=1))', array('attributes' => array('b')));
-        $this->assertEquals(
-            array(
-                'cn=a' => array(
-                    'b' => '1',
-                    'dn' => 'cn=a',
-                ),
-            ),
-            $a
-        );
-    }
-
-}
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Server/ServerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Server/ServerTest.php
deleted file mode 100644 (file)
index ee7c12a..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-/**
- * Test the server class.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Tests for the main server class.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Horde_Kolab_Server_Server_ServerTest extends PHPUnit_Framework_TestCase
-{
-    public function setUp()
-    {
-        $this->markTestIncomplete('Needs to be fixed');
-    }
-
-    /**
-     * Provide a mock server.
-     *
-     * @return Horde_Kolab_Server The mock server.
-     */
-    protected function getMockServer()
-    {
-        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-        $config = new stdClass;
-        $config->driver = 'none';
-        $injector->setInstance('Horde_Kolab_Server_Config', $config);
-        $injector->bindFactory('Horde_Kolab_Server_Structure',
-                               'Horde_Kolab_Server_Factory',
-                               'getStructure');
-        $injector->bindFactory('Horde_Kolab_Server',
-                               'Horde_Kolab_Server_Factory',
-                               'getServer');
-        return $injector->getInstance('Horde_Kolab_Server');
-    }
-
-    /**
-     * The generating a uid for an object.
-     *
-     * @return NULL
-     */
-    public function testGenerateUid()
-    {
-        $ks   = $this->getMockServer();
-        $user = new Horde_Kolab_Server_Object($ks, null, null);
-        $this->assertEquals(preg_replace('/[0-9a-f]*/', '', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)), '');
-    }
-
-    /**
-     * Test creating the server object.
-     *
-     * @return NULL
-     */
-    public function testCreation()
-    {
-        try {
-            $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-            $config = new stdClass;
-            $config->driver = 'dummy';
-            $injector->setInstance('Horde_Kolab_Server_Config', $config);
-            $injector->bindFactory('Horde_Kolab_Server_Structure',
-                                   'Horde_Kolab_Server_Factory',
-                                   'getStructure');
-            $injector->bindFactory('Horde_Kolab_Server',
-                                   'Horde_Kolab_Server_Factory',
-                                   'getServer');
-            Horde_Kolab_Server_Factory::getServer($injector);
-            $this->assertFail('No error!');
-        } catch (Horde_Kolab_Server_Exception $e) {
-            $this->assertEquals('Server type definition "Horde_Kolab_Server_Dummy" missing.',
-                                $e->getMessage());
-        }
-    }
-
-    /**
-     * The base class provides no abilities for reading data. So it
-     * should mainly return error. But it should be capable of
-     * returning a dummy Kolab user object.
-     *
-     * @return NULL
-     */
-    public function testFetch()
-    {
-        $ks   = $this->getMockServer();
-        $user = $ks->fetch('test');
-        $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
-
-        $ks   = $this->getMockServer();
-        $user = $ks->fetch();
-        $this->assertEquals('Horde_Kolab_Server_Object_Kolab_User', get_class($user));
-    }
-
-    /**
-     * Test listing objects.
-     *
-     * @return NULL
-     */
-    public function testList()
-    {
-        $ks   = $this->getMockServer();
-        $hash = $ks->listHash('Horde_Kolab_Server_Object');
-        $this->assertEquals($hash, array());
-
-        $ks   = $this->getMockServer();
-        $hash = $ks->listHash('Horde_Kolab_Server_Object');
-        $this->assertEquals($hash, array());
-    }
-
-}
index fa72c92..2ff1ff1 100644 (file)
@@ -34,8 +34,6 @@ class Horde_Kolab_Server_Structure_KolabTest extends PHPUnit_Framework_TestCase
 {
     public function setUp()
     {
-        $this->markTestIncomplete('Needs to be fixed');
-
         $server = $this->getMock('Horde_Kolab_Server');
         $this->composite = new Horde_Kolab_Server_Composite(
             $server,
@@ -84,7 +82,7 @@ class Horde_Kolab_Server_Structure_KolabTest extends PHPUnit_Framework_TestCase
             ->method('read')
             ->with('guid')
             ->will($this->returnValue(array('objectClass' => array('top'))));
-        $this->assertEquals('Horde_Kolab_Server_Object', $this->composite->structure->determineType('guid'));
+        $this->assertEquals('Horde_Kolab_Server_Object_Top', $this->composite->structure->determineType('guid'));
     }
 
     public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid5()
index 7c9630e..95ed217 100644 (file)
@@ -34,8 +34,6 @@ class Horde_Kolab_Server_Structure_LdapTest extends PHPUnit_Framework_TestCase
 {
     public function setUp()
     {
-        $this->markTestIncomplete('Needs to be fixed');
-
         $server = $this->getMock('Horde_Kolab_Server');
         $this->composite = new Horde_Kolab_Server_Composite(
             $server,
@@ -66,7 +64,7 @@ class Horde_Kolab_Server_Structure_LdapTest extends PHPUnit_Framework_TestCase
             ->method('read')
             ->with('guid')
             ->will($this->returnValue(array('objectClass' => array('TOP'))));
-        $this->assertEquals('Horde_Kolab_Server_Object', $this->composite->structure->determineType('guid'));
+        $this->assertEquals('Horde_Kolab_Server_Object_Top', $this->composite->structure->determineType('guid'));
     }
 
     public function testMethodDeterminetypeHasResultStringTheObjectclassOfTheGivenGuid2()