*
* 'version' - The format version.
*
- * @return mixed The newly created concrete Horde_Kolab_Format_XML instance, or
- * a PEAR error.
+ * @return mixed The newly created concrete Horde_Kolab_Format_XML instance
*
* @throws Horde_Exception If the specified driver could not be loaded.
*/
* @param string $object_type The object type that should be handled.
* @param array $params Any additional parameters.
*
- * @return Horde_Kolab_Format_XML|PEAR_Error The newly created concrete
- * Horde_Kolab_Format_XML
- * instance.
+ * @return Horde_Kolab_Format_XML The newly created concrete
+ * Horde_Kolab_Format_XML instance.
+ *
+ * @throws Horde_Exception If the class for the object type could
+ * not be loaded.
*/
public function &factory($object_type = '', $params = null)
{
*
* @param array $children An array of XML nodes.
*
- * @return array|PEAR_Error The data array representing the object.
+ * @return array The data array representing the object.
*
* @throws Horde_Exception If parsing the XML data failed.
*/
protected function _load(&$children)
{
$object = $this->_loadArray($children, $this->_fields_specific);
- if (is_a($object, 'PEAR_Error')) {
- return $object;
- }
$result = array();
foreach ($object['annotation'] as $annotation) {
protected function _load(&$children)
{
$object = $this->_loadArray($children, $this->_fields_specific);
- if (is_a($object, 'PEAR_Error')) {
- return $object;
- }
// Handle name fields
if (isset($object['name'])) {
protected function _load(&$children)
{
$object = $this->_loadArray($children, $this->_fields_specific);
- if (is_a($object, 'PEAR_Error')) {
- return $object;
- }
// Map the display-name of a kolab dist list to horde's lastname attribute
if (isset($object['display-name'])) {
protected function _load(&$children)
{
$object = parent::_load($children);
- if (is_a($object, 'PEAR_Error')) {
- return $object;
- }
// Translate start/end date including full day events
if (strlen($object['start-date']) == 10) {
$object['application'] = $object['categories'];
unset($object['categories']);
} else {
- return PEAR::raiseError('Preferences XML object is missing an application setting.');
+ throw new Horde_Exception('Preferences XML object is missing an application setting.');
}
}
$object['application'] = $object['categories'];
unset($object['categories']);
} else {
- return PEAR::raiseError('Preferences XML object is missing an application setting.');
+ throw new Horde_Exception('Preferences XML object is missing an application setting.');
}
}
protected function _load(&$children)
{
$object = $this->_loadArray($children, $this->_fields_specific);
- if (is_a($object, 'PEAR_Error')) {
- return $object;
- }
$object['desc'] = $object['summary'];
unset($object['summary']);
protected function _load(&$children)
{
$object = $this->_loadArray($children, $this->_fields_specific);
- if (is_a($object, 'PEAR_Error')) {
- return $object;
- }
$object['name'] = $object['summary'];
unset($object['summary']);
'full-name' => 'User Name',
'email' => 'user@example.org');
$xml = $contact->save($object);
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
$expect = file_get_contents(dirname(__FILE__) . '/fixtures/contact_mail.xml');
$this->assertEquals($expect, $xml);
}
'pgp-publickey' => 'PGP Test Key',
'email' => 'user@example.org');
$xml = $contact->save($object);
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
$expect = file_get_contents(dirname(__FILE__) . '/fixtures/contact_pgp.xml');
$this->assertEquals($expect, $xml);
}
$contact = &new Horde_Kolab_Format_XML_contact();
$xml = file_get_contents(dirname(__FILE__) . '/fixtures/contact_category.xml');
$object = $contact->load($xml);
- if (is_a($object, 'PEAR_Error')) {
- $this->assertEquals('', $object->getMessage());
- }
$this->assertContains('Test', $object['categories']);
$prefs = 'some string';
$object = $contact->load($xml);
- if (is_a($object, 'PEAR_Error')) {
- $this->assertEquals('', $object->getMessage());
- }
$this->assertContains('Test', $object['categories']);
}
$xml = file_get_contents(dirname(__FILE__) . '/fixtures/contact_category.xml');
$object = $contact->load($xml);
- if (is_a($object, 'PEAR_Error')) {
- $this->assertEquals('', $object->getMessage());
- }
$this->assertContains('Test', $object['categories']);
$this->assertEquals('Test', $prefs->getValue('categories'));
}
public function testIssue3525()
{
$xml = Horde_Kolab_Format::factory('XML', 'event');
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
// Load XML
$event = file_get_contents(dirname(__FILE__) . '/fixtures/event_umlaut.xml');
$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...');
// Load XML
$event = file_get_contents(dirname(__FILE__) . '/fixtures/event_umlaut_broken.xml');
$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...');
}
$xml = file_get_contents(dirname(__FILE__) . '/fixtures/preferences_read_old.xml');
$object = $preferences->load($xml);
- if (is_a($object, 'PEAR_Error')) {
- $this->assertEquals('', $object->getMessage());
- }
$this->assertContains('test', $object['pref']);
$this->assertEquals('Test', $object['application']);
'pref' => array('test'),
'categories' => 'Test');
$xml = $preferences->save($object);
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
$expect = file_get_contents(dirname(__FILE__) . '/fixtures/preferences_write_old.xml');
$this->assertEquals($expect, $xml);
'pref' => array('test'),
'application' => 'Test');
$xml = $preferences->save($object);
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
$expect = file_get_contents(dirname(__FILE__) . '/fixtures/preferences_write_old.xml');
$this->assertEquals($expect, $xml);
}
public function testBug6388()
{
$xml = Horde_Kolab_Format::factory('XML', 'event');
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
// Load XML
$recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
- // Check that the xml loads fine
- $this->assertFalse(is_a($xml->load($recur), 'PEAR_Error'));
-
// Load XML
$xml = &Horde_Kolab_Format::factory('XML', 'event');
$recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur_fail.xml');
// Check that the xml fails because of a missing interval value
try {
- $this->assertTrue(is_a($xml->load($recur), 'PEAR_Error'));
+ $xml->load($recur);
$this->assertTrue(false);
} catch (Exception $e) {
$this->assertTrue(is_a($e, 'Horde_Exception'));
public function testExceptions()
{
$xml = Horde_Kolab_Format::factory('XML', 'event');
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
// Load XML
$recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
$object = $xml->load($recur);
- if (is_a($object, 'PEAR_Error')) {
- $this->ensureEquals('', $object->getMessage());
- }
$r = &new Horde_Date_Recurrence($object['start-date']);
$r->fromHash($object['recurrence']);
$recur = $xml->save($object);
$object = $xml->load($recur);
- if (is_a($object, 'PEAR_Error')) {
- $this->ensureEquals('', $object->getMessage());
- }
$s = &new Horde_Date_Recurrence($object['start-date']);
$s->fromHash($object['recurrence']);
public function testCompletions()
{
$xml = Horde_Kolab_Format::factory('XML', 'event');
- if (is_a($xml, 'PEAR_Error')) {
- $this->assertEquals('', $xml->getMessage());
- }
$r = &new Horde_Date_Recurrence(0);
$r->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
$object['recurrence'] = $r->toHash();
$recur = $xml->save($object);
$object = $xml->load($recur);
- if (is_a($object, 'PEAR_Error')) {
- $this->ensureEquals('', $object->getMessage());
- }
$s = &new Horde_Date_Recurrence(0);
$s->fromHash($object['recurrence']);