Complete the Kolabinetorgperson class and add testing.
authorGunnar Wrobel <p@rdus.de>
Mon, 13 Apr 2009 20:56:26 +0000 (22:56 +0200)
committerGunnar Wrobel <p@rdus.de>
Mon, 13 Apr 2009 20:56:26 +0000 (22:56 +0200)
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php
framework/Kolab_Server/test/Horde/Kolab/Server/KolabinetorgpersonTest.php [new file with mode: 0644]

index 886c316..fa6e16d 100644 (file)
  */
 class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Object_Inetorgperson
 {
+    /** Define attributes specific to this object type */
 
-    const ATTRIBUTE_ALIAS         = 'alias';
-    const ATTRIBUTE_DELEGATE      = 'kolabDelegate';
-    const ATTRIBUTE_DELETED       = 'kolabDeleteFlag';
-    const ATTRIBUTE_FBFUTURE      = 'kolabFreeBusyFuture';
-    const ATTRIBUTE_FOLDERTYPE    = 'kolabFolderType';
-    const ATTRIBUTE_HOMESERVER    = 'kolabHomeServer';
-    const ATTRIBUTE_FREEBUSYHOST  = 'kolabFreeBusyServer';
-    const ATTRIBUTE_IMAPHOST      = 'kolabImapServer';
-    const ATTRIBUTE_IPOLICY       = 'kolabInvitationPolicy';
-    const ATTRIBUTE_SALUTATION    = 'kolabSalutation';
-    const ATTRIBUTE_GENDER        = 'gender';
+    /** Alias mail addresses */
+    const ATTRIBUTE_ALIAS = 'alias';
+
+    /** Delegates for this person */
+    const ATTRIBUTE_DELEGATE = 'kolabDelegate';
+
+    /** Marker for a deleted object */
+    const ATTRIBUTE_DELETED = 'kolabDeleteFlag';
+
+    /** How many days of the free/busy future should be calculated in advance? */
+    const ATTRIBUTE_FBFUTURE = 'kolabFreeBusyFuture';
+
+    /** 
+     * The home server of this person. It identifies the correct machine in a
+     * master/slave setup.
+     */
+    const ATTRIBUTE_HOMESERVER = 'kolabHomeServer';
+
+    /** The free/busy server of this person */
+    const ATTRIBUTE_FREEBUSYHOST = 'kolabFreeBusyServer';
+
+    /** The host that keeps the IMAP mail store of this person */
+    const ATTRIBUTE_IMAPHOST = 'kolabImapServer';
+
+    /** The invitation policy for this person */
+    const ATTRIBUTE_IPOLICY = 'kolabInvitationPolicy';
+
+    /** The salutation of this person. */
+    const ATTRIBUTE_SALUTATION = 'kolabSalutation';
+
+    /** Persons gender */
+    const ATTRIBUTE_GENDER = 'gender';
+
+    /** The marital status */
     const ATTRIBUTE_MARITALSTATUS = 'kolabMaritalStatus';
 
+    /** The german tax ID */
+    const ATTRIBUTE_GERMANTAXID = 'germanTaxId';
+
+    /** The country of residence */
+    const ATTRIBUTE_COUNTRY = 'c';
+
+    /** The IMAP quota */
+    const ATTRIBUTE_QUOTA = 'cyrus-userquota';
+
+    /** Allowed recipients for this person */
+    const ATTRIBUTE_ALLOWEDRECIPIENTS = 'kolabAllowSMTPRecipient';
+
+    /** Allowed senders for this person */
+    const ATTRIBUTE_ALLOWEDFROM = 'kolabAllowSMTPFrom';
+
+    /** The date of birth */
+    const ATTRIBUTE_DATEOFBIRTH = 'dateOfBirth';
+
+    /** The place of birth */
+    const ATTRIBUTE_PLACEOFBIRTH = 'birthPlace';
+
+    /** Birth name */
+    const ATTRIBUTE_BIRTHNAME = 'birthName';
+
+    /** Country of citizenship */
+    const ATTRIBUTE_COUNTRYCITIZENSHIP = 'countryOfCitizenship';
+
+    /** Legal form (if the person is a legal entity) */
+    const ATTRIBUTE_LEGALFORM = 'legalForm';
+
+    /** Registered capital (if the person is a legal entity) */
+    const ATTRIBUTE_REGISTEREDCAPITAL = 'tradeRegisterRegisteredCapital';
+
+    /** URI for bylaw (if the person is a legal entity) */
+    const ATTRIBUTE_BYLAWURI = 'bylawURI';
+
+    /** Date of incorporation (if the person is a legal entity) */
+    const ATTRIBUTE_DATEOFINCORPORATION = 'dateOfIncorporation';
+
+    /** Legal representative (if the person is a legal entity) */
+    const ATTRIBUTE_LEGALREPRESENTATIVE = 'legalRepresentative';
+
+    /** Commercial procuration (if the person is a legal entity) */
+    const ATTRIBUTE_COMMERCIALPROCURATION = 'commercialProcuration';
+
+    /** Legal representation policy (if the person is a legal entity) */
+    const ATTRIBUTE_LEGALREPRESENTATIONPOLICY = 'legalRepresentationPolicy';
+
+    /** Acting deputy (if the person is a legal entity) */
+    const ATTRIBUTE_ACTINGDEPUTY = 'actingDeputy';
+
+    /** VAT number (if the person is a legal entity) */
+    const ATTRIBUTE_VATNUMBER = 'VATNumber';
+
+    /** Additional legal relationships (if the person is a legal entity) */
+    const ATTRIBUTE_OTHERLEGAL = 'otherLegalRelationship';
+
+    /** Is this entity in liquidation? (if the person is a legal entity) */
+    const ATTRIBUTE_INLIQUIDATION = 'inLiquidation';
+
+    /** Type of entity as given by the trade register (if the person is a legal entity) */
+    const ATTRIBUTE_TRTYPE = 'tradeRegisterType';
+
+    /** Location of entity as given by the trade register (if the person is a legal entity) */
+    const ATTRIBUTE_TRLOCATION = 'tradeRegisterLocation';
+
+    /** Identifier of entity as given by the trade register (if the person is a legal entity) */
+    const ATTRIBUTE_TRIDENTIFIER = 'tradeRegisterIdentifier';
+
+    /** URI of entity as given by the trade register (if the person is a legal entity) */
+    const ATTRIBUTE_TRURI = 'tradeRegisterURI';
+
+    /** Date of last change in the trade register (if the person is a legal entity) */
+    const ATTRIBUTE_TRLASTCHANGED = 'tradeRegisterLastChangedDate';
+
+    /** Subdomain for this person */
+    const ATTRIBUTE_DC = 'domainComponent';
+
+    /** The specific object class of this object type */
     const OBJECTCLASS_KOLABINETORGPERSON = 'kolabInetOrgPerson';
 
     /**
@@ -50,16 +153,43 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob
      */
     static public $init_attributes = array(
         'defined' => array(
-            self::ATTRIBUTE_IMAPHOST,
+            self::ATTRIBUTE_ALIAS,
+            self::ATTRIBUTE_DELEGATE,
+            self::ATTRIBUTE_DELETED,
+            self::ATTRIBUTE_FBFUTURE,
             self::ATTRIBUTE_HOMESERVER,
             self::ATTRIBUTE_FREEBUSYHOST,
+            self::ATTRIBUTE_IMAPHOST,
+            self::ATTRIBUTE_IPOLICY,
             self::ATTRIBUTE_SALUTATION,
             self::ATTRIBUTE_GENDER,
             self::ATTRIBUTE_MARITALSTATUS,
-            self::ATTRIBUTE_IPOLICY,
-            self::ATTRIBUTE_ALIAS,
-            self::ATTRIBUTE_DELEGATE,
-            self::ATTRIBUTE_FBFUTURE,
+            self::ATTRIBUTE_GERMANTAXID,
+            self::ATTRIBUTE_COUNTRY,
+            self::ATTRIBUTE_QUOTA,
+            self::ATTRIBUTE_ALLOWEDRECIPIENTS,
+            self::ATTRIBUTE_ALLOWEDFROM,
+            self::ATTRIBUTE_DATEOFBIRTH,
+            self::ATTRIBUTE_PLACEOFBIRTH,
+            self::ATTRIBUTE_BIRTHNAME,
+            self::ATTRIBUTE_COUNTRYCITIZENSHIP,
+            self::ATTRIBUTE_LEGALFORM,
+            self::ATTRIBUTE_REGISTEREDCAPITAL,
+            self::ATTRIBUTE_BYLAWURI,
+            self::ATTRIBUTE_DATEOFINCORPORATION,
+            self::ATTRIBUTE_LEGALREPRESENTATIVE,
+            self::ATTRIBUTE_COMMERCIALPROCURATION,
+            self::ATTRIBUTE_LEGALREPRESENTATIONPOLICY,
+            self::ATTRIBUTE_ACTINGDEPUTY,
+            self::ATTRIBUTE_VATNUMBER,
+            self::ATTRIBUTE_OTHERLEGAL,
+            self::ATTRIBUTE_INLIQUIDATION,
+            self::ATTRIBUTE_TRTYPE,
+            self::ATTRIBUTE_TRLOCATION,
+            self::ATTRIBUTE_TRIDENTIFIER,
+            self::ATTRIBUTE_TRURI,
+            self::ATTRIBUTE_TRLASTCHANGED,
+            self::ATTRIBUTE_DC,
         ),
         'locked' => array(
             self::ATTRIBUTE_MAIL,
diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/KolabinetorgpersonTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/KolabinetorgpersonTest.php
new file mode 100644 (file)
index 0000000..843c6a0
--- /dev/null
@@ -0,0 +1,320 @@
+<?php
+/**
+ * Test the kolabInetOrgPerson object.
+ *
+ * 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
+ */
+
+/**
+ * The Autoloader allows us to omit "require/include" statements.
+ */
+require_once 'Horde/Autoloader.php';
+
+/**
+ * Test the kolabInetOrgPerson object.
+ *
+ * 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_KolabinetorgpersonTest extends Horde_Kolab_Test_Server
+{
+    /**
+     * Objects used within this test
+     *
+     * @var array
+     */
+    private $objects = array(
+        /* Default kolabInetOrgPerson */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
+            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GIVENNAME    => 'Frank',
+            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SN           => 'Mustermann',
+            Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
+        ),
+        /* Invalid person (no sn) */
+        array(
+            'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson',
+            Horde_Kolab_Server_Object_Person::ATTRIBUTE_CN           => 'Kolab_Server_OrgPersonTest_123',
+            Horde_Kolab_Server_Object_Person::ATTRIBUTE_USERPASSWORD => 'Kolab_Server_OrgPersonTest_123',
+        ),
+    );
+
+    /**
+     * Provide different server types.
+     *
+     * @return array The different server types.
+     */
+    public function &provideServers()
+    {
+        $servers = array();
+        /**
+         * We always use the test server
+         */
+        $servers[] = array($this->prepareEmptyKolabServer());
+        if (false) {
+            $real = $this->prepareLdapKolabServer();
+            if (!empty($real)) {
+                $servers[] = array($real);
+            }
+        }
+        return $servers;
+    }
+
+    /**
+     * Test ID generation for a person.
+     *
+     * @dataProvider provideServers
+     *
+     * @return NULL
+     */
+    public function testGenerateId($server)
+    {
+        $a = new Horde_Kolab_Server_Object_Kolabinetorgperson($server, null, $this->objects[0]);
+        $this->assertContains('Frank Mustermann',
+                              $a->get(Horde_Kolab_Server_Object_Person::ATTRIBUTE_UID));
+    }
+
+    /**
+     * Test adding an invalid person.
+     *
+     * @dataProvider provideServers
+     * @expectedException Horde_Kolab_Server_Exception
+     *
+     * @return NULL
+     */
+    public function testAddInvalidPerson($server)
+    {
+        $result = $server->add($this->objects[1]);
+    }
+
+    /**
+     * Test handling simple attributes.
+     *
+     * @dataProvider provideServers
+     *
+     * @return NULL
+     */
+    public function testSimpleAttributes($server)
+    {
+        $person = $this->assertAdd($server, $this->objects[0],
+                                   array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+        $this->assertSimpleAttributes($person, $server,
+                                      array(
+                                      ));
+    }
+
+    /**
+     * Test handling easy attributes.
+     *
+     * @dataProvider provideServers
+     *
+     * @return NULL
+     */
+    public function testEasyAttributes($server)
+    {
+        $person = $this->assertAdd($server, $this->objects[0],
+                                   array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => ''));
+        $this->assertEasyAttributes($person, $server,
+                                    array(
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GERMANTAXID => array(
+                                            '01234567890123456789',
+                                            '0',
+                                            '101',
+                                            null,
+                                            'DE',
+                                            array('101', '202'),
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_HOMESERVER => array(
+                                            'a.b.c',
+                                            '',
+                                            'jodeldodel',
+                                            null,
+                                            array('a.example.com', 'b.example.com'),
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_QUOTA => array(
+                                            '100',
+                                            null,
+                                            array('0', '1000'),
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALLOWEDRECIPIENTS => array(
+                                            '-a@example.com', 
+                                            '',
+                                            array('a', 'b'),
+                                            null,
+                                            '0'
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALLOWEDFROM => array(
+                                            '-a@example.com', 
+                                            '',
+                                            array('a', 'b'),
+                                            null,
+                                            '0'
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SALUTATION => array(
+                                            'Herr', 
+                                            'Mrs.',
+                                            null,
+                                            array('Herr', 'Mrs.'),
+                                            '0'
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_GENDER => array(
+                                            '1',
+                                            null,
+                                            '0',
+                                            '2',
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_BIRTHNAME => array(
+                                            'Adam',
+                                            null,
+                                            '',
+                                            '0',
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_PLACEOFBIRTH => array(
+                                            'Jotwede',
+                                            null,
+                                            '',
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_COUNTRY => array(
+                                            'DE',
+                                            'SE',
+                                            null,
+                                            'DE',
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_COUNTRYCITIZENSHIP => array(
+                                            'DE',
+                                            'SE',
+                                            //FIXME: "null" does not work. Why?
+                                            //null,
+                                            'DE',
+                                        ),
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_LEGALFORM => array(
+                                            'GmbH',
+                                            'Freelancer',
+                                            null,
+                                            'Freelancer',
+                                        ),
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_REGISTEREDCAPITAL => array( */
+/*                                             '1212121211', */
+/*                                             '0', */
+/*                                             null, */
+/*                                             '' */
+/*                                         ), */
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_BYLAWURI => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                             '', */
+/*                                         ), */
+
+//FIXME: Alias support
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DATEOFINCORPORATION => array( */
+/*                                             '199911220707Z', */
+/*                                         ), */
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_LEGALREPRESENTATIONPOLICY => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                             '', */
+/*                                         ), */
+
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_VATNUMBER => array(
+                                            'something',
+                                            'somewhere',
+                                            null,
+                                            array('a', 'b'),
+                                        ),
+
+//FIXME: Undefined
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_OTHERLEGAL => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                         ), */
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_INLIQUIDATION => array( */
+/*                                             'TRUE', */
+/*                                             'FALSE', */
+/*                                             null, */
+/*                                             array('TRUE', 'FALSE'), */
+/*                                         ), */
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRTYPE => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                         ), */
+
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRLOCATION => array(
+                                            'something',
+                                            'somewhere',
+                                            null,
+                                            'somewhere',
+                                        ),
+
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRIDENTIFIER => array(
+                                            'something',
+                                            'somewhere',
+                                            null,
+                                            'somewhere',
+                                        ),
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRURI => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                         ), */
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_TRLASTCHANGED => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                         ), */
+
+// FIXME: Undefined in object class
+/*                                         Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_DC => array( */
+/*                                             'something', */
+/*                                             'somewhere', */
+/*                                             null, */
+/*                                             array('a', 'b'), */
+/*                                         ), */
+
+                                        Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_ALIAS => array(
+                                            'something',
+                                            'somewhere',
+                                            null,
+                                            array('a', 'b'),
+                                        ),
+
+                                    )
+        );
+    }
+}