Completed the factory testing.
authorGunnar Wrobel <p@rdus.de>
Wed, 28 Oct 2009 08:30:24 +0000 (09:30 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 28 Oct 2009 08:30:24 +0000 (09:30 +0100)
21 files changed:
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaned.php [deleted file]
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php [new file with mode: 0644]
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php
framework/Kolab_Server/package.xml
framework/Kolab_Server/test/Horde/Kolab/Server/AllTests.php
framework/Kolab_Server/test/Horde/Kolab/Server/Autoload.php
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php [new file with mode: 0644]
framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php [new file with mode: 0644]

diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaned.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaned.php
deleted file mode 100644 (file)
index 5764453..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-<?php
-/**
- * A factory decorator that adds cleaning to the generated instances.
- *
- * 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 factory decorator that adds cleaning to the generated instances.
- *
- * 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_Factory_Cleaned
-implements Horde_Kolab_Server_Factory
-{
-    /**
-     * The factory used for creating the instances.
-     *
-     * @var Horde_Kolab_Server_Factory
-     */
-    private $_factory;
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Kolab_Server_Factory $factory The base factory.
-     */
-    public function __construct(Horde_Kolab_Server_Factory $factory)
-    {
-        $this->_factory = $factory;
-        $this->_mapping = $mapping;
-    }
-
-    /**
-     * Returns the conn factory.
-     *
-     * @return Horde_Kolab_Server_Factory_Conn The connection factory.
-     */
-    public function getConnectionFactory()
-    {
-        return $this->_factory->getConnectionFactory();
-    }
-
-    /**
-     * Returns the server configuration parameters.
-     *
-     * @return array The configuration parameters.
-     */
-    public function getConfiguration()
-    {
-        return $this->_factory->getConfiguration();
-    }
-
-    /**
-     * Return the server connection that should be used.
-     *
-     * @return Horde_Kolab_Server The Horde_Kolab_Server connection.
-     */
-    public function getServer()
-    {
-        $server = $this->_factory->getServer();
-        $server = new Horde_Kolab_Server_Cleaned($server);
-        return $server;
-    }
-
-    /**
-     * Return the server that should be used.
-     *
-     * @return Horde_Kolab_Server_Connection The connection.
-     */
-    public function getConnection()
-    {
-        return $this->_factory->getConnection();
-    }
-
-    /**
-     * Returns a concrete Horde_Kolab_Server_Composite instance.
-     *
-     * @return Horde_Kolab_Server_Composite The newly created concrete
-     *                                      Horde_Kolab_Server_Composite
-     *                                      instance.
-     */
-    public function getComposite()
-    {
-        return $this->_factory->getComposite();
-    }
-
-    /**
-     * Return the object handler that should be used.
-     *
-     * @return Horde_Kolab_Server_Objects The handler for objects on the server.
-     */
-    public function getObjects()
-    {
-        return $this->_factory->getObjects();
-    }
-
-    /**
-     * Return the structural representation that should be used.
-     *
-     * @return Horde_Kolab_Server_Structure The representation of the db
-     *                                      structure.
-     */
-    public function getStructure()
-    {
-        return $this->_factory->getStructure();
-    }
-
-    /**
-     * Return the search handler that should be used.
-     *
-     * @return Horde_Kolab_Server_Search The search handler.
-     */
-    public function getSearch()
-    {
-        return $this->_factory->getSearch();
-    }
-
-    /**
-     * Return the db schema representation that should be used.
-     *
-     * @return Horde_Kolab_Server_Schema The db schema representation.
-     */
-    public function getSchema()
-    {
-        return $this->_factory->getSchema();
-    }
-
-}
\ No newline at end of file
diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php
new file mode 100644 (file)
index 0000000..9c79108
--- /dev/null
@@ -0,0 +1,143 @@
+<?php
+/**
+ * A factory decorator that adds cleaning to the generated instances.
+ *
+ * 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 factory decorator that adds cleaning to the generated instances.
+ *
+ * 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_Factory_Cleaner
+implements Horde_Kolab_Server_Factory
+{
+    /**
+     * The factory used for creating the instances.
+     *
+     * @var Horde_Kolab_Server_Factory
+     */
+    private $_factory;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Kolab_Server_Factory $factory The base factory.
+     */
+    public function __construct(Horde_Kolab_Server_Factory $factory)
+    {
+        $this->_factory = $factory;
+    }
+
+    /**
+     * Returns the conn factory.
+     *
+     * @return Horde_Kolab_Server_Factory_Conn The connection factory.
+     */
+    public function getConnectionFactory()
+    {
+        return $this->_factory->getConnectionFactory();
+    }
+
+    /**
+     * Returns the server configuration parameters.
+     *
+     * @return array The configuration parameters.
+     */
+    public function getConfiguration()
+    {
+        return $this->_factory->getConfiguration();
+    }
+
+    /**
+     * Return the server connection that should be used.
+     *
+     * @return Horde_Kolab_Server The Horde_Kolab_Server connection.
+     */
+    public function getServer()
+    {
+        $server = $this->_factory->getServer();
+        $server = new Horde_Kolab_Server_Cleaner($server);
+        return $server;
+    }
+
+    /**
+     * Return the server that should be used.
+     *
+     * @return Horde_Kolab_Server_Connection The connection.
+     */
+    public function getConnection()
+    {
+        return $this->_factory->getConnection();
+    }
+
+    /**
+     * Returns a concrete Horde_Kolab_Server_Composite instance.
+     *
+     * @return Horde_Kolab_Server_Composite The newly created concrete
+     *                                      Horde_Kolab_Server_Composite
+     *                                      instance.
+     */
+    public function getComposite()
+    {
+        return $this->_factory->getComposite();
+    }
+
+    /**
+     * Return the object handler that should be used.
+     *
+     * @return Horde_Kolab_Server_Objects The handler for objects on the server.
+     */
+    public function getObjects()
+    {
+        return $this->_factory->getObjects();
+    }
+
+    /**
+     * Return the structural representation that should be used.
+     *
+     * @return Horde_Kolab_Server_Structure The representation of the db
+     *                                      structure.
+     */
+    public function getStructure()
+    {
+        return $this->_factory->getStructure();
+    }
+
+    /**
+     * Return the search handler that should be used.
+     *
+     * @return Horde_Kolab_Server_Search The search handler.
+     */
+    public function getSearch()
+    {
+        return $this->_factory->getSearch();
+    }
+
+    /**
+     * Return the db schema representation that should be used.
+     *
+     * @return Horde_Kolab_Server_Schema The db schema representation.
+     */
+    public function getSchema()
+    {
+        return $this->_factory->getSchema();
+    }
+
+}
\ No newline at end of file
index 2a07597..c54ca48 100644 (file)
@@ -66,8 +66,8 @@ implements Horde_Kolab_Server_Factory
         }
 
         if (!empty($config['cleanup'])) {
-            $factory = new Horde_Kolab_Server_Factory_Cleaned(
-                $factory, $config['map']
+            $factory = new Horde_Kolab_Server_Factory_Cleaner(
+                $factory
             );
         }
 
index 81fb120..3e2e7d7 100644 (file)
 interface Horde_Kolab_Server_Factory_Conn
 {
     /**
+     * Get the connection configuration.
+     *
+     * @return array $configuration The configuration parameters.
+     */
+    public function getConfiguration();
+
+    /**
      * Set the connection configuration.
      *
      * @param array $configuration The configuration parameters.
index 3c96143..1336cbd 100644 (file)
@@ -36,6 +36,21 @@ implements Horde_Kolab_Server_Factory_Conn
     private $_configuration;
 
     /**
+     * Get the connection configuration.
+     *
+     * @return array $configuration The configuration parameters.
+     */
+    public function getConfiguration()
+    {
+        if (!isset($this->_configuration)) {
+            throw new Horde_Kolab_Server_Exception(
+                'The configuration has not been set!'
+            ); 
+        }
+        return $this->_configuration;
+    }
+
+    /**
      * Set the connection configuration.
      *
      * @param array $configuration The configuration parameters.
@@ -44,25 +59,6 @@ implements Horde_Kolab_Server_Factory_Conn
      */
     public function setConfiguration(array $configuration)
     {
-        if (!isset($configuration['basedn'])) {
-            throw new Horde_Kolab_Server_Exception('The base DN is missing');
-        }
-
-        if (isset($configuration['server'])) {
-            $configuration['host'] = $configuration['server'];
-            unset($configuration['server']);
-        }
-
-        if (isset($configuration['phpdn'])) {
-            $configuration['binddn'] = $configuration['phpdn'];
-            unset($configuration['phpdn']);
-        }
-
-        if (isset($configuration['phppw'])) {
-            $configuration['bindpw'] = $configuration['phppw'];
-            unset($configuration['phppw']);
-        }
-
         $this->_configuration = $configuration;
     }
 }
\ No newline at end of file
index f53b1a9..f483de8 100644 (file)
@@ -29,16 +29,48 @@ class Horde_Kolab_Server_Factory_Conn_Ldap
 extends Horde_Kolab_Server_Factory_Conn_Base
 {
     /**
+     * Set the connection configuration.
+     *
+     * @param array $configuration The configuration parameters.
+     *
+     * @return NULL
+     */
+    public function setConfiguration(array $configuration)
+    {
+        if (!isset($configuration['basedn'])) {
+            throw new Horde_Kolab_Server_Exception('The base DN is missing!');
+        }
+
+        if (isset($configuration['server'])) {
+            $configuration['host'] = $configuration['server'];
+            unset($configuration['server']);
+        }
+
+        if (isset($configuration['phpdn'])) {
+            $configuration['binddn'] = $configuration['phpdn'];
+            unset($configuration['phpdn']);
+        }
+
+        if (isset($configuration['phppw'])) {
+            $configuration['bindpw'] = $configuration['phppw'];
+            unset($configuration['phppw']);
+        }
+
+        parent::setConfiguration($configuration);
+    }
+
+    /**
      * Return the server connection that should be used.
      *
      * @return Horde_Kolab_Server_Connection The server connection.
      */
     public function getConnection()
     {
-        $ldap_read = new Net_LDAP2($params);
-        if (isset($params['host_master'])) {
-            $params['host'] = $params['host_master'];
-            $ldap_write = new Net_LDAP2($params);
+        $configuration = $this->getConfiguration();
+        $ldap_read = new Net_LDAP2($configuration);
+        if (isset($configuration['host_master'])) {
+            $configuration['host'] = $configuration['host_master'];
+            $ldap_write = new Net_LDAP2($configuration);
             $connection = new Horde_Kolab_Server_Connection_Splittedldap(
                 $ldap_read, $ldap_write
             );
index 5cbdcf4..8578f50 100644 (file)
@@ -36,7 +36,7 @@ extends Horde_Kolab_Server_Factory_Conn_Base
     public function getConnection()
     {
         $connection = new Horde_Kolab_Server_Connection_Mock(
-            $this->_configuration
+            $this->getConfiguration()
         );
         return $connection;
     }
index 1e03e7a..0699c40 100644 (file)
@@ -29,20 +29,6 @@ class Horde_Kolab_Server_Factory_Injector
 implements Horde_Kolab_Server_Factory
 {
     /**
-     * The conn factory class.
-     *
-     * @param string
-     */
-    private $_conn_factory;
-
-    /**
-     * Configuration parameters for the server.
-     *
-     * @var array
-     */
-    private $_configuration;
-
-    /**
      * The injector.
      *
      * @var Horde_Injector
@@ -57,8 +43,6 @@ implements Horde_Kolab_Server_Factory
     public function __construct(
         Horde_Injector $injector
     ) {
-        $this->_conn_factory  = $factory;
-        $this->_configuration = $config;
         $this->_injector      = $injector;
         $this->_setup();
     }
@@ -95,7 +79,7 @@ implements Horde_Kolab_Server_Factory
         Horde_Injector $injector
     ) {
         $injector->setInstance(
-            'Horde_Kolab_Server_Config', $config
+            'Horde_Kolab_Server_Configuration', $config
         );
     }
 
@@ -179,13 +163,14 @@ implements Horde_Kolab_Server_Factory
      */
     private function _setupStructure()
     {
-        if (!isset($this->_configuration['structure']['driver'])) {
+        $configuration = $this->getConfiguration();
+        if (!isset($configuration['structure']['driver'])) {
             $driver = 'Horde_Kolab_Server_Structure_Kolab';
         } else {
-            $driver = $this->_configuration['structure']['driver'];
+            $driver = $configuration['structure']['driver'];
         }
 
-        $injector->bindImplementation('Horde_Kolab_Server_Structure', $driver);
+        $this->_injector->bindImplementation('Horde_Kolab_Server_Structure', $driver);
     }
 
     /**
@@ -195,7 +180,7 @@ implements Horde_Kolab_Server_Factory
      */
     private function _setupConnection()
     {
-        $injector->bindFactory(
+        $this->_injector->bindFactory(
             'Horde_Kolab_Server_Connection',
             'Horde_Kolab_Server_Factory_Conn_Injector',
             'getConnection'
@@ -209,7 +194,7 @@ implements Horde_Kolab_Server_Factory
      */
     private function _setupServer()
     {
-        $injector->bindFactory(
+        $this->_injector->bindFactory(
             'Horde_Kolab_Server',
             'Horde_Kolab_Server_Factory_Injector',
             'getServer'
@@ -267,7 +252,7 @@ implements Horde_Kolab_Server_Factory
     {
         $configuration = $this->getConfiguration();
         if (!isset($configuration['basedn'])) {
-            throw new Horde_Kolab_Server_Exception('The base DN is missing');
+            throw new Horde_Kolab_Server_Exception('The base DN is missing!');
         }
 
         $connection = $this->getConnection();
index 54cca83..b177ed3 100644 (file)
@@ -82,7 +82,9 @@ implements Horde_Kolab_Server_Factory
     public function getServer()
     {
         $server = $this->_factory->getServer();
-        $server = new Horde_Kolab_Server_Logged($server);
+        $server = new Horde_Kolab_Server_Logged(
+            $server, $this->_logger
+        );
         return $server;
     }
 
index 7d27db5..efafca5 100644 (file)
@@ -61,6 +61,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
      <dir name="Kolab">
       <file name="Server.php" role="php" />
       <dir name="Server">
+       <file name="Cleaner.php" role="php" />
        <file name="Composite.php" role="php" />
        <file name="Connection.php" role="php" />
        <dir name="Connection">
@@ -79,7 +80,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <file name="Factory.php" role="php" />
        <dir name="Factory">
         <file name="Base.php" role="php" />
-        <file name="Cleaned.php" role="php" />
+        <file name="Cleaner.php" role="php" />
         <file name="Configuration.php" role="php" />
         <file name="Conn.php" role="php" />
         <dir name="Conn">
@@ -303,6 +304,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <phprelease>
   <filelist>
    <install name="lib/Horde/Kolab/Server.php" as="Horde/Kolab/Server.php" />
+   <install name="lib/Horde/Kolab/Server/Cleaner.php" as="Horde/Kolab/Server/Cleaner.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" />
@@ -314,7 +316,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Kolab/Server/Exception/Novalue.php" as="Horde/Kolab/Server/Exception/Novalue.php" />
    <install name="lib/Horde/Kolab/Server/Factory.php" as="Horde/Kolab/Server/Factory.php" />
    <install name="lib/Horde/Kolab/Server/Factory/Base.php" as="Horde/Kolab/Server/Factory/Base.php" />
-   <install name="lib/Horde/Kolab/Server/Factory/Cleaned.php" as="Horde/Kolab/Server/Factory/Cleaned.php" />
+   <install name="lib/Horde/Kolab/Server/Factory/Cleaner.php" as="Horde/Kolab/Server/Factory/Cleaner.php" />
    <install name="lib/Horde/Kolab/Server/Factory/Configuration.php" as="Horde/Kolab/Server/Factory/Configuration.php" />
    <install name="lib/Horde/Kolab/Server/Factory/Conn.php" as="Horde/Kolab/Server/Factory/Conn.php" />
    <install name="lib/Horde/Kolab/Server/Factory/Conn/Base.php" as="Horde/Kolab/Server/Factory/Conn/Base.php" />
index 73997e5..02ca677 100644 (file)
@@ -57,9 +57,6 @@ class Horde_Kolab_Server_AllTests
      */
     public static function suite()
     {
-        // Catch strict standards
-        error_reporting(E_ALL | E_STRICT);
-
         $suite = new PHPUnit_Framework_TestSuite('Horde Framework - Kolab_Server');
 
         $basedir    = dirname(__FILE__);
index 780b43c..f71c887 100644 (file)
@@ -22,4 +22,7 @@ if (!spl_autoload_functions()) {
             . 'error_reporting($oldErrorReporting);'
         )
     );
-}
\ No newline at end of file
+}
+
+/** Catch strict standards */
+error_reporting(E_ALL | E_STRICT);
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php
new file mode 100644 (file)
index 0000000..4a7a234
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Test the cleaner server factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the cleaner server factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_CleanerTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->factory = $this->getMock('Horde_Kolab_Server_Factory');
+    }
+
+    public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array('cleanup' => true)
+        );
+        $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer());
+    }
+
+    public function testMethodConstructHasParametersFactory()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory
+        );
+    }
+
+    public function testMethodGetconnectionfactoryGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnectionFactory');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getConnectionFactory();
+    }
+
+    public function testMethodGetserverGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getServer();
+    }
+
+    public function testMethodGetconfigurationGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConfiguration');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getConfiguration();
+    }
+
+    public function testMethodGetconnectionGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getConnection();
+    }
+
+    public function testMethodGetcompositeGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getComposite');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getComposite();
+    }
+
+    public function testMethodGetobjectsGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getObjects');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getObjects();
+    }
+
+    public function testMethodGetstructureGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getStructure');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getStructure();
+    }
+
+    public function testMethodGetsearchGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSearch');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getSearch();
+    }
+
+    public function testMethodGetschemaGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSchema');
+        $factory = new Horde_Kolab_Server_Factory_Cleaner(
+            $this->factory, array()
+        );
+        $factory->getSchema();
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php
new file mode 100644 (file)
index 0000000..8ba5eb9
--- /dev/null
@@ -0,0 +1,170 @@
+<?php
+/**
+ * Test the configuration based server factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the configuration based server factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_ConfigurationTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->factory = $this->getMock('Horde_Kolab_Server_Factory');
+    }
+
+    public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array('logger' => 'set')
+        );
+        $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer());
+    }
+
+    public function testMethodGetserverHasResultMappedServerIfAMappedWasProvidedInTheConfiguration()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array('map' => array())
+        );
+        $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer());
+    }
+
+    public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array('cleanup' => true)
+        );
+        $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer());
+    }
+
+    public function testMethodConstructHasParametersFactoryAndArrayParameters()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+    }
+
+    public function testMethodGetconnectionfactoryGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnectionFactory');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getConnectionFactory();
+    }
+
+    public function testMethodGetserverGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getServer();
+    }
+
+    public function testMethodGetconfigurationGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConfiguration');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getConfiguration();
+    }
+
+    public function testMethodGetconnectionGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getConnection();
+    }
+
+    public function testMethodGetcompositeGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getComposite');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getComposite();
+    }
+
+    public function testMethodGetobjectsGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getObjects');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getObjects();
+    }
+
+    public function testMethodGetstructureGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getStructure');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getStructure();
+    }
+
+    public function testMethodGetsearchGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSearch');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getSearch();
+    }
+
+    public function testMethodGetschemaGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSchema');
+        $factory = new Horde_Kolab_Server_Factory_Configuration(
+            $this->factory, array()
+        );
+        $factory->getSchema();
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php
new file mode 100644 (file)
index 0000000..7ecff3f
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Test the injector based connection factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the injector based connection factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_Conn_InjectorTest
+extends PHPUnit_Framework_TestCase
+{
+    public function testMethodGetconnectionHasResultConnection()
+    {
+        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+        $injector->bindImplementation(
+            'Horde_Kolab_Server_Factory_Conn',
+            'Horde_Kolab_Server_Factory_Conn_Mock'
+        );
+        $injector->setInstance(
+            'Horde_Kolab_Server_Configuration',
+            array()
+        );
+        $factory = new Horde_Kolab_Server_Factory_Conn_Injector($injector);
+        $this->assertType(
+            'Horde_Kolab_Server_Connection',
+            $factory->getConnection()
+        );
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php
new file mode 100644 (file)
index 0000000..7f2aaa9
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+/**
+ * Test the ldap connection factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the ldap connection factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_Conn_LdapTest
+extends PHPUnit_Framework_TestCase
+{
+    public function testMethodSetconfigurationHasPostconditionThatTheServerParameterWasRewritten()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Ldap();
+        $factory->setConfiguration(
+            array(
+                'basedn' => 'test',
+                'server' => '1'
+            )
+        );
+        $this->assertEquals(
+            array(
+                'basedn' => 'test',
+                'host' => '1'
+            ),
+            $factory->getConfiguration()
+        );
+    }
+
+    public function testMethodSetconfigurationHasPostconditionThatThePhpdnParameterWasRewritten()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Ldap();
+        $factory->setConfiguration(
+            array(
+                'basedn' => 'test',
+                'phpdn' => '1'
+            )
+        );
+        $this->assertEquals(
+            array(
+                'basedn' => 'test',
+                'binddn' => '1'
+            ),
+            $factory->getConfiguration()
+        );
+    }
+
+    public function testMethodSetconfigurationHasPostconditionThatThePhppwParameterWasRewritten()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Ldap();
+        $factory->setConfiguration(
+            array(
+                'basedn' => 'test',
+                'phppw' => '1'
+            )
+        );
+        $this->assertEquals(
+            array(
+                'basedn' => 'test',
+                'bindpw' => '1'
+            ),
+            $factory->getConfiguration()
+        );
+    }
+
+    public function testMethodSetconfigurationThrowsExceptionIfTheBasednIsNotSet()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Ldap();
+        try {
+            $factory->setConfiguration(array());
+            $this->fail('No exception!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals(
+                'The base DN is missing!',
+                $e->getMessage()
+            );
+        }
+    }
+
+    public function testMethodGetconnectionHasResultConnectionSimpleldap()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Ldap();
+        $factory->setConfiguration(array('basedn' => 'test'));
+        $this->assertType(
+            'Horde_Kolab_Server_Connection_Simpleldap',
+            $factory->getConnection()
+        );
+    }
+
+    public function testMethodGetconnectionHasResultConnectionSplittedldapIfTheHostMasterIsSet()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Ldap();
+        $factory->setConfiguration(array('basedn' => 'test', 'host_master' => 'dummy'));
+        $this->assertType(
+            'Horde_Kolab_Server_Connection_Splittedldap',
+            $factory->getConnection()
+        );
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php
new file mode 100644 (file)
index 0000000..a551879
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Test the mock connection factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the mock connection factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_Conn_MockTest
+extends PHPUnit_Framework_TestCase
+{
+    public function testMethodGetconfigurationHasResultArrayTheConnectionConfiguration()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Mock();
+        $factory->setConfiguration(array('basedn' => 'test'));
+        $this->assertEquals(
+            array('basedn' => 'test'),
+            $factory->getConfiguration()
+        );
+    }
+
+    public function testMethodSetconfigurationHasPostconditionThatTheConfigurationWasSaved()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Mock();
+        $factory->setConfiguration(array());
+        $this->assertEquals(
+            array(),
+            $factory->getConfiguration()
+        );
+    }
+
+    public function testMethodGetconfigurationThrowsExceptionIfNoConfigurationHasBeenSet()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Mock();
+        try {
+            $factory->getConfiguration();
+            $this->fail('No exception!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals(
+                'The configuration has not been set!',
+                $e->getMessage()
+            );
+        }
+    }
+
+    public function testMethodGetconnectionHasResultConnectionmock()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Conn_Mock();
+        $factory->setConfiguration(array('basedn' => 'test'));
+        $this->assertType(
+            'Horde_Kolab_Server_Connection_Mock',
+            $factory->getConnection()
+        );
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php
new file mode 100644 (file)
index 0000000..59f42df
--- /dev/null
@@ -0,0 +1,153 @@
+<?php
+/**
+ * Test the mapping server factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the mapping server factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_ConstructorTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->factory   = $this->getMock('Horde_Kolab_Server_Factory_Conn');
+        $this->objects   = $this->getMock('Horde_Kolab_Server_Objects');
+        $this->structure = $this->getMock('Horde_Kolab_Server_Structure');
+        $this->search    = $this->getMock('Horde_Kolab_Server_Search');
+        $this->schema    = $this->getMock('Horde_Kolab_Server_Schema');
+    }
+
+    public function testMethodConstructHasParametersFactoryObjectsStructureSearchSchemaConfig()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+    }
+
+    public function testMethodGetserverReturnsServer()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection')
+            ->will(
+                $this->returnValue(
+                    $this->getMock('Horde_Kolab_Server_Connection')
+                )
+            );
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertType('Horde_Kolab_Server', $factory->getServer());
+    }
+
+    public function testMethodGetconfigurationReturnsArrayConfiguration()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertEquals(
+            array('basedn' => 'test'), $factory->getConfiguration()
+        );
+    }
+
+    public function testMethodGetconnectionGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection')
+            ->will(
+                $this->returnValue(
+                    $this->getMock('Horde_Kolab_Server_Connection')
+                )
+            );
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertType(
+            'Horde_Kolab_Server_Connection',
+            $factory->getConnection()
+        );
+    }
+
+    public function testMethodGetcompositeReturnsComposite()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection')
+            ->will(
+                $this->returnValue(
+                    $this->getMock('Horde_Kolab_Server_Connection')
+                )
+            );
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertType(
+            'Horde_Kolab_Server_Composite',
+            $factory->getComposite()
+        );
+    }
+
+    public function testMethodGetobjectsReturnsObjects()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertSame($this->objects, $factory->getObjects());
+    }
+
+    public function testMethodGetstructureReturnsStructure()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertSame($this->structure, $factory->getStructure());
+    }
+
+    public function testMethodGetsearchReturnsSearch()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertSame($this->search,  $factory->getSearch());
+    }
+
+    public function testMethodGetschemaGetsDelegated()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Constructor(
+            $this->factory, $this->objects, $this->structure,
+            $this->search, $this->schema, array('basedn' => 'test')
+        );
+        $this->assertSame($this->schema,  $factory->getSchema());
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php
new file mode 100644 (file)
index 0000000..8dadfb1
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+/**
+ * Test the injector based server factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the injector based server factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_InjectorTest
+extends PHPUnit_Framework_TestCase
+{
+    private function _getFactory(array $configuration = array())
+    {
+        $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+        Horde_Kolab_Server_Factory_Injector::setup(
+            'Horde_Kolab_Server_Factory_Conn_Mock',
+            $configuration,
+            $injector
+        );
+        return $injector->getInstance(
+            'Horde_Kolab_Server_Factory_Injector'
+        );
+    }
+
+    public function testMethodGetconnectionfactoryHasResultConnectionfactory()
+    {
+        $this->assertType(
+            'Horde_Kolab_Server_Factory_Conn',
+            $this->_getFactory(array())->getConnectionFactory()
+        );
+    }
+
+    public function testMethodGetconnectionHasResultConnection()
+    {
+        $factory = $this->_getFactory(array());
+        $this->assertType(
+            'Horde_Kolab_Server_Connection',
+            $factory->getConnection()
+        );
+    }
+
+    public function testMethodGetserverHasResultServerldapstandard()
+    {
+        $factory = $this->_getFactory(array('basedn' => 'test'));
+        $this->assertType(
+            'Horde_Kolab_Server_Ldap_Standard',
+            $factory->getServer()
+        );
+    }
+
+    public function testMethodGetserverThrowsExceptionIfTheBaseDnIsMissingInTheConfiguration()
+    {
+        $factory = $this->_getFactory(array());
+        try {
+            $factory->getServer();
+            $this->fail('No exception!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals(
+                'The base DN is missing!',
+                $e->getMessage()
+            );
+        }
+    }
+
+    public function testMethodGetserverHasResultServerldapFilteredIfAFilterWasSet()
+    {
+        $factory = $this->_getFactory(array('filter' => 'test', 'basedn' => 'test'));
+        $this->assertType(
+            'Horde_Kolab_Server_Ldap_Filtered',
+            $factory->getServer()
+        );
+    }
+
+    public function testMethodGetobjectsHasResultObjects()
+    {
+        $factory = $this->_getFactory(array());
+        $this->assertType(
+            'Horde_Kolab_Server_Objects',
+            $factory->getObjects()
+        );
+    }
+
+    public function testMethodGetstructureHasResultStructureKolab()
+    {
+        $factory = $this->_getFactory(array());
+        $this->assertType(
+            'Horde_Kolab_Server_Structure_Kolab',
+            $factory->getStructure()
+        );
+    }
+
+    public function testMethodGetstructureHasResultStructureLdapIfConfiguredThatWay()
+    {
+        $factory = $this->_getFactory(
+            array(
+                'structure' => array(
+                    'driver' => 'Horde_Kolab_Server_Structure_Ldap'
+                )
+            )
+        );
+        $this->assertType(
+            'Horde_Kolab_Server_Structure_Ldap',
+            $factory->getStructure()
+        );
+    }
+
+    public function testMethodGetsearchHasResultSearch()
+    {
+        $factory = $this->_getFactory(array());
+        $this->assertType(
+            'Horde_Kolab_Server_Search',
+            $factory->getSearch()
+        );
+    }
+
+    public function testMethodGetschemaHasResultSchema()
+    {
+        $factory = $this->_getFactory(array());
+        $this->assertType(
+            'Horde_Kolab_Server_Schema',
+            $factory->getSchema()
+        );
+    }
+
+    public function testMethodGetcompositeHasResultComposite()
+    {
+        $factory = $this->_getFactory(array('basedn' => 'test'));
+        $this->assertType(
+            'Horde_Kolab_Server_Composite',
+            $factory->getComposite()
+        );
+    }
+
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php
new file mode 100644 (file)
index 0000000..9f299be
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Test the log decorator server factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the log decorator server factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_LoggedTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->factory = $this->getMock('Horde_Kolab_Server_Factory');
+    }
+
+    public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer());
+    }
+
+    public function testMethodConstructHasParametersFactoryAndMixedLoggerParameter()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+    }
+
+    public function testMethodGetconnectionfactoryGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnectionFactory');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getConnectionFactory();
+    }
+
+    public function testMethodGetserverGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getServer();
+    }
+
+    public function testMethodGetconfigurationGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConfiguration');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getConfiguration();
+    }
+
+    public function testMethodGetconnectionGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getConnection();
+    }
+
+    public function testMethodGetcompositeGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getComposite');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getComposite();
+    }
+
+    public function testMethodGetobjectsGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getObjects');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getObjects();
+    }
+
+    public function testMethodGetstructureGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getStructure');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getStructure();
+    }
+
+    public function testMethodGetsearchGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSearch');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getSearch();
+    }
+
+    public function testMethodGetschemaGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSchema');
+        $factory = new Horde_Kolab_Server_Factory_Logged(
+            $this->factory, 'logger'
+        );
+        $factory->getSchema();
+    }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php
new file mode 100644 (file)
index 0000000..c2ea0b1
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Test the mapping server factory.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the mapping server factory.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Horde_Kolab_Server_Class_Server_Factory_MappedTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->factory = $this->getMock('Horde_Kolab_Server_Factory');
+    }
+
+    public function testMethodGetserverHasResultMappedServer()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer());
+    }
+
+    public function testMethodConstructHasParametersFactoryAndArrayMapping()
+    {
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+    }
+
+    public function testMethodGetconnectionfactoryGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnectionFactory');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getConnectionFactory();
+    }
+
+    public function testMethodGetserverGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getServer')
+            ->will($this->returnValue($this->getMock('Horde_Kolab_Server')));
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getServer();
+    }
+
+    public function testMethodGetconfigurationGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConfiguration');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getConfiguration();
+    }
+
+    public function testMethodGetconnectionGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getConnection');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getConnection();
+    }
+
+    public function testMethodGetcompositeGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getComposite');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getComposite();
+    }
+
+    public function testMethodGetobjectsGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getObjects');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getObjects();
+    }
+
+    public function testMethodGetstructureGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getStructure');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getStructure();
+    }
+
+    public function testMethodGetsearchGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSearch');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getSearch();
+    }
+
+    public function testMethodGetschemaGetsDelegated()
+    {
+        $this->factory->expects($this->once())
+            ->method('getSchema');
+        $factory = new Horde_Kolab_Server_Factory_Mapped(
+            $this->factory, array()
+        );
+        $factory->getSchema();
+    }
+}
\ No newline at end of file