From 2fa0c8fc0f39cdf2f5a1bd7de8afbbb0ee98cbf6 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Mon, 29 Jun 2009 07:31:56 +0200
Subject: [PATCH] Completed testing fixes.
---
.../Kolab_Format/lib/Horde/Kolab/Format/XML.php | 30 ++--
.../lib/Horde/Kolab/Format/XML/Event.php | 2 +-
.../test/Horde/Kolab/Format/ContactTest.php | 4 +-
.../test/Horde/Kolab/Format/EventTest.php | 10 +-
.../test/Horde/Kolab/Format/PreferencesTest.php | 4 +-
.../test/Horde/Kolab/Format/RecurrenceTest.php | 8 +-
.../test/Horde/Kolab/Format/XmlTest.php | 159 +++++++++++----------
7 files changed, 125 insertions(+), 92 deletions(-)
diff --git a/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php b/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php
index 7238ed969..40265129d 100644
--- a/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php
+++ b/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php
@@ -128,8 +128,10 @@ class Horde_Kolab_Format_XML
* The XML document this driver works with.
*
* @var Horde_DOM_Document
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected $_xmldoc = null;
+ public $_xmldoc = null;
/**
* The name of the root element.
@@ -163,8 +165,10 @@ class Horde_Kolab_Format_XML
* Fields for a simple person
*
* @var array
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected $_fields_simple_person = array(
+ public $_fields_simple_person = array(
'type' => self::TYPE_COMPOSITE,
'value' => self::VALUE_MAYBE_MISSING,
'array' => array(
@@ -190,8 +194,10 @@ class Horde_Kolab_Format_XML
* Fields for an attendee
*
* @var array
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected $_fields_attendee = array(
+ public $_fields_attendee = array(
'type' => self::TYPE_MULTIPLE,
'value' => self::VALUE_DEFAULT,
'default' => array(),
@@ -364,7 +370,7 @@ class Horde_Kolab_Format_XML
*/
public function &factory($object_type = '', $params = null)
{
- $object_type = str_replace('-', '', $object_type);
+ $object_type = ucfirst(str_replace('-', '', $object_type));
$class = 'Horde_Kolab_Format_XML_' . $object_type;
if (class_exists($class)) {
@@ -523,8 +529,10 @@ class Horde_Kolab_Format_XML
* string.
*
* @throws Horde_Exception If parsing the XML data failed.
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected function _getXmlData($children, $name, $params)
+ public function _getXmlData($children, $name, $params)
{
$value = null;
$missing = false;
@@ -586,8 +594,10 @@ class Horde_Kolab_Format_XML
* @return Horde_DOM_Node The root node of the document.
*
* @throws Horde_Exception If parsing the XML data failed.
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected function _parseXml(&$xmltext)
+ public function _parseXml(&$xmltext)
{
$params = array(
'xml' => $xmltext,
@@ -646,8 +656,10 @@ class Horde_Kolab_Format_XML
* @param string $xmltext The XML of the message as string.
*
* @return Horde_DOM_Node The root node of the document.
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected function _prepareSave()
+ public function _prepareSave()
{
if ($this->_xmldoc != null) {
$root = $this->_xmldoc->document_element();
@@ -698,8 +710,10 @@ class Horde_Kolab_Format_XML
* @return Horde_DOM_Node The new/updated child node.
*
* @throws Horde_Exception If converting the data to XML failed.
+ *
+ * @todo Make protected (fix the XmlTest for that)
*/
- protected function _updateNode($parent_node, $attributes, $name, $params,
+ public function _updateNode($parent_node, $attributes, $name, $params,
$append = false)
{
$value = null;
diff --git a/framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Event.php b/framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Event.php
index 0ccbb5eff..ab6261d17 100644
--- a/framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Event.php
+++ b/framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Event.php
@@ -126,7 +126,7 @@ class Horde_Kolab_Format_XML_Event extends Horde_Kolab_Format_XML
*
* @throws Horde_Exception If converting the data to XML failed.
*/
- function _save($root, $object)
+ protected function _save($root, $object)
{
// Translate start/end date including full day events
if (!empty($object['_is_all_day'])) {
diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php
index 314333e6d..a1ac2291a 100644
--- a/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php
+++ b/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php
@@ -35,7 +35,7 @@ class Horde_Kolab_Format_XML_contact_dummy extends Horde_Kolab_Format_XML_contac
return $this->_saveDefault($parent_node,
$name,
$value,
- array('type' => HORDE_KOLAB_XML_TYPE_DATETIME));
+ array('type' => self::TYPE_DATETIME));
}
function _saveModificationDate($parent_node, $name, $value, $missing)
@@ -44,7 +44,7 @@ class Horde_Kolab_Format_XML_contact_dummy extends Horde_Kolab_Format_XML_contac
return $this->_saveDefault($parent_node,
$name,
0,
- array('type' => HORDE_KOLAB_XML_TYPE_DATETIME));
+ array('type' => self::TYPE_DATETIME));
}
}
diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php
index cd71b7b9c..03ddb8dd1 100644
--- a/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php
+++ b/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php
@@ -52,17 +52,17 @@ class Horde_Kolab_Format_EventTest extends PHPUnit_Framework_TestCase
// Load XML
$event = file_get_contents(dirname(__FILE__) . '/fixtures/event_umlaut.xml');
- $result = $xml->load($event);
+ $result = $xml->load($event);
// Check that the xml loads fine
$this->assertFalse(is_a($result, 'PEAR_Error'));
- $this->assertEquals(mb_convert_encoding($result['body'], 'UTF-8', 'ISO-8859-1'), '...übbe...');
+ $this->assertEquals(mb_convert_encoding($result['body'], 'UTF-8', 'ISO-8859-1'), '...übbe...');
// Load XML
$event = file_get_contents(dirname(__FILE__) . '/fixtures/event_umlaut_broken.xml');
- $result = $xml->load($event);
+ $result = $xml->load($event);
// Check that the xml loads fine
$this->assertFalse(is_a($result, 'PEAR_Error'));
- //FIXME: Why does Kolab Format return ISO-8859-1? UTF-8 would seem more appropriate
- $this->assertEquals(mb_convert_encoding($result['body'], 'UTF-8', 'ISO-8859-1'), '...übbe...');
+ //FIXME: Why does Kolab Format return ISO-8859-1? UTF-8 would seem more appropriate
+ $this->assertEquals(mb_convert_encoding($result['body'], 'UTF-8', 'ISO-8859-1'), '...übbe...');
}
}
diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php
index 17583ff39..c3c6b94b9 100644
--- a/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php
+++ b/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php
@@ -29,7 +29,7 @@ class Horde_Kolab_Format_XML_hprefs_dummy extends Horde_Kolab_Format_XML_hprefs
return $this->_saveDefault($parent_node,
$name,
$value,
- array('type' => HORDE_KOLAB_XML_TYPE_DATETIME));
+ array('type' => self::TYPE_DATETIME));
}
function _saveModificationDate($parent_node, $name, $value, $missing)
@@ -38,7 +38,7 @@ class Horde_Kolab_Format_XML_hprefs_dummy extends Horde_Kolab_Format_XML_hprefs
return $this->_saveDefault($parent_node,
$name,
0,
- array('type' => HORDE_KOLAB_XML_TYPE_DATETIME));
+ array('type' => self::TYPE_DATETIME));
}
}
diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php
index eb2ccfd4e..c2db3d8a9 100644
--- a/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php
+++ b/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php
@@ -69,7 +69,12 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
$recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur_fail.xml');
// Check that the xml fails because of a missing interval value
- $this->assertTrue(is_a($xml->load($recur), 'PEAR_Error'));
+ try {
+ $this->assertTrue(is_a($xml->load($recur), 'PEAR_Error'));
+ $this->assertTrue(false);
+ } catch (Exception $e) {
+ $this->assertTrue(is_a($e, 'Horde_Exception'));
+ }
}
@@ -135,7 +140,6 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
$object = array('uid' => 0, 'start-date' => 0, 'end-date' => 60);
$object['recurrence'] = $r->toHash();
$recur = $xml->save($object);
-
$object = $xml->load($recur);
if (is_a($object, 'PEAR_Error')) {
$this->ensureEquals('', $object->getMessage());
diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php
index f3f914838..4c0ce729b 100644
--- a/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php
+++ b/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php
@@ -17,35 +17,6 @@ require_once 'Horde/Kolab/Format.php';
require_once 'Horde/Kolab/Format/XML.php';
/**
- * A dummy XML type
- *
- * $Horde: framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php,v 1.5 2009/01/06 17:49:23 jan Exp $
- *
- * Copyright 2007-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.
- *
- * @author Gunnar Wrobel