From: Gunnar Wrobel
Date: Thu, 8 Jul 2010 09:33:41 +0000 (+0200)
Subject: Reactivate testing and make the basic filter test work again.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1cb16470064ec65628126759405dee73a96308ef;p=horde.git
Reactivate testing and make the basic filter test work again.
---
diff --git a/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php b/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php
index 66ea6334a..f16784715 100644
--- a/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php
+++ b/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Base.php
@@ -3,9 +3,6 @@
* @package Kolab_Filter
*/
-/** Load the Filter libraries */
-require_once dirname(__FILE__) . '/Response.php';
-
/**
* A basic definition for a PHP based postfix filter.
*
@@ -76,6 +73,12 @@ class Horde_Kolab_Filter_Base
*/
var $_sasl_username;
+ public function __construct()
+ {
+ $GLOBALS['injector'] = $injector = new Horde_Injector(new Horde_Injector_TopLevel());
+ $injector->setInstance('Horde_Log_Logger', new Horde_Core_Log_Logger(new Horde_Log_Handler_Mock()));
+ }
+
/**
* Initialize the class.
*/
@@ -98,7 +101,7 @@ class Horde_Kolab_Filter_Base
{
/* Setup the temporary storage */
$result = $this->_initTmp();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceOf PEAR_Error) {
return $result;
}
@@ -208,9 +211,14 @@ class Horde_Kolab_Filter_Base
}
if (empty($values['recipient'])) {
- $msg = 'Please provide one or more recipients.'
- . "\n\n" . $p->getUsage();
- return PEAR::raiseError($msg, OUT_STDOUT | EX_USAGE);
+ throw new Horde_Kolab_Filter_Exception(
+ sprintf(
+ "Please provide one or more recipients.\n\n%s",
+ $p->getUsage()
+ ),
+ Horde_Kolab_Filter_Exception::OUT_STDOUT |
+ Horde_Kolab_Filter_Exception::EX_USAGE
+ );
}
$this->_sender = strtolower($values['sender']);
diff --git a/framework/Kolab_Filter/test/Horde/Kolab/Filter/AllTests.php b/framework/Kolab_Filter/test/Horde/Kolab/Filter/AllTests.php
new file mode 100644
index 000000000..66b842c36
--- /dev/null
+++ b/framework/Kolab_Filter/test/Horde/Kolab/Filter/AllTests.php
@@ -0,0 +1,87 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * Define the main method
+ */
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'Horde_Kolab_Storage_AllTests::main');
+}
+
+/**
+ * Prepare the test setup.
+ */
+require_once 'Horde/Test/AllTests.php';
+
+/**
+ * @package Horde_Kolab_Storage
+ * @subpackage UnitTests
+ */
+class Horde_Kolab_Storage_AllTests extends Horde_Test_AllTests
+{
+ /**
+ * Main entry point for running the suite.
+ */
+ public static function main($package = null, $file = null)
+ {
+ if ($package) {
+ self::$_package = $package;
+ }
+ if ($file) {
+ self::$_file = $file;
+ }
+
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ /**
+ * Collect the unit tests of this directory into a new suite.
+ *
+ * @return PHPUnit_Framework_TestSuite The test suite.
+ */
+ public static function suite()
+ {
+ return self::detectTestFixture(Horde_Test_AllTests::suite());
+ }
+
+ /**
+ * Detect if test configuration is available for the server integration
+ * tests.
+ *
+ * @param PHPUnit_Framework_TestSuite $suite The current test suite.
+ */
+ public static function detectTestFixture(PHPUnit_Framework_TestSuite $suite)
+ {
+ $config = getenv('KOLAB_STORAGE_TEST_CONFIG');
+ if ($config === false) {
+ $config = dirname(__FILE__) . '/conf.php';
+ }
+ if (file_exists($config)) {
+ require $config;
+ if (isset($conf['kolab']['storage']['test'])) {
+ $fixture = new stdClass;
+ $fixture->conf = $conf['kolab']['storage']['test'];
+ $fixture->drivers = array();
+ $suite->setSharedFixture($fixture);
+ }
+ }
+ return $suite;
+ }
+}
+
+Horde_Kolab_Storage_AllTests::init('Horde_Kolab_Storage', __FILE__);
+
+if (PHPUnit_MAIN_METHOD == 'Horde_Kolab_Storage_AllTests::main') {
+ Horde_Kolab_Storage_AllTests::main();
+}
diff --git a/framework/Kolab_Filter/test/Horde/Kolab/Filter/Autoload.php b/framework/Kolab_Filter/test/Horde/Kolab/Filter/Autoload.php
new file mode 100644
index 000000000..d92650cea
--- /dev/null
+++ b/framework/Kolab_Filter/test/Horde/Kolab/Filter/Autoload.php
@@ -0,0 +1,38 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Filter
+ */
+
+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__) . '/StoryTestCase.php';
diff --git a/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php b/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php
index a399dfe35..634f41b77 100644
--- a/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php
+++ b/framework/Kolab_Filter/test/Horde/Kolab/Filter/FilterTest.php
@@ -2,17 +2,20 @@
/**
* Test the base filter class within the Kolab filter implementation.
*
- * @package Horde_Kolab_Filter
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Filter
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel