Fix testing so that it runs through again.
authorGunnar Wrobel <p@rdus.de>
Wed, 8 Apr 2009 16:53:50 +0000 (18:53 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 8 Apr 2009 16:54:20 +0000 (18:54 +0200)
framework/Kolab_Server/lib/Horde/Kolab/Test/Server.php
framework/Kolab_Server/test/Horde/Kolab/Server/GroupHandlingTest.php
framework/Kolab_Server/test/Horde/Kolab/Server/GroupTest.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/UserTest.php

index 9093432..36bad3f 100644 (file)
@@ -334,9 +334,9 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
         $this->assertNoError($result);
         $result = $server->add($this->provideBasicDomainMaintainer());
         $this->assertNoError($result);
-        $result = $server->add($this->provideBasicGroupOne());
+        $result = $server->add($this->provideGroupWithoutMembers());
         $this->assertNoError($result);
-        $result = $server->add($this->provideBasicGroupTwo());
+        $result = $server->add($this->provideBasicGroupOne());
         $this->assertNoError($result);
         $result = $server->add($this->provideBasicMaintainer());
         $this->assertNoError($result);
@@ -406,10 +406,11 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicAddress()
     {
-        return array('givenName' => 'Test',
-                     'sn' => 'Address',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_Address',
-                     'mail' => 'address@example.org');
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Address',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_GIVENNAME    => 'Test',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SN           => 'Address',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_MAIL         => 'address@example.org',
+        );
     }
 
     /**
@@ -419,11 +420,12 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicAdmin()
     {
-        return array('sn' => 'Administrator',
-                     'givenName' => 'The',
-                     'uid' => 'admin',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_Administrator',
-                     'userPassword' => 'none');
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Administrator',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_GIVENNAME    => 'The',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SN           => 'Administrator',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_SID          => 'admin',
+                     Horde_Kolab_Server_Object_Kolab_Administrator::ATTRIBUTE_USERPASSWORD => 'none',
+        );
     }
 
     /**
@@ -433,11 +435,11 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicMaintainer()
     {
-        return array('sn' => 'Tainer',
-                     'givenName' => 'Main',
-                     'uid' => 'maintainer',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_Maintainer',
-                     'userPassword' => 'none',
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Maintainer',
+                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_GIVENNAME    => 'Main',
+                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_SN           => 'Tainer',
+                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_SID          => 'maintainer',
+                     Horde_Kolab_Server_Object_Kolab_Maintainer::ATTRIBUTE_USERPASSWORD => 'none',
         );
     }
 
@@ -448,12 +450,13 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicDomainMaintainer()
     {
-        return array('sn' => 'Maintainer',
-                     'givenName' => 'Domain',
-                     'uid' => 'domainmaintainer',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_Domainmaintainer',
-                     'userPassword' => 'none',
-                     'domain' => array('example.com'),
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Domainmaintainer',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_GIVENNAME    => 'Domain',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_SN           => 'Maintainer',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_SID          => 'domainmaintainer',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_USERPASSWORD => 'none',
+                     Horde_Kolab_Server_Object_Kolab_Domainmaintainer::ATTRIBUTE_DOMAIN       => array('example.com'),
+
         );
     }
 
@@ -464,9 +467,57 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicSharedFolder()
     {
-        return array('cn' => 'shared@example.org',
-                     'kolabHomeServer' => 'example.org',
-                     'type' => 'Horde_Kolab_Server_Object_Kolabsharedfolder');
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabsharedfolder',
+                     Horde_Kolab_Server_Object_Kolabsharedfolder::ATTRIBUTE_CN         => 'shared@example.org',
+                     Horde_Kolab_Server_Object_Kolabsharedfolder::ATTRIBUTE_HOMESERVER => 'example.org',
+        );
+    }
+
+    /**
+     * Provide a set of valid groups.
+     *
+     * @return array The array of groups.
+     */
+    public function groupLists()
+    {
+        $groups = $this->validGroups();
+        $result = array();
+        foreach ($groups as $group) {
+            $result[] = array($group);
+        }
+        return $result;
+    }
+
+    /**
+     * Provide a set of valid groups.
+     *
+     * @return array The array of groups.
+     */
+    public function validGroups()
+    {
+        return array(
+            array(
+                $this->provideGroupWithoutMembers(),
+            ),
+            array(
+                $this->provideBasicGroupOne(),
+            ),
+            array(
+                $this->provideBasicGroupTwo(),
+            ),
+        );
+    }
+
+    /**
+     * Return a test group.
+     *
+     * @return array The test group.
+     */
+    public function provideGroupWithoutMembers()
+    {
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'empty.group@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array());
     }
 
     /**
@@ -476,8 +527,11 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicGroupOne()
     {
-        return array('mail' => 'empty.group@example.org',
-                     'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames');
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'group@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Test Test,dc=example,dc=org',
+                                                                                         'cn=Gunnar Wrobel,dc=example,dc=org')
+        );
     }
 
     /**
@@ -487,18 +541,19 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
      */
     public function provideBasicGroupTwo()
     {
-        return array('mail' => 'group@example.org',
-                     'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                     'member' => array('cn=Test Test,dc=example,dc=org',
-                                       'cn=Gunnar Wrobel,dc=example,dc=org'));
+        return array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'group2@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Gunnar Wrobel,dc=example,dc=org')
+        );
     }
 
     public function provideDistributionList()
     {
-        return array('mail' => 'distlist@example.org',
-                     'type' => 'Horde_Kolab_Server_Object_Kolab_Distlist',
-                     'member' => array('cn=Test Test,dc=example,dc=org',
-                                       'cn=Gunnar Wrobel,dc=example,dc=org'));
+        return array('type' => 'Horde_Kolab_Server_Object_Kolab_Distlist',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MAIL   => 'distlist@example.org',
+                     Horde_Kolab_Server_Object_Kolab_Distlist::ATTRIBUTE_MEMBER => array('cn=Test Test,dc=example,dc=org',
+                                                                                         'cn=Gunnar Wrobel,dc=example,dc=org')
+        );
     }
 
     public function provideInvalidUserWithoutPassword()
@@ -610,28 +665,6 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
         );
     }
 
-    public function validGroups()
-    {
-        return array(
-            array(
-                $this->validGroupWithoutMembers(),
-            ),
-            array(
-                array('mail' => 'group@example.org',
-                      'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                      'member' => array('cn=Test Test,dc=example,dc=org',
-                                        'cn=Gunnar Wrobel,dc=example,dc=org')
-                ),
-            ),
-            array(
-                array('mail' => 'group2@example.org',
-                      'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                      'member' => array('cn=Gunnar Wrobel,dc=example,dc=org')
-                ),
-            ),
-        );
-    }
-
     public function validSharedFolders()
     {
         return array(
@@ -641,12 +674,6 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
         );
     }
 
-    public function validGroupWithoutMembers()
-    {
-        return array('mail' => 'empty.group@example.org',
-                     'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-        );
-    }
 
     public function userLists()
     {
@@ -654,39 +681,6 @@ class Horde_Kolab_Test_Server extends PHPUnit_Extensions_Story_TestCase
         );
     }
 
-    public function groupLists()
-    {
-        return array(
-            array(
-                array(
-                    array('type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                          'mail' => 'empty.group@example.org',
-                    ),
-                )
-            ),
-            array(
-                array(
-                    array('mail' => 'empty.group@example.org',
-                          'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                    ),
-                ),
-                array(
-                    array('mail' => 'group@example.org',
-                          'type' => 'Horde_Kolab_Server_Object_Kolabgroupnames',
-                          'member' => array('cn=Test Test,dc=example,dc=org',
-                                            'cn=Gunnar Wrobel,dc=example,dc=org')
-                    ),
-                ),
-                array(
-                    array('mail' => 'group2@example.org',
-                          'type' => 'Horde_Kolab_Server_Object_Kolabgroupofnames',
-                          'member' => array('cn=Gunnar Wrobel,dc=example,dc=org')
-                    ),
-                ),
-            )
-        );
-    }
-
     public function userListByLetter()
     {
         return array(
index 086b3f6..fe926f7 100644 (file)
@@ -87,7 +87,7 @@ class Horde_Kolab_Server_GroupHandlingTest extends Horde_Kolab_Test_Server
             ->and('retrieving a hash list with all objects of type',
                   'Horde_Kolab_Server_Object_Kolabgroupofnames')
             ->then('the provided list and the result list match with regard to these attributes',
-                   'mail', 'id', $group_list);
+                   'mail', 'cn', $group_list);
     }
 
     /**
@@ -155,7 +155,7 @@ class Horde_Kolab_Server_GroupHandlingTest extends Horde_Kolab_Test_Server
     public function creatingGroupWithoutVisibilityCreatesVisibleGroup()
     {
         $this->given('an empty Kolab server')
-            ->when('adding an object', $this->validGroupWithoutMembers())
+            ->when('adding an object', $this->provideGroupWithoutMembers())
             ->and('retrieving a hash list with all objects of type',
                   'Horde_Kolab_Server_Object_Kolabgroupofnames')
             ->then('each element in the result list has an attribute set to a given value',
index 31cfdaa..e6b7243 100644 (file)
@@ -101,7 +101,7 @@ class Horde_Kolab_Server_GroupTest extends Horde_Kolab_Test_Server
         $this->assertContains('id', array_keys($hash));
         $this->assertContains('visible', array_keys($hash));
         $this->assertEquals('empty.group@example.org', $hash['mail']);
-        $this->assertEquals('empty.group@example.org', $hash['id']);
+        $this->assertEquals('cn=empty.group@example.org', $hash['id']);
         $this->assertTrue($hash['visible']);
     }
 
index 4e5d134..a839ed2 100644 (file)
@@ -145,6 +145,12 @@ class Horde_Kolab_Server_ObjectTest extends Horde_Kolab_Test_Server
  */
 class DummyDB
 {
-
-
+    public function getAttributes()
+    {
+        return array(array(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN => array()),
+              array(
+                  'derived'  => array(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_FN),
+                  'locked'   => array(),
+                  'required' => array()));
+    }
 }
index 3fe0fb2..8275b7b 100644 (file)
@@ -126,6 +126,19 @@ class Horde_Kolab_Server_None extends Horde_Kolab_Server
     }
 
     /**
+     * Stub for saving object data.
+     *
+     * @param string $uid   The object to retrieve.
+     * @param string $attrs Restrict to these attributes.
+     *
+     * @return array|PEAR_Error An array of attributes.
+     */
+    public function save($uid, $data, $exists = false)
+    {
+        throw new Horde_Kolab_Server_Exception('Not implemented!');
+    }
+
+    /**
      * Determine the type of a Kolab object.
      *
      * @param string $uid The UID of the object to examine.
index dd45074..432108d 100644 (file)
@@ -55,7 +55,7 @@ class Horde_Kolab_Server_UserTest extends Horde_Kolab_Test_Server
     public function testGenerateId()
     {
         $users = $this->validUsers();
-        $this->assertEquals('Gunnar Wrobel',
+        $this->assertEquals('cn=Gunnar Wrobel',
                             Horde_Kolab_Server_Object_Kolab_User::generateId($users[0][0]));
 
         $this->assertEquals('cn=Gunnar Wrobel,dc=example,dc=org',