From: Gunnar Wrobel
Date: Wed, 8 Apr 2009 16:53:50 +0000 (+0200) Subject: Fix testing so that it runs through again. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=60236d19975b5e003a5738413f9ccbcd3a61385e;p=horde.git Fix testing so that it runs through again. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Test/Server.php b/framework/Kolab_Server/lib/Horde/Kolab/Test/Server.php index 9093432f6..36bad3ff5 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Test/Server.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Test/Server.php @@ -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( diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/GroupHandlingTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/GroupHandlingTest.php index 086b3f66c..fe926f77c 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/GroupHandlingTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/GroupHandlingTest.php @@ -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', diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/GroupTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/GroupTest.php index 31cfdaa21..e6b724361 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/GroupTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/GroupTest.php @@ -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']); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/ObjectTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/ObjectTest.php index 4e5d13488..a839ed28f 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/ObjectTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/ObjectTest.php @@ -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())); + } } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php index 3fe0fb2c9..8275b7b5e 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php @@ -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. diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/UserTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/UserTest.php index dd450749c..432108d9b 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/UserTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/UserTest.php @@ -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',