From: Gunnar Wrobel Date: Fri, 10 Dec 2010 05:17:44 +0000 (+0100) Subject: Simple CLI test. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d9d403d6c79fad5adc32b10b547d7f45b57ec9dc;p=horde.git Simple CLI test. --- diff --git a/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php b/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php index e26148146..7a38e4539 100644 --- a/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php +++ b/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php @@ -52,12 +52,9 @@ class Horde_Kolab_Format_Cli list($options, $arguments) = $parser->parseArgs(); $factory = new Horde_Kolab_Format_Factory(); $timed = $factory->createTimed('xml', 'task'); - for ($i = 0; $i < 1000; $i++) { - $timed->load( - file_get_contents($arguments[0]) - ); - } - $cli->message($timed->timeSpent()); + $content = file_get_contents($arguments[0]); + $timed->load($content); + $cli->message(floor($timed->timeSpent() * 1000) . ' ms'); } static private function _prepareParser(array $parameters = array()) diff --git a/framework/Kolab_Format/package.xml b/framework/Kolab_Format/package.xml index fae382bbd..e3b41c76e 100644 --- a/framework/Kolab_Format/package.xml +++ b/framework/Kolab_Format/package.xml @@ -29,8 +29,8 @@ jan@horde.org yes - 2010-12-09 - + 2010-12-10 + 1.1.0 1.1.0 @@ -88,6 +88,7 @@ + @@ -394,6 +395,7 @@ + @@ -463,6 +465,7 @@ + @@ -585,6 +588,7 @@ + @@ -724,7 +728,7 @@ stable stable - 2010-12-09 + 2010-12-10 LGPL * Removed dependency on the Kolab package within the task handler. diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/Unit/CliTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/Unit/CliTest.php new file mode 100644 index 000000000..e2892551d --- /dev/null +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/Unit/CliTest.php @@ -0,0 +1,58 @@ + + * @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 CLI interface. + * + * 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 + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Format + */ +class Horde_Kolab_Format_Unit_CliTest +extends PHPUnit_Framework_TestCase +{ + public function testCli() + { + $_SERVER['argv'] = array( + 'kolab-format', + dirname(__FILE__) . '/../fixtures/task.xml' + ); + ob_start(); + Horde_Kolab_Format_Cli::main( + array( + 'output' => new Horde_Test_Stub_Cli(), + 'parser' => array('class' => 'Horde_Test_Stub_Parser') + ) + ); + $output = ob_get_contents(); + ob_end_clean(); + $this->assertRegExp( + '/INFO.*[0-9]+ ms/', + $output + ); + } +}