From 894e6213b470e9daf28475577a2f1f75d32d3448 Mon Sep 17 00:00:00 2001
From: Gunnar Wrobel
Date: Wed, 9 Sep 2009 11:57:10 +0200
Subject: [PATCH] Start fixing the unit tests.
---
.../lib/Horde/Kolab/FreeBusy/Imap.php | 45 +++++++++++++---------
.../test/Horde/Kolab/FreeBusy/FreeBusyTest.php | 20 +++-------
.../lib/Horde/Kolab/Storage/Folder.php | 4 +-
3 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php
index c5c8c480b..c9bf2f182 100644
--- a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php
+++ b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php
@@ -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
+ * @author Steffen Hansen
+ * @author Gunnar Wrobel
+ * @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
- * @author Chuck Hagenbuch
- * @author Steffen Hansen
- * @package Kolab_FreeBusy
+ * @category Kolab
+ * @package Kolab_FreeBusy
+ * @author Chuck Hagenbuch
+ * @author Steffen Hansen
+ * @author Gunnar Wrobel
+ * @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);
}
/**
diff --git a/framework/Kolab_FreeBusy/test/Horde/Kolab/FreeBusy/FreeBusyTest.php b/framework/Kolab_FreeBusy/test/Horde/Kolab/FreeBusy/FreeBusyTest.php
index a11495c62..0aa7124a7 100644
--- a/framework/Kolab_FreeBusy/test/Horde/Kolab/FreeBusy/FreeBusyTest.php
+++ b/framework/Kolab_FreeBusy/test/Horde/Kolab/FreeBusy/FreeBusyTest.php
@@ -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());
- }
}
/**
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
index 7e402ed38..a0f1aaff7 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
@@ -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;
--
2.11.0