Added a file test driver.
authorGunnar Wrobel <p@rdus.de>
Tue, 3 Mar 2009 19:37:37 +0000 (19:37 +0000)
committerGunnar Wrobel <p@rdus.de>
Tue, 3 Mar 2009 19:37:37 +0000 (19:37 +0000)
framework/Kolab_Server/lib/Horde/Kolab/Server/file.php [new file with mode: 0644]
framework/Kolab_Server/lib/Horde/Kolab/Server/test.php
framework/Kolab_Server/lib/Horde/Kolab/Test/Server.php
framework/Kolab_Server/package.xml
framework/Kolab_Server/test/Horde/Kolab/Server/AllTests.php
framework/Kolab_Server/test/Horde/Kolab/Server/GroupHandlingTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/UserTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php

diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/file.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/file.php
new file mode 100644 (file)
index 0000000..0d5f0f7
--- /dev/null
@@ -0,0 +1,113 @@
+<?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;
+
+    /**
+     * Construct a new Horde_Kolab_Server object.
+     *
+     * @param array $params Parameter array.
+     */
+    public function __construct($params = array())
+    {
+        if (isset($params['file'])) {
+            $this->_file = $params['file'];
+        } else {
+            $this->_file = Horde::getTempFile('Horde_Kolab_Server', false);
+        }
+        parent::__construct($params);
+    }
+
+    
+    /**
+     * Load the current state of the database.
+     *
+     * @return NULL
+     */
+    protected function load()
+    {
+        $raw_data = file_get_contents($this->file);
+        $data = @unserialize($raw_data);
+        if ($data !== false) {
+            $this->_data = $data;
+        } else {
+            $error = error_get_last();
+            Horde::logMessage(sprintf('Horde_Kolab_Server_file failed to read the database from %s. Error was: %s',
+                                      $this->_file, $error['message']), __FILE__,
+                              __LINE__, PEAR_LOG_WARNING);
+            $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->_file, $this->_data);
+        if ($result === false) {
+            $error = error_get_last();
+            Horde::logMessage(sprintf('Horde_Kolab_Server_file failed to store the database in %s. Error was: %s',
+                                      $this->_file,  $error['message']), __FILE__,
+                              __LINE__, PEAR_LOG_WARNING);
+        }
+    }
+
+    /**
+     * Cleans the current state of the database.
+     *
+     * @return NULL
+     */
+    public function clean()
+    {
+        unlink($this->_file);
+       $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->_file;
+    }
+}
index 6553543..5eebcf2 100644 (file)
@@ -29,6 +29,13 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
 {
 
     /**
+     * The current database data.
+     *
+     * @var array
+     */
+    private $_data;
+
+    /**
      * Array holding the current result set.
      *
      * @var array
@@ -77,16 +84,53 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
      */
     public function __construct($params = array())
     {
+        $this->load();
         if (isset($params['data'])) {
-            $GLOBALS['KOLAB_SERVER_TEST_DATA'] = $params['data'];
+            $this->_data = $params['data'];
         } else {
-            if (!isset($GLOBALS['KOLAB_SERVER_TEST_DATA'])) {
-                $GLOBALS['KOLAB_SERVER_TEST_DATA'] = array();
+            if (!isset($this->_data)) {
+               $this->_data  = array();
             }
         }
+        $this->store();
         parent::__construct($params);
     }
 
+    
+    /**
+     * Load the current state of the database.
+     *
+     * @return NULL
+     */
+    protected function load()
+    {
+        $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;
+    }
+
+    /**
+     * 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.
      *
@@ -116,7 +160,7 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
         }
 
         if (!empty($dn)) {
-            if (!isset($GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn])) {
+            if (!isset($this->_data[$dn])) {
                 throw new Horde_Kolab_Server_Exception('User does not exist!');
             }
 
@@ -292,7 +336,7 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
     {
         if (isset($filter['log'])) {
             $result = array();
-            foreach ($GLOBALS['KOLAB_SERVER_TEST_DATA'] as $element) {
+            foreach ($this->_data as $element) {
                 if (isset($element['data'][$filter['att']])) {
                     switch ($filter['log']) {
                     case '=':
@@ -354,16 +398,16 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
                         $dns[] = $entry['dn'];
                     }
                 }
-                $all_dns = array_keys($GLOBALS['KOLAB_SERVER_TEST_DATA']);
+                $all_dns = array_keys($this->_data);
                 $diff    = array_diff($all_dns, $dns);
 
                 $result = array();
                 foreach ($diff as $dn) {
                     if (empty($attributes)) {
-                        $result[] = $GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn];
+                        $result[] = $this->_data[$dn];
                     } else {
-                        $selection = $GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn];
-                        foreach ($GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn]['data']
+                        $selection = $this->_data[$dn];
+                        foreach ($this->_data[$dn]['data']
                                  as $attr => $value) {
                             if (!in_array($attr, $attributes)) {
                                 unset($selection['data'][$attr]);
@@ -395,15 +439,15 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
             $result = $this->bind();
         }
 
-        if (!isset($GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn])) {
+        if (!isset($this->_data[$dn])) {
             throw new Horde_Kolab_Server_Exception(sprintf("LDAP Error: No such object: %s: No such object",
                                                            $dn));
         }
         if (empty($attrs)) {
-            return $GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn]['data'];
+            return $this->_data[$dn]['data'];
         } else {
             $result = array();
-            $data   = $GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn]['data'];
+            $data   = $this->_data[$dn]['data'];
 
             foreach ($attrs as $attr) {
                 if (isset($data[$attr])) {
@@ -437,10 +481,11 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
             $ldap_data[$key] = $val;
         }
 
-        $GLOBALS['KOLAB_SERVER_TEST_DATA'][$dn] = array(
+        $this->_data[$dn] = array(
             'dn' => $dn,
             'data' => $ldap_data
         );
+        $this->store();
     }
 
     /**
index d46c5d2..5fb1e98 100644 (file)
@@ -268,20 +268,23 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      *
      * @return Horde_Kolab_Server The empty server.
      */
-    public function &prepareEmptyKolabServer()
+    public function &prepareEmptyKolabServer($type = 'test')
     {
         global $conf;
 
-        $GLOBALS['KOLAB_SERVER_TEST_DATA'] = array();
-
         /** Prepare a Kolab test server */
-        $conf['kolab']['server']['driver']           = 'test';
+        $conf['kolab']['server']['driver']           = $type;
         $conf['kolab']['server']['params']['basedn'] = 'dc=example,dc=org';
+        $conf['kolab']['server']['params']['data']   = array();
+
+        if ($type == 'file') {
+            $conf['kolab']['server']['params']['file'] = Horde::getTempFile('fileTest');
+        }
 
         $server = Horde_Kolab_Server::singleton();
 
         /** Ensure we don't use a connection from older tests */
-        $server->unbind();
+        $server->clean();
 
         /** Clean the server data */
         return $server;
@@ -292,9 +295,9 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      *
      * @return Horde_Kolab_Server The empty server.
      */
-    public function &prepareBasicServer()
+    public function &prepareBasicServer($type = 'test')
     {
-        $server = $this->prepareEmptyKolabServer();
+        $server = $this->prepareEmptyKolabServer($type);
         $this->prepareUsers($server);
         return $server;
     }
@@ -539,6 +542,11 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
         );
     }
 
+    public function provideServerTypes()
+    {
+        return array(array('test'), array('file'));
+    }
+
     /** FIXME: Prefix the stuff bewlow with provide...() */
 
     public function validUsers()
index 81df488..b4356b6 100644 (file)
@@ -49,6 +49,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
       <file name="Server.php" role="php" />
       <dir name="Server">
        <file name="Exception.php" role="php" />
+       <file name="file.php" role="php" />
        <file name="ldap.php" role="php" />
        <file name="Object.php" role="php" />
        <file name="test.php" role="php" />
@@ -129,6 +130,7 @@ 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/Test/Server.php" as="Horde/Kolab/Test/Server.php" />
    <install name="lib/Horde/Kolab/Server/Exception.php" as="Horde/Kolab/Server/Exception.php" />
+   <install name="lib/Horde/Kolab/Server/file.php" as="Horde/Kolab/Server/file.php" />
    <install name="lib/Horde/Kolab/Server/ldap.php" as="Horde/Kolab/Server/ldap.php" />
    <install name="lib/Horde/Kolab/Server/test.php" as="Horde/Kolab/Server/test.php" />
    <install name="lib/Horde/Kolab/Server/Object.php" as="Horde/Kolab/Server/Object.php" />
index 3f61139..2a4d7b8 100644 (file)
@@ -2,7 +2,6 @@
 /**
  * All tests for the Horde_Kolab_Server:: package.
  *
- *
  * PHP version 5
  *
  * @category Kolab
@@ -27,7 +26,6 @@ require_once 'Horde/Autoloader.php';
 /**
  * Combine the tests for this package.
  *
- *
  * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you
index d5e7d3c..2690081 100644 (file)
@@ -182,6 +182,8 @@ class Horde_Kolab_Server_GroupHandlingTest extends Horde_Kolab_Test_Server
      * Test modifying a group mail address.
      *
      * @scenario
+     *
+     * @return NULL
      */
     public function conflictBetweenGroupMailAndUserMailIsNotAllowed()
     {
@@ -194,6 +196,8 @@ class Horde_Kolab_Server_GroupHandlingTest extends Horde_Kolab_Test_Server
 
     /**
      * @scenario
+     *
+     * @return NULL
      */
     public function conflictBetweenUserMailAndGroupMailIsNotAllowed()
     {
index 759b6f3..fff75e2 100644 (file)
@@ -72,7 +72,7 @@ class Horde_Kolab_Server_UserTest extends Horde_Kolab_Test_Server
      */
     public function testAddInvalidUser()
     {
-        $user = $this->provideInvalidUserWithoutGivenName();
+        $user   = $this->provideInvalidUserWithoutGivenName();
         $result = $this->server->add($user);
     }
 
index 8aa6aa3..a6d07a3 100644 (file)
@@ -34,28 +34,22 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
 {
 
     /**
-     * Set up testing.
-     *
-     * @return NULL
-     */
-    protected function setUp()
-    {
-        $this->ldap = &$this->prepareBasicServer();
-    }
-
-    /**
      * Test search base.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testSearchBase()
+    public function testSearchBase($type)
     {
-        $result = $this->ldap->search('(objectClass=top)', array('objectClass'));
+        $server = &$this->prepareBasicServer($type);
+
+        $result = $server->search('(objectClass=top)', array('objectClass'));
         $this->assertEquals(13, count($result));
       
-        $result = $this->ldap->search('(objectClass=top)',
-                                      array('objectClass'),
-                                      'cn=internal,dc=example,dc=org');
+        $result = $server->search('(objectClass=top)',
+                                  array('objectClass'),
+                                  'cn=internal,dc=example,dc=org');
         $this->assertNoError($result);
         $this->assertEquals(4, count($result));
     }
@@ -63,14 +57,18 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test sorting.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testSorting()
+    public function testSorting($type)
     {
-/*         $result = $this->ldap->search('(mail=*)', array('mail')); */
+        $server = &$this->prepareBasicServer($type);
+
+/*         $result = $server->search('(mail=*)', array('mail')); */
 /*         $this->assertNoError($result); */
 /*         $this->assertEquals(5, count($result)); */
-/*         $this->ldap->sort($result, 'mail'); */
+/*         $server->sort($result, 'mail'); */
 /*         foreach ($result as $object) { */
 /*             if (isset($object['data']['dn'])) { */
 /*                 switch ($object['data']['dn']) { */
@@ -88,10 +86,14 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test listing objects.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testListObjects()
+    public function testListObjects($type)
     {
+        $server = &$this->prepareBasicServer($type);
+
         $filter     = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
         $attributes = array(
             KOLAB_ATTR_SN,
@@ -102,16 +104,16 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
         );
 
         $sort   = KOLAB_ATTR_SN;
-        $result = $this->ldap->search($filter);
+        $result = $server->search($filter);
         $this->assertNoError($result);
         $this->assertEquals(2, count($result));
 
-        $result = $this->ldap->listObjects('Horde_Kolab_Server_Object_user');
+        $result = $server->listObjects('Horde_Kolab_Server_Object_user');
         $this->assertNoError($result);
         $this->assertEquals(2, count($result));
         $this->assertEquals('Horde_Kolab_Server_Object_user', get_class($result[0]));
 
-        $result = $this->ldap->listObjects('Horde_Kolab_Server_Object_sharedfolder');
+        $result = $server->listObjects('Horde_Kolab_Server_Object_sharedfolder');
         $this->assertNoError($result);
         $this->assertEquals(1, count($result));
         $this->assertEquals('Horde_Kolab_Server_Object_sharedfolder', get_class($result[0]));
@@ -120,24 +122,28 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test handling of object classes.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testGetObjectClasses()
+    public function testGetObjectClasses($type)
     {
-        $classes = $this->ldap->getObjectClasses('cn=Gunnar Wrobel,dc=example,dc=org');
+        $server = &$this->prepareBasicServer($type);
+
+        $classes = $server->getObjectClasses('cn=Gunnar Wrobel,dc=example,dc=org');
         $this->assertNoError($classes);
         $this->assertContains('top', $classes);
         $this->assertContains('kolabinetorgperson', $classes);
         $this->assertContains('hordeperson', $classes);
 
         try {
-            $classes = $this->ldap->getObjectClasses('cn=DOES NOT EXIST,dc=example,dc=org');
+            $classes = $server->getObjectClasses('cn=DOES NOT EXIST,dc=example,dc=org');
         } catch (Horde_Kolab_Server_Exception $classes) {
         }
         $this->assertError($classes,
                            'LDAP Error: No such object: cn=DOES NOT EXIST,dc=example,dc=org: No such object');
 
-        $classes = $this->ldap->getObjectClasses('cn=The Administrator,dc=example,dc=org');
+        $classes = $server->getObjectClasses('cn=The Administrator,dc=example,dc=org');
         $this->assertNoError($classes);
         $this->assertContains('kolabinetorgperson', $classes);
     }
@@ -145,35 +151,39 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test handling of object types.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testDetermineType()
+    public function testDetermineType($type)
     {
-        $type = $this->ldap->determineType('cn=empty.group@example.org,dc=example,dc=org');
+        $server = &$this->prepareBasicServer($type);
+
+        $type = $server->determineType('cn=empty.group@example.org,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_group', $type);
 
-        $type = $this->ldap->determineType('cn=shared@example.org,dc=example,dc=org');
+        $type = $server->determineType('cn=shared@example.org,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_sharedfolder', $type);
 
-        $type = $this->ldap->determineType('cn=The Administrator,dc=example,dc=org');
+        $type = $server->determineType('cn=The Administrator,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_administrator', $type);
 
-        $type = $this->ldap->determineType('cn=Main Tainer,dc=example,dc=org');
+        $type = $server->determineType('cn=Main Tainer,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_maintainer', $type);
 
-        $type = $this->ldap->determineType('cn=Domain Maintainer,dc=example,dc=org');
+        $type = $server->determineType('cn=Domain Maintainer,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_domainmaintainer', $type);
 
-        $type = $this->ldap->determineType('cn=Test Address,cn=external,dc=example,dc=org');
+        $type = $server->determineType('cn=Test Address,cn=external,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_address', $type);
 
-        $type = $this->ldap->determineType('cn=Gunnar Wrobel,dc=example,dc=org');
+        $type = $server->determineType('cn=Gunnar Wrobel,dc=example,dc=org');
         $this->assertNoError($type);
         $this->assertEquals('Horde_Kolab_Server_Object_user', $type);
     }
@@ -181,18 +191,22 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test retrieving a primary mail for a mail or id.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testMailForIdOrMail()
+    public function testMailForIdOrMail($type)
     {
-        $mail = $this->ldap->mailForIdOrMail('wrobel');
+        $server = &$this->prepareBasicServer($type);
+
+        $mail = $server->mailForIdOrMail('wrobel');
         $this->assertEquals('wrobel@example.org', $mail);
 
-        $mail = $this->ldap->mailForIdOrMail('wrobel@example.org');
+        $mail = $server->mailForIdOrMail('wrobel@example.org');
         $this->assertNoError($mail);
         $this->assertEquals('wrobel@example.org', $mail);
 
-        $mail = $this->ldap->mailForIdOrMail('DOES NOT EXIST');
+        $mail = $server->mailForIdOrMail('DOES NOT EXIST');
         $this->assertNoError($mail);
         $this->assertSame(false, $mail);
     }
@@ -200,19 +214,23 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test retrieving a UID for a mail or id.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testUidForIdOrMail()
+    public function testUidForIdOrMail($type)
     {
-        $uid = $this->ldap->uidForIdOrMail('wrobel');
+        $server = &$this->prepareBasicServer($type);
+
+        $uid = $server->uidForIdOrMail('wrobel');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMail('wrobel@example.org');
+        $uid = $server->uidForIdOrMail('wrobel@example.org');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMail('DOES NOT EXIST');
+        $uid = $server->uidForIdOrMail('DOES NOT EXIST');
         $this->assertNoError($uid);
         $this->assertSame(false, $uid);
     }
@@ -220,23 +238,27 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test retrieving a UID for a mail or id.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testUidForMailOrIdOrAlias()
+    public function testUidForMailOrIdOrAlias($type)
     {
-        $uid = $this->ldap->uidForIdOrMailOrAlias('g.wrobel@example.org');
+        $server = &$this->prepareBasicServer($type);
+
+        $uid = $server->uidForIdOrMailOrAlias('g.wrobel@example.org');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMailOrAlias('wrobel@example.org');
+        $uid = $server->uidForIdOrMailOrAlias('wrobel@example.org');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMailOrAlias('wrobel');
+        $uid = $server->uidForIdOrMailOrAlias('wrobel');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMailOrAlias('DOES NOT EXIST');
+        $uid = $server->uidForIdOrMailOrAlias('DOES NOT EXIST');
         $this->assertNoError($uid);
         $this->assertSame(false, $uid);
     }
@@ -244,13 +266,17 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test retrieving all addresses for a mail or id.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testAddrsForIdOrMail()
+    public function testAddrsForIdOrMail($type)
     {
-        $addrs = $this->ldap->addrsForIdOrMail('wrobel');
+        $server = &$this->prepareBasicServer($type);
+
+        $addrs = $server->addrsForIdOrMail('wrobel');
 
-        $testuser = $this->ldap->fetch('cn=Test Test,dc=example,dc=org');
+        $testuser = $server->fetch('cn=Test Test,dc=example,dc=org');
         $this->assertNoError($testuser);
         $this->assertContains('wrobel@example.org',
                               $testuser->get(KOLAB_ATTR_KOLABDELEGATE, false));
@@ -262,7 +288,7 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
         $this->assertContains('g.wrobel@example.org', $addrs);
         $this->assertContains('gunnar@example.org', $addrs);
 
-        $addrs = $this->ldap->addrsForIdOrMail('test@example.org');
+        $addrs = $server->addrsForIdOrMail('test@example.org');
         $this->assertNoError($addrs);
         $this->assertContains('test@example.org', $addrs);
         $this->assertContains('t.test@example.org', $addrs);
@@ -271,23 +297,27 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test retrieving a UID for a primary mail.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testUidForMailAddress()
+    public function testUidForMailAddress($type)
     {
-        $uid = $this->ldap->uidForIdOrMailOrAlias('wrobel@example.org');
+        $server = &$this->prepareBasicServer($type);
+
+        $uid = $server->uidForIdOrMailOrAlias('wrobel@example.org');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMailOrAlias('test@example.org');
+        $uid = $server->uidForIdOrMailOrAlias('test@example.org');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Test Test,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMailOrAlias('gunnar@example.org');
+        $uid = $server->uidForIdOrMailOrAlias('gunnar@example.org');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
 
-        $uid = $this->ldap->uidForIdOrMailOrAlias('wrobel');
+        $uid = $server->uidForIdOrMailOrAlias('wrobel');
         $this->assertNoError($uid);
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org', $uid);
     }
@@ -295,11 +325,15 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test retrieving a UID for an attribute.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testUidForAttr()
+    public function testUidForAttr($type)
     {
-        $uid = $this->ldap->uidForSearch(array('AND' => array(array('field' => 'alias',
+        $server = &$this->prepareBasicServer($type);
+
+        $uid = $server->uidForSearch(array('AND' => array(array('field' => 'alias',
                                                                     'op' => '=',
                                                                     'test' => 'g.wrobel@example.org'))));
         $this->assertNoError($uid);
@@ -309,24 +343,28 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test group membership testing.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testMemberOfGroupAddress()
+    public function testMemberOfGroupAddress($type)
     {
-        $uid = $this->ldap->uidForIdOrMailOrAlias('g.wrobel@example.org');
+        $server = &$this->prepareBasicServer($type);
+
+        $uid = $server->uidForIdOrMailOrAlias('g.wrobel@example.org');
         $this->assertNoError($uid);
-        $member = $this->ldap->memberOfGroupAddress($uid, 'group@example.org');
+        $member = $server->memberOfGroupAddress($uid, 'group@example.org');
         $this->assertNoError($member);
         $this->assertTrue($member);
 
-        $member = $this->ldap->memberOfGroupAddress(
-            $this->ldap->uidForIdOrMailOrAlias('test@example.org'),
+        $member = $server->memberOfGroupAddress(
+            $server->uidForIdOrMailOrAlias('test@example.org'),
             'group@example.org');
         $this->assertNoError($member);
         $this->assertTrue($member);
 
-        $member = $this->ldap->memberOfGroupAddress(
-            $this->ldap->uidForIdOrMailOrAlias('somebody@example.org'),
+        $member = $server->memberOfGroupAddress(
+            $server->uidForIdOrMailOrAlias('somebody@example.org'),
             'group@example.org');
         $this->assertNoError($member);
         $this->assertFalse($member);
@@ -335,45 +373,49 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
     /**
      * Test group fetching.
      *
+     * @dataProvider provideServerTypes
+     *
      * @return NULL
      */
-    public function testGetGroups()
+    public function testGetGroups($type)
     {
+        $server = &$this->prepareBasicServer($type);
+
         $filter = '(&(objectClass=kolabGroupOfNames)(member='
             . Horde_LDAP::quote('cn=The Administrator,dc=example,dc=org') . '))';
-        $result = $this->ldap->search($filter, array());
+        $result = $server->search($filter, array());
         $this->assertNoError($result);
         $this->assertTrue(!empty($result));
 
-/*         $entry = $this->ldap->_firstEntry($result); */
+/*         $entry = $server->_firstEntry($result); */
 /*         $this->assertNoError($entry); */
 /*         $this->assertTrue(!empty($entry)); */
 
-/*         $uid = $this->ldap->_getDn($entry); */
+/*         $uid = $server->_getDn($entry); */
 /*         $this->assertNoError($uid); */
 /*         $this->assertTrue(!empty($uid)); */
 
-/*         $entry = $this->ldap->_nextEntry($entry); */
+/*         $entry = $server->_nextEntry($entry); */
 /*         $this->assertNoError($entry); */
 /*         $this->assertTrue(empty($entry)); */
 
-/*         $entries = $this->ldap->_getDns($result); */
+/*         $entries = $server->_getDns($result); */
 /*         $this->assertNoError($entries); */
 /*         $this->assertTrue(!empty($entries)); */
 
-        $groups = $this->ldap->getGroups('cn=The Administrator,dc=example,dc=org');
+        $groups = $server->getGroups('cn=The Administrator,dc=example,dc=org');
         $this->assertNoError($groups);
         $this->assertTrue(!empty($groups));
 
-        $groups = $this->ldap->getGroups($this->ldap->uidForIdOrMailOrAlias('g.wrobel@example.org'));
+        $groups = $server->getGroups($server->uidForIdOrMailOrAlias('g.wrobel@example.org'));
         $this->assertNoError($groups);
         $this->assertContains('cn=group@example.org,dc=example,dc=org', $groups);
 
-        $groups = $this->ldap->getGroups($this->ldap->uidForIdOrMailOrAlias('test@example.org'));
+        $groups = $server->getGroups($server->uidForIdOrMailOrAlias('test@example.org'));
         $this->assertNoError($groups);
         $this->assertContains('cn=group@example.org,dc=example,dc=org', $groups);
 
-        $groups = $this->ldap->getGroups('nobody');
+        $groups = $server->getGroups('nobody');
         $this->assertNoError($groups);
         $this->assertTrue(empty($groups));