*
* PHP version 5
*
- * @category Kolab
- * @package Kolab_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
*/
/**
/**
* Prepare the test setup.
*/
-require_once 'Horde/Test/AllTests.php';
+require_once dirname(__FILE__) . '/Autoload.php';
/**
- * @package Horde_Kolab_Format
+ * Combine the tests for this package.
+ *
+ * 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.
+ *
+ * @category Kolab
+ * @package Kolab_Format
* @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
*/
class Horde_Kolab_Format_AllTests extends Horde_Test_AllTests
{
--- /dev/null
+<?php
+/**
+ * Setup autoloading for the tests.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+if (!spl_autoload_functions()) {
+ spl_autoload_register(
+ create_function(
+ '$class',
+ '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);
+ $err_mask = E_ALL ^ E_WARNING;
+ $oldErrorReporting = error_reporting($err_mask);
+ include "$filename.php";
+ error_reporting($oldErrorReporting);'
+ )
+ );
+}
+
+/** Catch strict standards */
+error_reporting(E_ALL | E_STRICT);
+
+/** Load the basic test definition */
+//require_once dirname(__FILE__) . '/TestCase.php';
+++ /dev/null
-<?php
-/**
- * Test the contact XML format.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * Test the contact XML format.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_ContactTest extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- Horde_Nls::setCharset('utf-8');
- }
-
- /**
- * Test storing single mail addresses.
- *
- * @return NULL
- */
- public function testSingleEmail()
- {
- $contact = new Horde_Kolab_Format_Xml_contact_Dummy();
- $object = array('uid' => '1',
- 'full-name' => 'User Name',
- 'email' => 'user@example.org');
- $xml = $contact->save($object);
- $expect = file_get_contents(dirname(__FILE__)
- . '/fixtures/contact_mail.xml');
- $this->assertEquals($expect, $xml);
- }
-
- /**
- * Test storing PGP public keys.
- *
- * @return NULL
- */
- public function testPGP()
- {
- $contact = new Horde_Kolab_Format_Xml_contact_Dummy();
- $object = array('uid' => '1',
- 'full-name' => 'User Name',
- 'pgp-publickey' => 'PGP Test Key',
- 'email' => 'user@example.org');
- $xml = $contact->save($object);
- $expect = file_get_contents(dirname(__FILE__)
- . '/fixtures/contact_pgp.xml');
- $this->assertEquals($expect, $xml);
- }
-
- /**
- * Test loading a contact with a category.
- *
- * @return NULL
- */
- public function testCategories()
- {
- global $prefs;
-
- $contact = new Horde_Kolab_Format_Xml_contact();
- $xml = file_get_contents(dirname(__FILE__)
- . '/fixtures/contact_category.xml');
- $object = $contact->load($xml);
- $this->assertContains('Test', $object['categories']);
-
- $prefs = 'some string';
- $object = $contact->load($xml);
- $this->assertContains('Test', $object['categories']);
- }
-
- /**
- * Test loading a contact with a category with preferences.
- *
- * @return NULL
- */
- public function testCategoriesWithPrefs()
- {
- if (class_exists('Horde_Prefs')) {
- /* Monkey patch to allw the value to be set. */
- $prefs->_prefs['categories'] = array('v' => '');
-
- $contact = new Horde_Kolab_Format_Xml_contact();
- $xml = file_get_contents(dirname(__FILE__)
- . '/fixtures/contact_category.xml');
- $object = $contact->load($xml);
- $this->assertContains('Test', $object['categories']);
- }
- }
-
-
-}
-
-/**
- * A dummy registry.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class DummyRegistry
-{
- /**
- * Returns the application context.
- *
- * @return string Always "horde".
- */
- function get()
- {
- return 'horde';
- }
-}
-
-/**
- * A modification to the original contact handler. This prevents unpredictable
- * date entries.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_Xml_Contact_Dummy extends Horde_Kolab_Format_Xml_Contact
-{
- /**
- * Save the object creation date.
- *
- * @param DOMNode $parent_node The parent node to attach the child
- * to.
- * @param string $name The name of the node.
- * @param mixed $value The value to store.
- * @param boolean $missing Has the value been missing?
- *
- * @return DOMNode The new child node.
- */
- function _saveCreationDate($parent_node, $name, $value, $missing)
- {
- // Only create the creation date if it has not been set before
- if ($missing) {
- $value = 0;
- }
- return $this->_saveDefault($parent_node,
- $name,
- $value,
- array('type' => self::TYPE_DATETIME));
- }
-
- /**
- * Save the object modification date.
- *
- * @param DOMNode $parent_node The parent node to attach
- * the child to.
- * @param string $name The name of the node.
- * @param mixed $value The value to store.
- * @param boolean $missing Has the value been missing?
- *
- * @return DOMNode The new child node.
- */
- function _saveModificationDate($parent_node, $name, $value, $missing)
- {
- // Always store now as modification date
- return $this->_saveDefault($parent_node,
- $name,
- 0,
- array('type' => self::TYPE_DATETIME));
- }
-}
+++ /dev/null
-<?php
-/**
- * Test event handling within the Kolab format implementation.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * Test event handling.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_EventTest extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- Horde_Nls::setCharset('utf-8');
- Horde_String::setDefaultCharset('iso-8859-1');
- }
-
-
- /**
- * Test for https://www.intevation.de/roundup/kolab/issue3525
- *
- * @return NULL
- */
- public function testIssue3525()
- {
- $xml = Horde_Kolab_Format::factory('XML', 'event');
-
- // Load XML
- $event = file_get_contents(dirname(__FILE__)
- . '/fixtures/event_umlaut.xml');
- $result = $xml->load($event);
-
- // Check that the xml loads fine
- $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);
-
- /**
- * 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...');
- }
-}
--- /dev/null
+<?php
+/**
+ * Test the contact XML format.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test the contact XML format.
+ *
+ * Copyright 2007-2010 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_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Integration_ContactTest
+extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Set up testing.
+ *
+ * @return NULL
+ */
+ protected function setUp()
+ {
+ Horde_Nls::setCharset('utf-8');
+ }
+
+ /**
+ * Test storing single mail addresses.
+ *
+ * @return NULL
+ */
+ public function testSingleEmail()
+ {
+ $contact = new Horde_Kolab_Format_Xml_contact_Dummy();
+ $object = array('uid' => '1',
+ 'full-name' => 'User Name',
+ 'email' => 'user@example.org');
+ $xml = $contact->save($object);
+ $expect = file_get_contents(dirname(__FILE__)
+ . '/fixtures/contact_mail.xml');
+ $this->assertEquals($expect, $xml);
+ }
+
+ /**
+ * Test storing PGP public keys.
+ *
+ * @return NULL
+ */
+ public function testPGP()
+ {
+ $contact = new Horde_Kolab_Format_Xml_contact_Dummy();
+ $object = array('uid' => '1',
+ 'full-name' => 'User Name',
+ 'pgp-publickey' => 'PGP Test Key',
+ 'email' => 'user@example.org');
+ $xml = $contact->save($object);
+ $expect = file_get_contents(dirname(__FILE__)
+ . '/fixtures/contact_pgp.xml');
+ $this->assertEquals($expect, $xml);
+ }
+
+ /**
+ * Test loading a contact with a category.
+ *
+ * @return NULL
+ */
+ public function testCategories()
+ {
+ global $prefs;
+
+ $contact = new Horde_Kolab_Format_Xml_contact();
+ $xml = file_get_contents(dirname(__FILE__)
+ . '/fixtures/contact_category.xml');
+ $object = $contact->load($xml);
+ $this->assertContains('Test', $object['categories']);
+
+ $prefs = 'some string';
+ $object = $contact->load($xml);
+ $this->assertContains('Test', $object['categories']);
+ }
+
+ /**
+ * Test loading a contact with a category with preferences.
+ *
+ * @return NULL
+ */
+ public function testCategoriesWithPrefs()
+ {
+ if (class_exists('Horde_Prefs')) {
+ /* Monkey patch to allw the value to be set. */
+ $prefs->_prefs['categories'] = array('v' => '');
+
+ $contact = new Horde_Kolab_Format_Xml_contact();
+ $xml = file_get_contents(dirname(__FILE__)
+ . '/fixtures/contact_category.xml');
+ $object = $contact->load($xml);
+ $this->assertContains('Test', $object['categories']);
+ }
+ }
+
+
+}
+
+/**
+ * A dummy registry.
+ *
+ * Copyright 2007-2010 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_Format
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class DummyRegistry
+{
+ /**
+ * Returns the application context.
+ *
+ * @return string Always "horde".
+ */
+ function get()
+ {
+ return 'horde';
+ }
+}
+
+/**
+ * A modification to the original contact handler. This prevents unpredictable
+ * date entries.
+ *
+ * Copyright 2007-2010 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_Format
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Xml_Contact_Dummy extends Horde_Kolab_Format_Xml_Contact
+{
+ /**
+ * Save the object creation date.
+ *
+ * @param DOMNode $parent_node The parent node to attach the child
+ * to.
+ * @param string $name The name of the node.
+ * @param mixed $value The value to store.
+ * @param boolean $missing Has the value been missing?
+ *
+ * @return DOMNode The new child node.
+ */
+ function _saveCreationDate($parent_node, $name, $value, $missing)
+ {
+ // Only create the creation date if it has not been set before
+ if ($missing) {
+ $value = 0;
+ }
+ return $this->_saveDefault($parent_node,
+ $name,
+ $value,
+ array('type' => self::TYPE_DATETIME));
+ }
+
+ /**
+ * Save the object modification date.
+ *
+ * @param DOMNode $parent_node The parent node to attach
+ * the child to.
+ * @param string $name The name of the node.
+ * @param mixed $value The value to store.
+ * @param boolean $missing Has the value been missing?
+ *
+ * @return DOMNode The new child node.
+ */
+ function _saveModificationDate($parent_node, $name, $value, $missing)
+ {
+ // Always store now as modification date
+ return $this->_saveDefault($parent_node,
+ $name,
+ 0,
+ array('type' => self::TYPE_DATETIME));
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test event handling within the Kolab format implementation.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test event handling.
+ *
+ * Copyright 2007-2010 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_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Integration_EventTest
+extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Set up testing.
+ *
+ * @return NULL
+ */
+ protected function setUp()
+ {
+ Horde_Nls::setCharset('utf-8');
+ Horde_String::setDefaultCharset('iso-8859-1');
+ }
+
+
+ /**
+ * Test for https://www.intevation.de/roundup/kolab/issue3525
+ *
+ * @return NULL
+ */
+ public function testIssue3525()
+ {
+ $xml = Horde_Kolab_Format::factory('XML', 'event');
+
+ // Load XML
+ $event = file_get_contents(dirname(__FILE__)
+ . '/fixtures/event_umlaut.xml');
+ $result = $xml->load($event);
+
+ // Check that the xml loads fine
+ $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);
+
+ /**
+ * 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...');
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test Kolab Format MIME attributes
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test Kolab Format MIME attributes
+ *
+ * Copyright 2007-2010 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_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Integration_MimeAttrTest
+extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Set up testing.
+ *
+ * @return NULL
+ */
+ protected function setUp()
+ {
+ Horde_Nls::setCharset('utf-8');
+ }
+
+ /**
+ * Test retrieving the document name.
+ *
+ * @return NULL
+ */
+ public function testGetName()
+ {
+ $format = Horde_Kolab_Format::factory('XML', 'contact');
+ $this->assertEquals('kolab.xml', $format->getName());
+ }
+
+ /**
+ * Test retrieving the document mime type.
+ *
+ * @return NULL
+ */
+ public function testMimeType()
+ {
+ $format = Horde_Kolab_Format::factory('XML', 'contact');
+ $this->assertEquals('application/x-vnd.kolab.contact',
+ $format->getMimeType());
+ }
+
+ /**
+ * Test retrieving the document disposition.
+ *
+ * @return NULL
+ */
+ public function testGetDisposition()
+ {
+ $format = Horde_Kolab_Format::factory('XML', 'contact');
+ $this->assertEquals('attachment', $format->getDisposition());
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the preferences XML format.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * The Autoloader allows us to omit "require/include" statements.
+ */
+require_once 'Horde/Autoloader.php';
+
+
+/**
+ * Test the preferences XML format.
+ *
+ * Copyright 2007-2010 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_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Integration_PreferencesTest
+extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Set up testing.
+ *
+ * @return NULL
+ */
+ protected function setUp()
+ {
+ Horde_Nls::setCharset('utf-8');
+ }
+
+ /**
+ * Test preferences format conversion.
+ *
+ * @return NULL
+ */
+ public function testConversionFromOld()
+ {
+ $preferences = new Horde_Kolab_Format_Xml_hprefs_Dummy();
+
+ $xml = file_get_contents(dirname(__FILE__)
+ . '/fixtures/preferences_read_old.xml');
+ $object = $preferences->load($xml);
+ $this->assertContains('test', $object['pref']);
+ $this->assertEquals('Test', $object['application']);
+
+ $object = array('uid' => 1,
+ 'pref' => array('test'),
+ 'categories' => 'Test');
+ $xml = $preferences->save($object);
+ $expect = file_get_contents(dirname(__FILE__)
+ . '/fixtures/preferences_write_old.xml');
+ $this->assertEquals($expect, $xml);
+
+ $object = array('uid' => 1,
+ 'pref' => array('test'),
+ 'application' => 'Test');
+ $xml = $preferences->save($object);
+ $expect = file_get_contents(dirname(__FILE__)
+ . '/fixtures/preferences_write_old.xml');
+ $this->assertEquals($expect, $xml);
+ }
+}
+
+
+/**
+ * A modification to the original preferences handler. This prevents
+ * unpredictable date entries.
+ *
+ * Copyright 2007-2010 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_Format
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Xml_Hprefs_Dummy extends Horde_Kolab_Format_Xml_Hprefs
+{
+ /**
+ * Save the object creation date.
+ *
+ * @param DOMNode $parent_node The parent node to attach the child
+ * to.
+ * @param string $name The name of the node.
+ * @param mixed $value The value to store.
+ * @param boolean $missing Has the value been missing?
+ *
+ * @return DOMNode The new child node.
+ */
+ function _saveCreationDate($parent_node, $name, $value, $missing)
+ {
+ // Only create the creation date if it has not been set before
+ if ($missing) {
+ $value = 0;
+ }
+ return $this->_saveDefault($parent_node,
+ $name,
+ $value,
+ array('type' => self::TYPE_DATETIME));
+ }
+
+ /**
+ * Save the object modification date.
+ *
+ * @param DOMNode $parent_node The parent node to attach
+ * the child to.
+ * @param string $name The name of the node.
+ * @param mixed $value The value to store.
+ * @param boolean $missing Has the value been missing?
+ *
+ * @return DOMNode The new child node.
+ */
+ function _saveModificationDate($parent_node, $name, $value, $missing)
+ {
+ // Always store now as modification date
+ return $this->_saveDefault($parent_node,
+ $name,
+ 0,
+ array('type' => self::TYPE_DATETIME));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test recurrence handling within the Kolab format implementation.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test recurrence handling
+ *
+ * Copyright 2007-2010 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_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Integration_RecurrenceTest
+extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Set up testing.
+ *
+ * @return NULL
+ */
+ protected function setUp()
+ {
+ @include_once 'Horde/Date/Recurrence.php';
+
+ if (!class_exists('Horde_Date_Recurrence')) {
+ $this->markTestSkipped('The Horde_Date_Recurrence class is missing.');
+ }
+
+ Horde_Nls::setCharset('utf-8');
+
+ $this->_oldTimezone = date_default_timezone_get();
+ date_default_timezone_set('Europe/Berlin');
+ }
+
+ public function tearDown()
+ {
+ date_default_timezone_set($this->_oldTimezone);
+ }
+
+ /**
+ * Test for http://bugs.horde.org/ticket/?id=6388
+ *
+ * @return NULL
+ */
+ public function testBug6388()
+ {
+ $xml = Horde_Kolab_Format::factory('XML', 'event');
+
+ // Load XML
+ $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
+
+ // 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 {
+ $xml->load($recur);
+ $this->assertTrue(false);
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceOf Horde_Exception);
+ }
+ }
+
+
+ /**
+ * Test exception handling.
+ *
+ * @return NULL
+ */
+ public function testExceptions()
+ {
+ $xml = Horde_Kolab_Format::factory('XML', 'event');
+
+ // Load XML
+ $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
+
+ $object = $xml->load($recur);
+
+ $r = new Horde_Date_Recurrence($object['start-date']);
+ $r->fromHash($object['recurrence']);
+
+ $this->assertTrue($r->hasRecurEnd());
+ $this->assertTrue($r->hasException(2006, 8, 16));
+ $this->assertTrue($r->hasException(2006, 10, 18));
+
+ $object['recurrence'] = $r->toHash();
+ $recur = $xml->save($object);
+ $object = $xml->load($recur);
+
+ $s = new Horde_Date_Recurrence($object['start-date']);
+ $s->fromHash($object['recurrence']);
+
+ $this->assertTrue($s->hasRecurEnd());
+ $this->assertTrue($s->hasException(2006, 8, 16));
+ $this->assertTrue($s->hasException(2006, 10, 18));
+ }
+
+ /**
+ * Test completion handling.
+ *
+ * @return NULL
+ */
+ public function testCompletions()
+ {
+ $xml = Horde_Kolab_Format::factory('XML', 'event');
+
+ $r = new Horde_Date_Recurrence(0);
+ $r->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
+ $r->addException(1970, 1, 1);
+ $r->addCompletion(1970, 1, 2);
+ $r->addException(1970, 1, 3);
+ $r->addCompletion(1970, 1, 4);
+ $r->setRecurEnd(new Horde_Date(86400*3));
+
+ $object = array('uid' => 0, 'start-date' => 0,
+ 'end-date' => 60);
+ $object['recurrence'] = $r->toHash();
+ $recur = $xml->save($object);
+ $object = $xml->load($recur);
+
+ $s = new Horde_Date_Recurrence(0);
+ $s->fromHash($object['recurrence']);
+
+ $this->assertTrue($s->hasRecurEnd());
+ $this->assertTrue($s->hasException(1970, 1, 1));
+ $this->assertTrue($s->hasCompletion(1970, 1, 2));
+ $this->assertTrue($s->hasException(1970, 1, 3));
+ $this->assertTrue($s->hasCompletion(1970, 1, 4));
+ $this->assertEquals(2, count($s->getCompletions()));
+ $this->assertEquals(2, count($s->getExceptions()));
+ $this->assertFalse($s->hasActiveRecurrence());
+
+ $s->deleteCompletion(1970, 1, 2);
+ $this->assertEquals(1, count($s->getCompletions()));
+ $s->deleteCompletion(1970, 1, 4);
+ $this->assertEquals(0, count($s->getCompletions()));
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the XML format implementation.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test the XML format.
+ *
+ * Copyright 2007-2010 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_Format
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Integration_XmlTest
+extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Set up testing.
+ *
+ * @return NULL
+ */
+ protected function setUp()
+ {
+ Horde_Nls::setCharset('utf-8');
+ }
+
+
+ /**
+ * Check the preparation of the basic XML structure
+ *
+ * @return NULL
+ */
+ public function testBasic()
+ {
+ $xml = new Horde_Kolab_Format_XML();
+ $xml->_prepareSave();
+ $base = $xml->_xmldoc->saveXML();
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\"/>\n",
+ $base);
+ }
+
+ /**
+ * The resulting XML string should be readable.
+ *
+ * @return NULL
+ */
+ public function testReadable()
+ {
+ $xml = new Horde_Kolab_Format_XML();
+ $xml->_prepareSave();
+ $base = $xml->_xmldoc->saveXML();
+ $xml->_parseXml($base);
+ $this->assertEquals($base, $xml->_xmldoc->saveXML());
+
+ }
+
+ /**
+ * Test adding nodes.
+ *
+ * @return NULL
+ */
+ public function testAdd()
+ {
+ $xml = new Horde_Kolab_Format_XML();
+ $root = $xml->_prepareSave();
+ $base = $xml->_xmldoc->saveXML();
+
+ // A missing attribute should cause no change if it
+ // is allowed to be empty
+ $xml->_updateNode($root,
+ array(),
+ 'empty1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_MAYBE_MISSING));
+ $this->assertEquals($base, $xml->_xmldoc->saveXML());
+
+ // A missing attribute should cause an error if it
+ // is not allowed to be empty
+ try {
+ $xml->_updateNode($root,
+ array(),
+ 'empty1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_NOT_EMPTY));
+ $this->assertTrue(false);
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceOf Horde_Exception);
+ }
+
+ $xml->_updateNode($root,
+ array(),
+ 'empty1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 'empty1', 'type' => 0));
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n</kolab>\n",
+ $xml->_xmldoc->saveXML());
+
+ try {
+ $xml->_updateNode($root,
+ array(),
+ 'empty1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
+ 'save' => '_unknown'));
+ $this->assertTrue(false);
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceOf Horde_Exception);
+ }
+ }
+
+
+ /**
+ * Test node operations
+ *
+ * @return NULL
+ */
+ public function testNodeOps()
+ {
+ $dxml = new Horde_Kolab_Format_Xml_Dummy();
+ $droot = $dxml->_prepareSave();
+
+ // Test calculated nodes
+ $dxml->_updateNode($droot,
+ array(),
+ 'empty2',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
+ 'save' => 'Value', 'type' => 0));
+ $dxml->_updateNode($droot,
+ array('present1' => 'present1'),
+ 'present1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
+ 'save' => 'Value', 'type' => 0));
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty2>empty2: , missing</empty2>\n <present1>present1: present1</present1>\n</kolab>\n",
+ $dxml->_xmldoc->saveXML());
+
+ $xml = new Horde_Kolab_Format_Xml();
+ $root = $xml->_prepareSave();
+ $xml->_updateNode($root,
+ array(),
+ 'empty1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 'empty1', 'type' => 0));
+
+ // Back to the original object: Test saving a normal value
+ $xml->_updateNode($root,
+ array('present1' => 'present1'),
+ 'present1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 'empty1', 'type' => 0));
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n <present1>present1</present1>\n</kolab>\n",
+ $xml->_xmldoc->saveXML());
+
+ // Test overwriting a value
+ $xml->_updateNode($root,
+ array('present1' => 'new1'),
+ 'present1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 'empty1', 'type' => 0));
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n <present1>new1</present1>\n</kolab>\n",
+ $xml->_xmldoc->saveXML());
+
+ // Test saving a date
+ $xml->_updateNode($root,
+ array('date1' => 1175080008),
+ 'date1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 'empty1',
+ 'type' => Horde_Kolab_Format_Xml::TYPE_DATETIME));
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n <present1>new1</present1>\n <date1>2007-03-28T11:06:48Z</date1>\n</kolab>\n",
+ $xml->_xmldoc->saveXML());
+
+ // Now load the data back in
+ $children = $root->childNodes;
+
+ // Test loading a value that may be empty
+ $this->assertEquals(null, $xml->_getXmlData($children,
+ 'empty2',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_MAYBE_MISSING,
+ 'default' => '',
+ 'type' => Horde_Kolab_Format_Xml::TYPE_STRING)));
+
+ // Test loading a value that may not be empty
+ try {
+ $xml->_getXmlData($children,
+ 'empty2',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_NOT_EMPTY,
+ 'default' => '',
+ 'type' => Horde_Kolab_Format_Xml::TYPE_STRING));
+ $this->assertTrue(false);
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceOf Horde_Exception);
+ }
+
+ // Test loading a missing value with a default
+ $this->assertEquals(0, $xml->_getXmlData($children,
+ 'date2',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 0,
+ 'type' => Horde_Kolab_Format_Xml::TYPE_DATETIME)));
+
+ // Test loading a calculated value
+ $this->assertEquals('new1', $dxml->_getXmlData($children,
+ 'present1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
+ 'func' => '_calculate',
+ 'type' => Horde_Kolab_Format_Xml::TYPE_STRING)));
+
+ // Test loading a normal value
+ $this->assertEquals('new1', $xml->_getXmlData($children,
+ 'present1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 'empty',
+ 'type' => Horde_Kolab_Format_Xml::TYPE_STRING)));
+
+ // Test loading a date value
+ $this->assertEquals(1175080008, $xml->_getXmlData($children,
+ 'date1',
+ array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
+ 'default' => 0,
+ 'type' => Horde_Kolab_Format_Xml::TYPE_DATETIME)));
+ }
+
+
+ /**
+ * Test load/save
+ *
+ * @return NULL
+ */
+ public function testReleod()
+ {
+ // Save an object and reload it
+ $xml = new Horde_Kolab_Format_Xml();
+ $result = $xml->save(array('uid'=>'test',
+ 'body' => 'body',
+ 'dummy' => 'hello',
+ 'creation-date' => 1175080008,
+ 'last-modification-date' => 1175080008,
+ ));
+ $object = $xml->load($result);
+ $this->assertEquals('body', $object['body']);
+ $this->assertTrue(empty($object['dummy']));
+ $this->assertEquals('public', $object['sensitivity']);
+ $this->assertEquals(1175080008, $object['creation-date']);
+ $this->assertTrue($object['last-modification-date'] != 1175080008);
+ $this->assertEquals('Horde::Kolab', $object['product-id']);
+ }
+
+ /**
+ * Test complex values
+ *
+ * @return NULL
+ */
+ public function testComplex()
+ {
+ // Continue with complex values
+ $xml = new Horde_Kolab_Format_Xml();
+ $root = $xml->_prepareSave();
+
+ // Test saving a composite value
+ $xml->_updateNode($root,
+ array('composite1' => array('display-name' => 'test',
+ 'smtp-address' => 'test@example.com')),
+ 'composite1', $xml->_fields_simple_person);
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <composite1>\n <display-name>test</display-name>\n <smtp-address>test@example.com</smtp-address>\n <uid></uid>\n </composite1>\n</kolab>\n",
+ $xml->_xmldoc->saveXML());
+
+ // Test saving multiple values
+ $xml->_updateNode($root,
+ array('attendee1' => array(array('display-name' => 'test'),
+ array('smtp-address' => 'test@example.com'))),
+ 'attendee1', $xml->_fields_attendee);
+ $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <composite1>\n <display-name>test</display-name>\n <smtp-address>test@example.com</smtp-address>\n <uid></uid>\n </composite1>\n <attendee1>\n <display-name>test</display-name>\n <smtp-address></smtp-address>\n <status>none</status>\n <request-response>true</request-response>\n <role>required</role>\n </attendee1>\n <attendee1>\n <display-name></display-name>\n <smtp-address>test@example.com</smtp-address>\n <status>none</status>\n <request-response>true</request-response>\n <role>required</role>\n </attendee1>\n</kolab>\n",
+ $xml->_xmldoc->saveXML());
+
+ $children = $root->childNodes;
+
+ // Load a composite value
+ $data = $xml->_getXmlData($children,
+ 'composite1',
+ $xml->_fields_simple_person);
+
+ $this->assertEquals(3, count($data));
+ $this->assertEquals('test@example.com', $data['smtp-address']);
+
+ // Load multiple values
+ $data = $xml->_getXmlData($children,
+ 'attendee1',
+ $xml->_fields_attendee);
+ $this->assertEquals(2, count($data));
+ $this->assertEquals(5, count($data[0]));
+ $this->assertEquals('', $data[0]['smtp-address']);
+ $this->assertEquals('test@example.com', $data[1]['smtp-address']);
+ }
+}
+
+/**
+ * A dummy XML type
+ *
+ * Copyright 2007-2010 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_Format
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Xml_Dummy extends Horde_Kolab_Format_Xml
+{
+ /**
+ * Save the object creation date.
+ *
+ * @param DOMNode $node The parent node to attach the child
+ * to.
+ * @param string $name The name of the node.
+ * @param mixed $value The value to store.
+ * @param boolean $missing Has the value been missing?
+ *
+ * @return DOMNode The new child node.
+ */
+ function _saveValue($node, $name, $value, $missing)
+ {
+ $result ='';
+ $result .= $name . ': ';
+ $result .= $value;
+ if ($missing) {
+ $result .= ', missing';
+ }
+
+ return $this->_saveDefault($node,
+ $name,
+ $result,
+ array('type' => self::TYPE_STRING));
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+<contact version="1.0">
+ <uid>1</uid>
+ <body></body>
+ <categories>Test</categories>
+ <creation-date>1970-01-01T00:00:00Z</creation-date>
+ <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <product-id>Horde::Kolab</product-id>
+ <name>
+ <full-name>User Name</full-name>
+ </name>
+ <email>
+ <display-name>User Name</display-name>
+ <smtp-address>user@example.org</smtp-address>
+ <uid></uid>
+ </email>
+</contact>
--- /dev/null
+<?xml version="1.0"?>
+<contact version="1.0">
+ <uid>1</uid>
+ <body></body>
+ <categories></categories>
+ <creation-date>1970-01-01T00:00:00Z</creation-date>
+ <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <product-id>Horde::Kolab</product-id>
+ <name>
+ <full-name>User Name</full-name>
+ </name>
+ <email>
+ <display-name>User Name</display-name>
+ <smtp-address>user@example.org</smtp-address>
+ <uid></uid>
+ </email>
+</contact>
--- /dev/null
+<?xml version="1.0"?>
+<contact version="1.0">
+ <uid>1</uid>
+ <body></body>
+ <categories></categories>
+ <creation-date>1970-01-01T00:00:00Z</creation-date>
+ <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <product-id>Horde::Kolab</product-id>
+ <name>
+ <full-name>User Name</full-name>
+ </name>
+ <email>
+ <display-name>User Name</display-name>
+ <smtp-address>user@example.org</smtp-address>
+ <uid></uid>
+ </email>
+ <pgp-publickey>PGP Test Key</pgp-publickey>
+</contact>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<event version="1.0" >
+ <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
+ <uid>libkcal-543769073.139</uid>
+ <creation-date>2006-03-16T15:00:53Z</creation-date>
+ <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <pilot-sync-status>1</pilot-sync-status>
+ <start-date>2006-03-15T18:30:00Z</start-date>
+ <summary>Summary</summary>
+ <organizer>
+ <display-name>Orga Nizer</display-name>
+ <smtp-address>orga.nizer@example.com</smtp-address>
+ </organizer>
+ <body>...übbe...</body>
+ <revision>0</revision>
+ <show-time-as>busy</show-time-as>
+ <end-date>2007-03-15T20:00:00Z</end-date>
+</event>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<event version="1.0" >
+ <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
+ <uid>libkcal-543769073.139</uid>
+ <creation-date>2006-03-16T15:00:53Z</creation-date>
+ <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <pilot-sync-status>1</pilot-sync-status>
+ <start-date>2006-03-15T18:30:00Z</start-date>
+ <summary>Summary</summary>
+ <organizer>
+ <display-name>Orga Nizer</display-name>
+ <smtp-address>orga.nizer@example.com</smtp-address>
+ </organizer>
+ <body>...übbe...</body>
+ <revision>0</revision>
+ <show-time-as>busy</show-time-as>
+ <end-date>2007-03-15T20:00:00Z</end-date>
+</event>
--- /dev/null
+<?xml version="1.0"?>
+<contact version="1.0">
+ <uid>1</uid>
+ <body></body>
+ <creation-date>1970-01-01T00:00:00Z</creation-date>
+ <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <product-id>Horde::Kolab</product-id>
+ <categories>Test</categories>
+ <pref>test</pref>
+</contact>
--- /dev/null
+<?xml version="1.0"?>
+<h-prefs version="1.0">
+ <uid>1</uid>
+ <body></body>
+ <categories></categories>
+ <creation-date>1970-01-01T00:00:00Z</creation-date>
+ <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <product-id>Horde::Kolab</product-id>
+ <application>Test</application>
+ <pref>test</pref>
+</h-prefs>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<event version="1.0" >
+ <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
+ <uid>libkcal-543769073.139</uid>
+ <creation-date>2006-03-16T15:00:53Z</creation-date>
+ <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <pilot-sync-status>1</pilot-sync-status>
+ <start-date>2006-03-15T18:30:00Z</start-date>
+ <summary>Summary</summary>
+ <organizer>
+ <display-name>Orga Nizer</display-name>
+ <smtp-address>orga.nizer@example.com</smtp-address>
+ </organizer>
+ <recurrence cycle="weekly" >
+ <interval>1</interval>
+ <day>wednesday</day>
+ <range type="date" >2007-01-24</range>
+ <exclusion>2006-04-05</exclusion>
+ <exclusion>2006-04-12</exclusion>
+ <exclusion>2006-07-19</exclusion>
+ <exclusion>2006-07-26</exclusion>
+ <exclusion>2006-08-02</exclusion>
+ <exclusion>2006-08-09</exclusion>
+ <exclusion>2006-08-16</exclusion>
+ <exclusion>2006-08-23</exclusion>
+ <exclusion>2006-07-12</exclusion>
+ <exclusion>2006-09-06</exclusion>
+ <exclusion>2006-09-13</exclusion>
+ <exclusion>2006-10-18</exclusion>
+ <exclusion>2006-10-25</exclusion>
+ <exclusion>2006-12-27</exclusion>
+ <exclusion>2007-01-17</exclusion>
+ <exclusion>2007-01-10</exclusion>
+ <exclusion>2007-01-03</exclusion>
+ </recurrence>
+ <revision>0</revision>
+ <show-time-as>busy</show-time-as>
+ <end-date>2007-03-15T20:00:00Z</end-date>
+</event>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<event version="1.0" >
+ <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
+ <uid>libkcal-543769073.139</uid>
+ <creation-date>2006-03-16T15:00:53Z</creation-date>
+ <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
+ <sensitivity>public</sensitivity>
+ <pilot-sync-status>1</pilot-sync-status>
+ <start-date>2006-03-15T18:30:00Z</start-date>
+ <summary>Summary</summary>
+ <organizer>
+ <display-name>Orga Nizer</display-name>
+ <smtp-address>orga.nizer@example.com</smtp-address>
+ </organizer>
+ <recurrence>
+ <day>wednesday</day>
+ <range type="date" >2007-01-24</range>
+ <exclusion>2006-04-05</exclusion>
+ <exclusion>2006-04-12</exclusion>
+ <exclusion>2006-07-19</exclusion>
+ <exclusion>2006-07-26</exclusion>
+ <exclusion>2006-08-02</exclusion>
+ <exclusion>2006-08-09</exclusion>
+ <exclusion>2006-08-16</exclusion>
+ <exclusion>2006-08-23</exclusion>
+ <exclusion>2006-07-12</exclusion>
+ <exclusion>2006-09-06</exclusion>
+ <exclusion>2006-09-13</exclusion>
+ <exclusion>2006-10-18</exclusion>
+ <exclusion>2006-10-25</exclusion>
+ <exclusion>2006-12-27</exclusion>
+ <exclusion>2007-01-17</exclusion>
+ <exclusion>2007-01-10</exclusion>
+ <exclusion>2007-01-03</exclusion>
+ </recurrence>
+ <revision>0</revision>
+ <show-time-as>busy</show-time-as>
+ <end-date>2006-03-15T20:00:00Z</end-date>
+</event>
+++ /dev/null
-<?php
-/**
- * Test Kolab Format MIME attributes
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Format
- * @subpackage UnitTests
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * Test Kolab Format MIME attributes
- *
- * Copyright 2007-2010 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_Format
- * @subpackage UnitTests
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_MimeAttrTest extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- Horde_Nls::setCharset('utf-8');
- }
-
- /**
- * Test retrieving the document name.
- *
- * @return NULL
- */
- public function testGetName()
- {
- $format = Horde_Kolab_Format::factory('XML', 'contact');
- $this->assertEquals('kolab.xml', $format->getName());
- }
-
- /**
- * Test retrieving the document mime type.
- *
- * @return NULL
- */
- public function testMimeType()
- {
- $format = Horde_Kolab_Format::factory('XML', 'contact');
- $this->assertEquals('application/x-vnd.kolab.contact',
- $format->getMimeType());
- }
-
- /**
- * Test retrieving the document disposition.
- *
- * @return NULL
- */
- public function testGetDisposition()
- {
- $format = Horde_Kolab_Format::factory('XML', 'contact');
- $this->assertEquals('attachment', $format->getDisposition());
- }
-}
+++ /dev/null
-<?php
-/**
- * Test the preferences XML format.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-
-/**
- * Test the preferences XML format.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_PreferencesTest extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- Horde_Nls::setCharset('utf-8');
- }
-
- /**
- * Test preferences format conversion.
- *
- * @return NULL
- */
- public function testConversionFromOld()
- {
- $preferences = new Horde_Kolab_Format_Xml_hprefs_Dummy();
-
- $xml = file_get_contents(dirname(__FILE__)
- . '/fixtures/preferences_read_old.xml');
- $object = $preferences->load($xml);
- $this->assertContains('test', $object['pref']);
- $this->assertEquals('Test', $object['application']);
-
- $object = array('uid' => 1,
- 'pref' => array('test'),
- 'categories' => 'Test');
- $xml = $preferences->save($object);
- $expect = file_get_contents(dirname(__FILE__)
- . '/fixtures/preferences_write_old.xml');
- $this->assertEquals($expect, $xml);
-
- $object = array('uid' => 1,
- 'pref' => array('test'),
- 'application' => 'Test');
- $xml = $preferences->save($object);
- $expect = file_get_contents(dirname(__FILE__)
- . '/fixtures/preferences_write_old.xml');
- $this->assertEquals($expect, $xml);
- }
-}
-
-
-/**
- * A modification to the original preferences handler. This prevents
- * unpredictable date entries.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_Xml_Hprefs_Dummy extends Horde_Kolab_Format_Xml_Hprefs
-{
- /**
- * Save the object creation date.
- *
- * @param DOMNode $parent_node The parent node to attach the child
- * to.
- * @param string $name The name of the node.
- * @param mixed $value The value to store.
- * @param boolean $missing Has the value been missing?
- *
- * @return DOMNode The new child node.
- */
- function _saveCreationDate($parent_node, $name, $value, $missing)
- {
- // Only create the creation date if it has not been set before
- if ($missing) {
- $value = 0;
- }
- return $this->_saveDefault($parent_node,
- $name,
- $value,
- array('type' => self::TYPE_DATETIME));
- }
-
- /**
- * Save the object modification date.
- *
- * @param DOMNode $parent_node The parent node to attach
- * the child to.
- * @param string $name The name of the node.
- * @param mixed $value The value to store.
- * @param boolean $missing Has the value been missing?
- *
- * @return DOMNode The new child node.
- */
- function _saveModificationDate($parent_node, $name, $value, $missing)
- {
- // Always store now as modification date
- return $this->_saveDefault($parent_node,
- $name,
- 0,
- array('type' => self::TYPE_DATETIME));
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test recurrence handling within the Kolab format implementation.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * Test recurrence handling
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- @include_once 'Horde/Date/Recurrence.php';
-
- if (!class_exists('Horde_Date_Recurrence')) {
- $this->markTestSkipped('The Horde_Date_Recurrence class is missing.');
- }
-
- Horde_Nls::setCharset('utf-8');
-
- $this->_oldTimezone = date_default_timezone_get();
- date_default_timezone_set('Europe/Berlin');
- }
-
- public function tearDown()
- {
- date_default_timezone_set($this->_oldTimezone);
- }
-
- /**
- * Test for http://bugs.horde.org/ticket/?id=6388
- *
- * @return NULL
- */
- public function testBug6388()
- {
- $xml = Horde_Kolab_Format::factory('XML', 'event');
-
- // Load XML
- $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
-
- // 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 {
- $xml->load($recur);
- $this->assertTrue(false);
- } catch (Exception $e) {
- $this->assertTrue($e instanceOf Horde_Exception);
- }
- }
-
-
- /**
- * Test exception handling.
- *
- * @return NULL
- */
- public function testExceptions()
- {
- $xml = Horde_Kolab_Format::factory('XML', 'event');
-
- // Load XML
- $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
-
- $object = $xml->load($recur);
-
- $r = new Horde_Date_Recurrence($object['start-date']);
- $r->fromHash($object['recurrence']);
-
- $this->assertTrue($r->hasRecurEnd());
- $this->assertTrue($r->hasException(2006, 8, 16));
- $this->assertTrue($r->hasException(2006, 10, 18));
-
- $object['recurrence'] = $r->toHash();
- $recur = $xml->save($object);
- $object = $xml->load($recur);
-
- $s = new Horde_Date_Recurrence($object['start-date']);
- $s->fromHash($object['recurrence']);
-
- $this->assertTrue($s->hasRecurEnd());
- $this->assertTrue($s->hasException(2006, 8, 16));
- $this->assertTrue($s->hasException(2006, 10, 18));
- }
-
- /**
- * Test completion handling.
- *
- * @return NULL
- */
- public function testCompletions()
- {
- $xml = Horde_Kolab_Format::factory('XML', 'event');
-
- $r = new Horde_Date_Recurrence(0);
- $r->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
- $r->addException(1970, 1, 1);
- $r->addCompletion(1970, 1, 2);
- $r->addException(1970, 1, 3);
- $r->addCompletion(1970, 1, 4);
- $r->setRecurEnd(new Horde_Date(86400*3));
-
- $object = array('uid' => 0, 'start-date' => 0,
- 'end-date' => 60);
- $object['recurrence'] = $r->toHash();
- $recur = $xml->save($object);
- $object = $xml->load($recur);
-
- $s = new Horde_Date_Recurrence(0);
- $s->fromHash($object['recurrence']);
-
- $this->assertTrue($s->hasRecurEnd());
- $this->assertTrue($s->hasException(1970, 1, 1));
- $this->assertTrue($s->hasCompletion(1970, 1, 2));
- $this->assertTrue($s->hasException(1970, 1, 3));
- $this->assertTrue($s->hasCompletion(1970, 1, 4));
- $this->assertEquals(2, count($s->getCompletions()));
- $this->assertEquals(2, count($s->getExceptions()));
- $this->assertFalse($s->hasActiveRecurrence());
-
- $s->deleteCompletion(1970, 1, 2);
- $this->assertEquals(1, count($s->getCompletions()));
- $s->deleteCompletion(1970, 1, 4);
- $this->assertEquals(0, count($s->getCompletions()));
- }
-}
+++ /dev/null
-<?php
-/**
- * Test the XML format implementation.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * Test the XML format.
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_XmlTest extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- Horde_Nls::setCharset('utf-8');
- }
-
-
- /**
- * Check the preparation of the basic XML structure
- *
- * @return NULL
- */
- public function testBasic()
- {
- $xml = new Horde_Kolab_Format_XML();
- $xml->_prepareSave();
- $base = $xml->_xmldoc->saveXML();
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\"/>\n",
- $base);
- }
-
- /**
- * The resulting XML string should be readable.
- *
- * @return NULL
- */
- public function testReadable()
- {
- $xml = new Horde_Kolab_Format_XML();
- $xml->_prepareSave();
- $base = $xml->_xmldoc->saveXML();
- $xml->_parseXml($base);
- $this->assertEquals($base, $xml->_xmldoc->saveXML());
-
- }
-
- /**
- * Test adding nodes.
- *
- * @return NULL
- */
- public function testAdd()
- {
- $xml = new Horde_Kolab_Format_XML();
- $root = $xml->_prepareSave();
- $base = $xml->_xmldoc->saveXML();
-
- // A missing attribute should cause no change if it
- // is allowed to be empty
- $xml->_updateNode($root,
- array(),
- 'empty1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_MAYBE_MISSING));
- $this->assertEquals($base, $xml->_xmldoc->saveXML());
-
- // A missing attribute should cause an error if it
- // is not allowed to be empty
- try {
- $xml->_updateNode($root,
- array(),
- 'empty1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_NOT_EMPTY));
- $this->assertTrue(false);
- } catch (Exception $e) {
- $this->assertTrue($e instanceOf Horde_Exception);
- }
-
- $xml->_updateNode($root,
- array(),
- 'empty1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 'empty1', 'type' => 0));
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n</kolab>\n",
- $xml->_xmldoc->saveXML());
-
- try {
- $xml->_updateNode($root,
- array(),
- 'empty1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
- 'save' => '_unknown'));
- $this->assertTrue(false);
- } catch (Exception $e) {
- $this->assertTrue($e instanceOf Horde_Exception);
- }
- }
-
-
- /**
- * Test node operations
- *
- * @return NULL
- */
- public function testNodeOps()
- {
- $dxml = new Horde_Kolab_Format_Xml_Dummy();
- $droot = $dxml->_prepareSave();
-
- // Test calculated nodes
- $dxml->_updateNode($droot,
- array(),
- 'empty2',
- array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
- 'save' => 'Value', 'type' => 0));
- $dxml->_updateNode($droot,
- array('present1' => 'present1'),
- 'present1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
- 'save' => 'Value', 'type' => 0));
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty2>empty2: , missing</empty2>\n <present1>present1: present1</present1>\n</kolab>\n",
- $dxml->_xmldoc->saveXML());
-
- $xml = new Horde_Kolab_Format_Xml();
- $root = $xml->_prepareSave();
- $xml->_updateNode($root,
- array(),
- 'empty1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 'empty1', 'type' => 0));
-
- // Back to the original object: Test saving a normal value
- $xml->_updateNode($root,
- array('present1' => 'present1'),
- 'present1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 'empty1', 'type' => 0));
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n <present1>present1</present1>\n</kolab>\n",
- $xml->_xmldoc->saveXML());
-
- // Test overwriting a value
- $xml->_updateNode($root,
- array('present1' => 'new1'),
- 'present1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 'empty1', 'type' => 0));
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n <present1>new1</present1>\n</kolab>\n",
- $xml->_xmldoc->saveXML());
-
- // Test saving a date
- $xml->_updateNode($root,
- array('date1' => 1175080008),
- 'date1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 'empty1',
- 'type' => Horde_Kolab_Format_Xml::TYPE_DATETIME));
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <empty1>empty1</empty1>\n <present1>new1</present1>\n <date1>2007-03-28T11:06:48Z</date1>\n</kolab>\n",
- $xml->_xmldoc->saveXML());
-
- // Now load the data back in
- $children = $root->childNodes;
-
- // Test loading a value that may be empty
- $this->assertEquals(null, $xml->_getXmlData($children,
- 'empty2',
- array('value' => Horde_Kolab_Format_Xml::VALUE_MAYBE_MISSING,
- 'default' => '',
- 'type' => Horde_Kolab_Format_Xml::TYPE_STRING)));
-
- // Test loading a value that may not be empty
- try {
- $xml->_getXmlData($children,
- 'empty2',
- array('value' => Horde_Kolab_Format_Xml::VALUE_NOT_EMPTY,
- 'default' => '',
- 'type' => Horde_Kolab_Format_Xml::TYPE_STRING));
- $this->assertTrue(false);
- } catch (Exception $e) {
- $this->assertTrue($e instanceOf Horde_Exception);
- }
-
- // Test loading a missing value with a default
- $this->assertEquals(0, $xml->_getXmlData($children,
- 'date2',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 0,
- 'type' => Horde_Kolab_Format_Xml::TYPE_DATETIME)));
-
- // Test loading a calculated value
- $this->assertEquals('new1', $dxml->_getXmlData($children,
- 'present1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_CALCULATED,
- 'func' => '_calculate',
- 'type' => Horde_Kolab_Format_Xml::TYPE_STRING)));
-
- // Test loading a normal value
- $this->assertEquals('new1', $xml->_getXmlData($children,
- 'present1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 'empty',
- 'type' => Horde_Kolab_Format_Xml::TYPE_STRING)));
-
- // Test loading a date value
- $this->assertEquals(1175080008, $xml->_getXmlData($children,
- 'date1',
- array('value' => Horde_Kolab_Format_Xml::VALUE_DEFAULT,
- 'default' => 0,
- 'type' => Horde_Kolab_Format_Xml::TYPE_DATETIME)));
- }
-
-
- /**
- * Test load/save
- *
- * @return NULL
- */
- public function testReleod()
- {
- // Save an object and reload it
- $xml = new Horde_Kolab_Format_Xml();
- $result = $xml->save(array('uid'=>'test',
- 'body' => 'body',
- 'dummy' => 'hello',
- 'creation-date' => 1175080008,
- 'last-modification-date' => 1175080008,
- ));
- $object = $xml->load($result);
- $this->assertEquals('body', $object['body']);
- $this->assertTrue(empty($object['dummy']));
- $this->assertEquals('public', $object['sensitivity']);
- $this->assertEquals(1175080008, $object['creation-date']);
- $this->assertTrue($object['last-modification-date'] != 1175080008);
- $this->assertEquals('Horde::Kolab', $object['product-id']);
- }
-
- /**
- * Test complex values
- *
- * @return NULL
- */
- public function testComplex()
- {
- // Continue with complex values
- $xml = new Horde_Kolab_Format_Xml();
- $root = $xml->_prepareSave();
-
- // Test saving a composite value
- $xml->_updateNode($root,
- array('composite1' => array('display-name' => 'test',
- 'smtp-address' => 'test@example.com')),
- 'composite1', $xml->_fields_simple_person);
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <composite1>\n <display-name>test</display-name>\n <smtp-address>test@example.com</smtp-address>\n <uid></uid>\n </composite1>\n</kolab>\n",
- $xml->_xmldoc->saveXML());
-
- // Test saving multiple values
- $xml->_updateNode($root,
- array('attendee1' => array(array('display-name' => 'test'),
- array('smtp-address' => 'test@example.com'))),
- 'attendee1', $xml->_fields_attendee);
- $this->assertEquals("<?xml version=\"1.0\"?>\n<kolab version=\"1.0\">\n <composite1>\n <display-name>test</display-name>\n <smtp-address>test@example.com</smtp-address>\n <uid></uid>\n </composite1>\n <attendee1>\n <display-name>test</display-name>\n <smtp-address></smtp-address>\n <status>none</status>\n <request-response>true</request-response>\n <role>required</role>\n </attendee1>\n <attendee1>\n <display-name></display-name>\n <smtp-address>test@example.com</smtp-address>\n <status>none</status>\n <request-response>true</request-response>\n <role>required</role>\n </attendee1>\n</kolab>\n",
- $xml->_xmldoc->saveXML());
-
- $children = $root->childNodes;
-
- // Load a composite value
- $data = $xml->_getXmlData($children,
- 'composite1',
- $xml->_fields_simple_person);
-
- $this->assertEquals(3, count($data));
- $this->assertEquals('test@example.com', $data['smtp-address']);
-
- // Load multiple values
- $data = $xml->_getXmlData($children,
- 'attendee1',
- $xml->_fields_attendee);
- $this->assertEquals(2, count($data));
- $this->assertEquals(5, count($data[0]));
- $this->assertEquals('', $data[0]['smtp-address']);
- $this->assertEquals('test@example.com', $data[1]['smtp-address']);
- }
-}
-
-/**
- * A dummy XML type
- *
- * Copyright 2007-2010 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_Format
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Format
- */
-class Horde_Kolab_Format_Xml_Dummy extends Horde_Kolab_Format_Xml
-{
- /**
- * Save the object creation date.
- *
- * @param DOMNode $node The parent node to attach the child
- * to.
- * @param string $name The name of the node.
- * @param mixed $value The value to store.
- * @param boolean $missing Has the value been missing?
- *
- * @return DOMNode The new child node.
- */
- function _saveValue($node, $name, $value, $missing)
- {
- $result ='';
- $result .= $name . ': ';
- $result .= $value;
- if ($missing) {
- $result .= ', missing';
- }
-
- return $this->_saveDefault($node,
- $name,
- $result,
- array('type' => self::TYPE_STRING));
- }
-}
+++ /dev/null
-<?xml version="1.0"?>
-<contact version="1.0">
- <uid>1</uid>
- <body></body>
- <categories>Test</categories>
- <creation-date>1970-01-01T00:00:00Z</creation-date>
- <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <product-id>Horde::Kolab</product-id>
- <name>
- <full-name>User Name</full-name>
- </name>
- <email>
- <display-name>User Name</display-name>
- <smtp-address>user@example.org</smtp-address>
- <uid></uid>
- </email>
-</contact>
+++ /dev/null
-<?xml version="1.0"?>
-<contact version="1.0">
- <uid>1</uid>
- <body></body>
- <categories></categories>
- <creation-date>1970-01-01T00:00:00Z</creation-date>
- <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <product-id>Horde::Kolab</product-id>
- <name>
- <full-name>User Name</full-name>
- </name>
- <email>
- <display-name>User Name</display-name>
- <smtp-address>user@example.org</smtp-address>
- <uid></uid>
- </email>
-</contact>
+++ /dev/null
-<?xml version="1.0"?>
-<contact version="1.0">
- <uid>1</uid>
- <body></body>
- <categories></categories>
- <creation-date>1970-01-01T00:00:00Z</creation-date>
- <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <product-id>Horde::Kolab</product-id>
- <name>
- <full-name>User Name</full-name>
- </name>
- <email>
- <display-name>User Name</display-name>
- <smtp-address>user@example.org</smtp-address>
- <uid></uid>
- </email>
- <pgp-publickey>PGP Test Key</pgp-publickey>
-</contact>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<event version="1.0" >
- <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
- <uid>libkcal-543769073.139</uid>
- <creation-date>2006-03-16T15:00:53Z</creation-date>
- <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <pilot-sync-status>1</pilot-sync-status>
- <start-date>2006-03-15T18:30:00Z</start-date>
- <summary>Summary</summary>
- <organizer>
- <display-name>Orga Nizer</display-name>
- <smtp-address>orga.nizer@example.com</smtp-address>
- </organizer>
- <body>...übbe...</body>
- <revision>0</revision>
- <show-time-as>busy</show-time-as>
- <end-date>2007-03-15T20:00:00Z</end-date>
-</event>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<event version="1.0" >
- <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
- <uid>libkcal-543769073.139</uid>
- <creation-date>2006-03-16T15:00:53Z</creation-date>
- <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <pilot-sync-status>1</pilot-sync-status>
- <start-date>2006-03-15T18:30:00Z</start-date>
- <summary>Summary</summary>
- <organizer>
- <display-name>Orga Nizer</display-name>
- <smtp-address>orga.nizer@example.com</smtp-address>
- </organizer>
- <body>...übbe...</body>
- <revision>0</revision>
- <show-time-as>busy</show-time-as>
- <end-date>2007-03-15T20:00:00Z</end-date>
-</event>
+++ /dev/null
-<?xml version="1.0"?>
-<contact version="1.0">
- <uid>1</uid>
- <body></body>
- <creation-date>1970-01-01T00:00:00Z</creation-date>
- <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <product-id>Horde::Kolab</product-id>
- <categories>Test</categories>
- <pref>test</pref>
-</contact>
+++ /dev/null
-<?xml version="1.0"?>
-<h-prefs version="1.0">
- <uid>1</uid>
- <body></body>
- <categories></categories>
- <creation-date>1970-01-01T00:00:00Z</creation-date>
- <last-modification-date>1970-01-01T00:00:00Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <product-id>Horde::Kolab</product-id>
- <application>Test</application>
- <pref>test</pref>
-</h-prefs>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<event version="1.0" >
- <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
- <uid>libkcal-543769073.139</uid>
- <creation-date>2006-03-16T15:00:53Z</creation-date>
- <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <pilot-sync-status>1</pilot-sync-status>
- <start-date>2006-03-15T18:30:00Z</start-date>
- <summary>Summary</summary>
- <organizer>
- <display-name>Orga Nizer</display-name>
- <smtp-address>orga.nizer@example.com</smtp-address>
- </organizer>
- <recurrence cycle="weekly" >
- <interval>1</interval>
- <day>wednesday</day>
- <range type="date" >2007-01-24</range>
- <exclusion>2006-04-05</exclusion>
- <exclusion>2006-04-12</exclusion>
- <exclusion>2006-07-19</exclusion>
- <exclusion>2006-07-26</exclusion>
- <exclusion>2006-08-02</exclusion>
- <exclusion>2006-08-09</exclusion>
- <exclusion>2006-08-16</exclusion>
- <exclusion>2006-08-23</exclusion>
- <exclusion>2006-07-12</exclusion>
- <exclusion>2006-09-06</exclusion>
- <exclusion>2006-09-13</exclusion>
- <exclusion>2006-10-18</exclusion>
- <exclusion>2006-10-25</exclusion>
- <exclusion>2006-12-27</exclusion>
- <exclusion>2007-01-17</exclusion>
- <exclusion>2007-01-10</exclusion>
- <exclusion>2007-01-03</exclusion>
- </recurrence>
- <revision>0</revision>
- <show-time-as>busy</show-time-as>
- <end-date>2007-03-15T20:00:00Z</end-date>
-</event>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<event version="1.0" >
- <product-id>KOrganizer 3.3 (proko2 branch after 2.1.5), Kolab resource</product-id>
- <uid>libkcal-543769073.139</uid>
- <creation-date>2006-03-16T15:00:53Z</creation-date>
- <last-modification-date>2007-01-25T11:36:40Z</last-modification-date>
- <sensitivity>public</sensitivity>
- <pilot-sync-status>1</pilot-sync-status>
- <start-date>2006-03-15T18:30:00Z</start-date>
- <summary>Summary</summary>
- <organizer>
- <display-name>Orga Nizer</display-name>
- <smtp-address>orga.nizer@example.com</smtp-address>
- </organizer>
- <recurrence>
- <day>wednesday</day>
- <range type="date" >2007-01-24</range>
- <exclusion>2006-04-05</exclusion>
- <exclusion>2006-04-12</exclusion>
- <exclusion>2006-07-19</exclusion>
- <exclusion>2006-07-26</exclusion>
- <exclusion>2006-08-02</exclusion>
- <exclusion>2006-08-09</exclusion>
- <exclusion>2006-08-16</exclusion>
- <exclusion>2006-08-23</exclusion>
- <exclusion>2006-07-12</exclusion>
- <exclusion>2006-09-06</exclusion>
- <exclusion>2006-09-13</exclusion>
- <exclusion>2006-10-18</exclusion>
- <exclusion>2006-10-25</exclusion>
- <exclusion>2006-12-27</exclusion>
- <exclusion>2007-01-17</exclusion>
- <exclusion>2007-01-10</exclusion>
- <exclusion>2007-01-03</exclusion>
- </recurrence>
- <revision>0</revision>
- <show-time-as>busy</show-time-as>
- <end-date>2006-03-15T20:00:00Z</end-date>
-</event>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit>
+ <filter>
+ <whitelist>
+ <directory suffix=".php">../../../../lib</directory>
+ </whitelist>
+ </filter>
+</phpunit>