PHP 5 conversions. Made Horde_Kolab_Server an abstract class. Adapted testing.
authorGunnar Wrobel <p@rdus.de>
Wed, 11 Feb 2009 22:11:16 +0000 (22:11 +0000)
committerGunnar Wrobel <p@rdus.de>
Wed, 11 Feb 2009 22:11:16 +0000 (22:11 +0000)
framework/Kolab_Server/lib/Horde/Kolab/Server.php
framework/Kolab_Server/lib/Horde/Kolab/Server/test.php
framework/Kolab_Server/test/Horde/Kolab/Server/ServerTest.php

index 6ecaca1..2a1d551 100644 (file)
@@ -2,7 +2,6 @@
 /**
  * A library for accessing the Kolab user database.
  *
- *
  * PHP version 5
  *
  * @category Kolab
  * @link     http://pear.horde.org/index.php?package=Kolab_Server
  */
 
-/** We need PEAR */
-require_once 'PEAR.php';
+/**
+ * The Autoloader allows us to omit "require/include" statements.
+ */
+require_once 'Horde/Autoloader.php';
 
 /** Provide access to the Kolab specific objects. */
 require_once 'Horde/Kolab/Server/Object.php';
@@ -27,7 +28,6 @@ define('KOLAB_SERVER_RESULT_MANY',   3);
  * This class provides methods to deal with Kolab objects stored in
  * the Kolab object db.
  *
- *
  * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you
@@ -39,7 +39,7 @@ define('KOLAB_SERVER_RESULT_MANY',   3);
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Kolab_Server
  */
-class Horde_Kolab_Server
+abstract class Horde_Kolab_Server
 {
 
     /**
@@ -54,7 +54,7 @@ class Horde_Kolab_Server
      *
      * @var string
      */
-    var $uid;
+    public $uid;
 
     /**
      * Valid Kolab object types
@@ -78,7 +78,7 @@ class Horde_Kolab_Server
      *
      * @param array $params Parameter array.
      */
-    function Horde_Kolab_Server($params = array())
+    public function __construct($params = array())
     {
         $this->_params = $params;
         if (isset($params['uid'])) {
@@ -101,16 +101,6 @@ class Horde_Kolab_Server
      */
     function &factory($driver, $params = array())
     {
-        $driver = basename($driver);
-        if (empty($driver) || $driver == 'none') {
-            $db = new Horde_Kolab_Server($params);
-            return $db;
-        }
-
-        if (file_exists(dirname(__FILE__) . '/Server/' . $driver . '.php')) {
-            include_once dirname(__FILE__) . '/Server/' . $driver . '.php';
-        }
-
         $class = 'Horde_Kolab_Server_' . $driver;
         if (class_exists($class)) {
             $db = new $class($params);
index 658f946..d205ea3 100644 (file)
@@ -80,7 +80,7 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
      *
      * @param array $params Parameter array.
      */
-    function Horde_Kolab_Server_test($params = array())
+    function __construct($params = array())
     {
         if (isset($params['data'])) {
             $GLOBALS['KOLAB_SERVER_TEST_DATA'] = $params['data'];
@@ -89,7 +89,7 @@ class Horde_Kolab_Server_test extends Horde_Kolab_Server_ldap
                 $GLOBALS['KOLAB_SERVER_TEST_DATA'] = array();
             }
         }
-        Horde_Kolab_Server::Horde_Kolab_Server($params);
+        parent::__construct($params);
     }
 
     /**
index 96f28c8..224c168 100644 (file)
@@ -2,7 +2,6 @@
 /**
  * Test the server class.
  *
- *
  * PHP version 5
  *
  * @category Kolab
  */
 
 /**
- *  We need the unit test framework
+ * We need the unit test framework
  */
 require_once 'PHPUnit/Framework.php';
 
-require_once 'Horde/Kolab/Server.php';
+/**
+ * The Autoloader allows us to omit "require/include" statements.
+ */
+require_once 'Horde/Autoloader.php';
 
 /**
  * Tests for the main server class.
  *
- *
  * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you
@@ -69,3 +70,21 @@ class Horde_Kolab_Server_ServerTest extends PHPUnit_Framework_TestCase
     }
 
 }
+
+/**
+ * A dummy class to test the original abstract class.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @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
+ */
+class Horde_Kolab_Server_none extends Horde_Kolab_Server
+{
+}