Start fixing the unit tests.
authorGunnar Wrobel <p@rdus.de>
Wed, 9 Sep 2009 09:57:10 +0000 (11:57 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 9 Sep 2009 09:57:10 +0000 (11:57 +0200)
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php
framework/Kolab_FreeBusy/test/Horde/Kolab/FreeBusy/FreeBusyTest.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php

index c5c8c48..c9bf2f1 100644 (file)
@@ -2,19 +2,21 @@
 /**
  * IMAP access for Kolab free/busy.
  *
- * $Horde: framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php,v 1.10 2009/07/14 00:28:33 mrubinsk Exp $
+ * PHP version 5
  *
- * @package Kolab_FreeBusy
+ * @category Kolab
+ * @package  Kolab_FreeBusy
+ * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @author   Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_FreeBusy
  */
 
-/** We need the Kolab Stores library for connecting to the IMAP storage. */
-require_once 'Horde/Kolab/Storage/List.php';
-
-/** We need the Date library for event handling. */
-require_once 'Horde/Date.php';
-
-/** We need the Recurrence library for recurrence handling. */
-require_once 'Horde/Date/Recurrence.php';
+/**
+ * The Autoloader allows us to omit "require/include" statements.
+ */
+require_once 'Horde/Autoloader.php';
 
 /** Event status - Taken from Kronolith*/
 define('KRONOLITH_STATUS_NONE', 0);
@@ -30,18 +32,19 @@ define('KRONOLITH_STATUS_FREE', 4);
  * This class is a merged result from the Kolab free/busy package and
  * the Horde::Kronolith free/busy driver.
  *
- * $Horde: framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php,v 1.10 2009/07/14 00:28:33 mrubinsk Exp $
- *
  * Copyright 2004-2008 Klarälvdalens Datakonsult AB
  * 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.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  *
- * @author  Gunnar Wrobel <wrobel@pardus.de>
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
- * @package Kolab_FreeBusy
+ * @category Kolab
+ * @package  Kolab_FreeBusy
+ * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @author   Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_FreeBusy
  */
 class Horde_Kolab_FreeBusy_Imap {
 
@@ -90,9 +93,15 @@ class Horde_Kolab_FreeBusy_Imap {
     /**
      * Initialize the free/busy IMAP handler.
      */
-    function Horde_Kolab_FreeBusy_Imap()
+    public function __construct()
     {
-        $this->_kolab = &Kolab_List::singleton();
+        //@todo: Make Kolab_FreeBusy session-less again and ensure we get the
+        //driver information as well as the login credentials here.
+        $params = array('driver'   => 'Mock',
+                        'username' => $username,
+                        'password' => $password);
+
+        $this->_kolab = &Horde_Kolab_Storage::singleton('Imap', $params);
     }
 
     /**
index a11495c..0aa7124 100644 (file)
@@ -46,14 +46,11 @@ class Horde_Kolab_FreeBusy_FreeBusyTest extends Horde_Kolab_Test_FreeBusy
         $conf['kolab']['freebusy']['server'] = 'https://fb.example.org/freebusy';
         $conf['fb']['use_acls'] = true;
 
-        $this->assertTrue($world['auth']->authenticate('wrobel@example.org',
-                                                        array('password' => 'none')));
-
-        $folder = $world['storage']->getNewFolder();
-        $folder->setName('Calendar');
-        $this->assertNoError($folder->save(array('type' => 'event',
-                                                 'default' => true)));
+        $this->storage = $this->authenticate($world['auth'],
+                                            'wrobel@example.org',
+                                            'none');
 
+        $this->folder = $this->prepareNewFolder($this->storage, 'Calendar', 'event', true);
         $this->server = $world['server'];
         $this->auth = $world['auth'];
     }
@@ -65,10 +62,8 @@ class Horde_Kolab_FreeBusy_FreeBusyTest extends Horde_Kolab_Test_FreeBusy
      */
     public function _addEvent($start)
     {
-        include_once 'Horde/Kolab/Storage.php';
-
-        $folder = Horde_Kolab_Storage::getShare('INBOX/Calendar', 'event');
-        $data   = Horde_Kolab_Storage::getData($folder, 'event', 1);
+        $folder = $this->storage->getShare('INBOX/Calendar', 'event');
+        $data   = $this->storage->getData($folder, 'event', 1);
         $object = array(
             'uid' => 1,
             'summary' => 'test',
@@ -78,9 +73,6 @@ class Horde_Kolab_FreeBusy_FreeBusyTest extends Horde_Kolab_Test_FreeBusy
 
         /* Add the event */
         $result = $data->save($object);
-        if (is_a($result, 'PEAR_Error')) {
-            $this->assertEquals('', $result->getMessage());
-        }
     }
 
     /**
index 7e402ed..a0f1aaf 100644 (file)
@@ -667,7 +667,7 @@ class Horde_Kolab_Storage_Folder
      *
      * @param Kolab_List $list  The handler for the list of folders.
      *
-     * @return Kolab_Data|PEAR_Error  The data handler.
+     * @return Horde_Kolab_Storage_Data The data handler.
      */
     function &getData($object_type = null, $data_version = 1)
     {
@@ -692,7 +692,7 @@ class Horde_Kolab_Storage_Folder
             } else {
                 $type = 'annotation';
             }
-            $data = new Kolab_Data($type, $object_type, $data_version);
+            $data = new Horde_Kolab_Storage_Data($type, $object_type, $data_version);
             $data->setFolder($this);
             $data->synchronize();
             $this->_data[$key] = &$data;