* @package Kolab_Filter
*/
-/** Load the Filter libraries */
-require_once dirname(__FILE__) . '/Response.php';
-
/**
* A basic definition for a PHP based postfix filter.
*
*/
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.
*/
{
/* Setup the temporary storage */
$result = $this->_initTmp();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceOf PEAR_Error) {
return $result;
}
}
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']);
--- /dev/null
+<?php
+/**
+ * All tests for the Kolab_Storage:: package.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Storage
+ * @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_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();
+}
--- /dev/null
+<?php
+/**
+ * Setup autoloading for the tests.
+ *
+ * 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_Filter
+ * @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_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';
/**
* 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 <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Filter
*/
/**
- * We need the unit test framework
+ * Prepare the test setup.
*/
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/Extensions/OutputTestCase.php';
-
-require_once 'Horde.php';
-require_once 'Horde/Kolab/Filter/Incoming.php';
+require_once dirname(__FILE__) . '/Autoload.php';
/**
* Test the filter class.
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
*
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @package Horde_Kolab_Filter
+ * @category Kolab
+ * @package Kolab_Filter
+ * @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_Filter
*/
class Horde_Kolab_Filter_FilterTest extends PHPUnit_Framework_TestCase
{
$_SERVER['argv'] = array($_SERVER['argv'][0]);
$parser = &new Horde_Kolab_Filter_Incoming();
$inh = fopen(dirname(__FILE__) . '/fixtures/tiny.eml', 'r');
- $result = $parser->parse($inh, 'echo');
-
- $this->assertTrue(is_a($result, 'PEAR_Error'));
-
- $this->assertContains('Please provide one or more recipients.', $result->getMessage());
+ try {
+ $result = $parser->parse($inh, 'echo');
+ } catch (Horde_Kolab_Filter_Exception $e) {
+ $this->assertContains('Please provide one or more recipients.', $e->getMessage());
+ return;
+ }
+ $this->assertFail('No exception!');
}
}
--- /dev/null
+<?php
+/**
+ * Base for scenario based testing of this package.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Filter
+ * @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_Filter
+ */
+
+/**
+ * Base for scenario based testing of this package.
+ *
+ * Copyright 2010 Klarälvdalens Datakonsult AB
+ *
+ * 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_Filter
+ * @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_Filter
+ */
+class Horde_Kolab_Filter_StoryTestCase
+extends PHPUnit_Extensions_Story_TestCase
+{
+ /**
+ * Handle a "given" step.
+ *
+ * @param array &$world Joined "world" of variables.
+ * @param string $action The description of the step.
+ * @param array $arguments Additional arguments to the step.
+ *
+ * @return mixed The outcome of the step.
+ */
+ public function runGiven(&$world, $action, $arguments)
+ {
+ switch($action) {
+ case 'that no Kolab server configuration file can be found':
+ break;
+ default:
+ return $this->notImplemented($action);
+ }
+ }
+
+ /**
+ * Handle a "when" step.
+ *
+ * @param array &$world Joined "world" of variables.
+ * @param string $action The description of the step.
+ * @param array $arguments Additional arguments to the step.
+ *
+ * @return mixed The outcome of the step.
+ */
+ public function runWhen(&$world, $action, $arguments)
+ {
+ switch($action) {
+ case 'reading the configuration':
+ break;
+ default:
+ return $this->notImplemented($action);
+ }
+ }
+
+ /**
+ * Handle a "then" step.
+ *
+ * @param array &$world Joined "world" of variables.
+ * @param string $action The description of the step.
+ * @param array $arguments Additional arguments to the step.
+ *
+ * @return mixed The outcome of the step.
+ */
+ public function runThen(&$world, $action, $arguments)
+ {
+ switch($action) {
+ case 'the Config Object will throw an exception of type':
+ break;
+ default:
+ return $this->notImplemented($action);
+ }
+ }
+
+}
\ No newline at end of file