Update and complete testing to the recent changes.
authorGunnar Wrobel <p@rdus.de>
Wed, 18 Mar 2009 21:50:14 +0000 (21:50 +0000)
committerGunnar Wrobel <p@rdus.de>
Wed, 18 Mar 2009 21:50:14 +0000 (21:50 +0000)
framework/Kolab_Server/test/Horde/Kolab/Server/AddingObjectsTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/ObjectTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/UserHandlingTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/UserTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/testTest.php

index 77469c1..abc6e21 100644 (file)
@@ -48,23 +48,4 @@ class Horde_Kolab_Server_AddingObjectsTest extends Horde_Kolab_Test_Server
             ->when('adding a Kolab server object', $user)
             ->then('the result should be an object of type', 'Horde_Kolab_Server_Object_user');
     }
-
-    /**
-     * Test adding invalid users.
-     *
-     * @param array  $user  The user to add.
-     * @param string $error The error to expect.
-     *
-     * @scenario
-     * @dataProvider provideInvalidUsers
-     *
-     * @return NULL
-     */
-    public function addingInvalidUser($user, $error)
-    {
-        $this->given('an empty Kolab server')
-            ->when('adding an invalid Kolab server object', $user)
-            ->then('the result should indicate an error with', $error);
-    }
-
 }
index e227af8..c2d70da 100644 (file)
@@ -86,7 +86,7 @@ class Horde_Kolab_Server_ObjectTest extends Horde_Kolab_Test_Server
     public function testConstructDn($dn, $data, $expect)
     {
         $ko  = &new Horde_Kolab_Server_Object($this->_dummydb, $dn, $data);
-        $ndn = $ko->get(KOLAB_ATTR_UID);
+        $ndn = $ko->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID);
         $this->assertNoError($ndn);
         $this->assertEquals($expect, $ndn);
     }
@@ -122,7 +122,7 @@ class Horde_Kolab_Server_ObjectTest extends Horde_Kolab_Test_Server
         $ko = &Horde_Kolab_Server_Object::factory('Horde_Kolab_Server_Object_user',
                                                   null, $this->_dummydb, $data);
         $this->assertNoError($ko);
-        $ndn = $ko->get(KOLAB_ATTR_FN);
+        $ndn = $ko->get(Horde_Kolab_Server_Object::ATTRIBUTE_FN);
         $this->assertNoError($ndn);
         $this->assertEquals($expect, $ndn);
     }
index 92be8e7..974eaef 100644 (file)
@@ -33,6 +33,34 @@ require_once 'Horde/Autoloader.php';
 class Horde_Kolab_Server_ServerTest extends PHPUnit_Framework_TestCase
 {
     /**
+     * The generating a uid for an object.
+     *
+     * @return NULL
+     */
+    public function testGenerateUid()
+    {
+        $ks = &Horde_Kolab_Server::factory('none');
+        $uid = $ks->generateUid('Horde_Kolab_Server_Object', array());
+        $this->assertEquals($uid, '');
+    }
+
+    /**
+     * Test creating the server object.
+     *
+     * @return NULL
+     */
+    public function testCreation()
+    {
+        try {
+            Horde_Kolab_Server::factory('dummy');
+            $this->assertFail('No error!');
+        } catch (Horde_Kolab_Server_Exception $e) {
+            $this->assertEquals($e->getMessage(),
+                                'Server type definition "Horde_Kolab_Server_dummy" missing.');
+        }
+    }
+
+    /**
      * The base class provides no abilities for reading data. So it
      * should mainly return error. But it should be capable of
      * returning a dummy Kolab user object.
@@ -44,6 +72,10 @@ class Horde_Kolab_Server_ServerTest extends PHPUnit_Framework_TestCase
         $ks   = &Horde_Kolab_Server::factory('none');
         $user = $ks->fetch('test');
         $this->assertEquals('Horde_Kolab_Server_Object_user', get_class($user));
+
+        $ks   = &Horde_Kolab_Server::factory('none', array('uid' => 'test'));
+        $user = $ks->fetch();
+        $this->assertEquals('Horde_Kolab_Server_Object_user', get_class($user));
     }
 
     /**
@@ -53,13 +85,47 @@ class Horde_Kolab_Server_ServerTest extends PHPUnit_Framework_TestCase
      *
      * @return NULL
      */
-    public function testDnFor()
+    public function testUidFor()
     {
         $ks = &Horde_Kolab_Server::factory('none');
+        $dn = $ks->uidForId('test');
+        $this->assertFalse($dn);
+        $dn = $ks->uidForMail('test');
+        $this->assertFalse($dn);
+        $dn = $ks->uidForAlias('test');
+        $this->assertFalse($dn);
         $dn = $ks->uidForIdOrMail('test');
-        $this->assertEquals(false, $dn);
+        $this->assertFalse($dn);
+        $dn = $ks->uidForMailOrAlias('test');
+        $this->assertFalse($dn);
         $dn = $ks->uidForIdOrMailOrAlias('test');
         $this->assertFalse($dn);
+        $dn = $ks->mailForIdOrMail('test');
+        $this->assertFalse($dn);
+        $dn = $ks->addrsForIdOrMail('test');
+        $this->assertEquals($dn, array());
+        $dn = $ks->gidForMail('test');
+        $this->assertFalse($dn);
+        $dn = $ks->memberOfGroupAddress('test', 'test@example.org');
+        $this->assertFalse($dn);
+        $dn = $ks->getGroups('test');
+        $this->assertEquals($dn, array());
+    }
+
+    /**
+     * Test listing objects.
+     *
+     * @return NULL
+     */
+    public function testList()
+    {
+        $ks   = &Horde_Kolab_Server::factory('none');
+        $hash = $ks->listHash('Horde_Kolab_Server_Object');
+        $this->assertEquals($hash, array());
+
+        $ks   = &Horde_Kolab_Server::factory('none', array('whatever'));
+        $hash = $ks->listHash('Horde_Kolab_Server_Object');
+        $this->assertEquals($hash, array());
     }
 
 }
@@ -147,14 +213,14 @@ class Horde_Kolab_Server_none extends Horde_Kolab_Server
      * search criteria.
      *
      * @param array $criteria The search parameters as array.
-     * @param int   $restrict A KOLAB_SERVER_RESULT_* result restriction.
+     * @param int   $restrict A Horde_Kolab_Server::RESULT_* result restriction.
      *
      * @return boolean|string|array The UID(s) or false if there was no result.
      *
      * @throws Horde_Kolab_Server_Exception
      */
     public function uidForSearch($criteria,
-                                 $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                                 $restrict = Horde_Kolab_Server::RESULT_SINGLE)
     {
         /* In the default class we just return false */
         return false;
@@ -165,14 +231,14 @@ class Horde_Kolab_Server_none extends Horde_Kolab_Server
      * search criteria
      *
      * @param array $criteria The search parameters as array.
-     * @param int   $restrict A KOLAB_SERVER_RESULT_* result restriction.
+     * @param int   $restrict A Horde_Kolab_Server::RESULT_* result restriction.
      *
      * @return boolean|string|array The GID(s) or false if there was no result.
      *
      * @throws Horde_Kolab_Server_Exception
      */
     public function gidForSearch($criteria,
-                                 $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                                 $restrict = Horde_Kolab_Server::RESULT_SINGLE)
     {
         /* In the default class we just return false */
         return false;
@@ -183,14 +249,14 @@ class Horde_Kolab_Server_none extends Horde_Kolab_Server
      *
      * @param array $criteria The search parameters as array.
      * @param array $attrs    The attributes to retrieve.
-     * @param int   $restrict A KOLAB_SERVER_RESULT_* result restriction.
+     * @param int   $restrict A Horde_Kolab_Server::RESULT_* result restriction.
      *
      * @return array The results.
      *
      * @throws Horde_Kolab_Server_Exception
      */
     public function attrsForSearch($criteria, $attrs,
-                                   $restrict = KOLAB_SERVER_RESULT_SINGLE)
+                                   $restrict = Horde_Kolab_Server::RESULT_SINGLE)
     {
         /* In the default class we just return an empty array */
         return array();
index ab1cd46..c28744f 100644 (file)
@@ -208,46 +208,6 @@ class Horde_Kolab_Server_UserHandlingTest extends Horde_Kolab_Test_Server
     /**
      * @scenario
      */
-    public function creatingUserWithoutGivenName()
-    {
-        $this->given('an empty Kolab server')
-            ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutGivenName())
-            ->then('the result should indicate an error with', 'Either the last name or the given name is missing!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithoutLastName()
-    {
-        $this->given('an empty Kolab server')
-            ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutLastName())
-            ->then('the result should indicate an error with', 'Either the last name or the given name is missing!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithoutPassword()
-    {
-        $this->given('an empty Kolab server')
-            ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutPassword())
-            ->then('the result should indicate an error with', 'The value for "userPassword" is missing!');
-    }
-
-    /**
-     * @scenario
-     */
-    public function creatingUserWithoutPrimaryMail()
-    {
-        $this->given('an empty Kolab server')
-            ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutMail())
-            ->then('the result should indicate an error with', 'The value for "mail" is missing!');
-    }
-
-    /**
-     * @scenario
-     */
     public function creatingUserWithoutTypeCreatesStandardUser()
     {
         $this->given('an empty Kolab server')
index 71593bc..6f2e0e1 100644 (file)
@@ -85,7 +85,7 @@ class Horde_Kolab_Server_UserTest extends Horde_Kolab_Test_Server
     {
         $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
         $this->assertEquals('Horde_Kolab_Server_Object_user', get_class($user));
-        $this->assertEquals('Gunnar Wrobel', $user->get(KOLAB_ATTR_FNLN));
+        $this->assertEquals('Gunnar Wrobel', $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_FNLN));
     }
 
     /**
@@ -104,7 +104,7 @@ class Horde_Kolab_Server_UserTest extends Horde_Kolab_Test_Server
         $this->assertEquals('home.example.org', $imap);
 
         $user = $this->server->fetch('cn=Gunnar Wrobel,dc=example,dc=org');
-        $attr = $user->get(KOLAB_ATTR_FREEBUSYHOST);
+        $attr = $user->get(Horde_Kolab_Server_Object::ATTRIBUTE_FREEBUSYHOST);
         if (is_a($attr, 'PEAR_Error')) {
             $this->assertEquals('', $attr->getMessage());
         }
index 7d81c52..fdb83ac 100644 (file)
@@ -96,14 +96,14 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
 
         $filter     = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
         $attributes = array(
-            KOLAB_ATTR_SN,
-            KOLAB_ATTR_CN,
-            KOLAB_ATTR_UID,
-            KOLAB_ATTR_MAIL,
-            KOLAB_ATTR_DELETED,
+            Horde_Kolab_Server_Object::ATTRIBUTE_SN,
+            Horde_Kolab_Server_Object::ATTRIBUTE_CN,
+            Horde_Kolab_Server_Object::ATTRIBUTE_UID,
+            Horde_Kolab_Server_Object::ATTRIBUTE_MAIL,
+            Horde_Kolab_Server_Object::ATTRIBUTE_DELETED,
         );
 
-        $sort   = KOLAB_ATTR_SN;
+        $sort   = Horde_Kolab_Server_Object::ATTRIBUTE_SN;
         $result = $server->search($filter);
         $this->assertNoError($result);
         $this->assertEquals(2, count($result));
@@ -279,7 +279,7 @@ class Horde_Kolab_Server_testTest extends Horde_Kolab_Test_Server
         $testuser = $server->fetch('cn=Test Test,dc=example,dc=org');
         $this->assertNoError($testuser);
         $this->assertContains('wrobel@example.org',
-                              $testuser->get(KOLAB_ATTR_KOLABDELEGATE, false));
+                              $testuser->get(Horde_Kolab_Server_Object::ATTRIBUTE_DELEGATE, false));
 
         $this->assertNoError($addrs);
         $this->assertContains('wrobel@example.org', $addrs);