* @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_Server
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
*/
/**
* @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_Server
+ * @link http://pear.horde.org/index.php?package=Kolab_Format
*/
abstract class Horde_Kolab_Format
{
-
/**
* Attempts to return a concrete Horde_Kolab_Format instance based on
* $format_type.
*
* @throws Horde_Kolab_Format_Exception If the specified driver could not be loaded.
*/
- static public function &factory($format_type = '', $object_type = '',
- $params = null)
+ static public function factory($format_type = '', $object_type = '',
+ $params = null)
{
$class = 'Horde_Kolab_Format_' . ucfirst(strtolower($format_type));
if (class_exists($class)) {
- $driver = call_user_func(array($class, 'factory'), $object_type,
- $params);
+ $driver = call_user_func(
+ array($class, 'factory'), $object_type, $params
+ );
} else {
- throw new Horde_Kolab_Format_Exception(sprintf('Failed to load Kolab Format driver %s',
- $format_type));
+ throw new Horde_Kolab_Format_Exception(
+ sprintf('Failed to load Kolab Format driver %s',
+ $format_type)
+ );
}
return $driver;
* @throws Horde_Kolab_Format_Exception
*/
abstract public function save($object);
-
}
/**
* Prepare the test setup.
*/
-require_once dirname(__FILE__) . '/Autoload.php';
+require_once 'Horde/Test/AllTests.php';
/**
* Combine the tests for this package.
*
- * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
+ * 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.
*
* PHP version 5
*
+ * Copyright 2009-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
+ * @package Kolab_Config
* @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
+ * @link http://pear.horde.org/index.php?package=Kolab_Config
*/
-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);'
- )
- );
-}
+require_once 'Horde/Test/Autoload.php';
/** Catch strict standards */
error_reporting(E_ALL | E_STRICT);
--- /dev/null
+<?php
+/**
+ * Test the format entry point.
+ *
+ * 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 format entry point.
+ *
+ * Copyright 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_Unit_FormatTest
+extends PHPUnit_Framework_TestCase
+{
+ public function testFactory()
+ {
+ $this->assertInstanceOf(
+ 'Horde_Kolab_Format_Xml_Contact',
+ Horde_Kolab_Format::factory('XML', 'contact')
+ );
+ }
+
+ /**
+ * @expectedException Horde_Kolab_Format_Exception
+ */
+ public function testFactoryException()
+ {
+ Horde_Kolab_Format::factory('UNKNOWN', 'contact');
+ }
+
+
+}