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())
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-12-09</date>
- <time>11:19:50</time>
+ <date>2010-12-10</date>
+ <time>06:10:51</time>
<version>
<release>1.1.0</release>
<api>1.1.0</api>
<file name="Note.php" role="php" />
<file name="Task.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Format/Xml -->
+ <file name="Cli.php" role="php" />
<file name="Date.php" role="php" />
<file name="Exception.php" role="php" />
<file name="Factory.php" role="php" />
<dir name="Decorator">
<file name="TimedTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Format/Unit/Decorator -->
+ <file name="CliTest.php" role="test" />
<file name="FactoryTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Format/Unit -->
<file name="AllTests.php" role="test" />
<install as="Horde/Kolab/Format/event.php" name="examples/Horde/Kolab/Format/event.php" />
<install as="Horde/Kolab/Format/new_type.php" name="examples/Horde/Kolab/Format/new_type.php" />
<install as="Horde/Kolab/Format.php" name="lib/Horde/Kolab/Format.php" />
+ <install as="Horde/Kolab/Format/Cli.php" name="lib/Horde/Kolab/Format/Cli.php" />
<install as="Horde/Kolab/Format/Date.php" name="lib/Horde/Kolab/Format/Date.php" />
<install as="Horde/Kolab/Format/Exception.php" name="lib/Horde/Kolab/Format/Exception.php" />
<install as="Horde/Kolab/Format/Factory.php" name="lib/Horde/Kolab/Format/Factory.php" />
<install as="Horde/Kolab/Format/Integration/fixtures/preferences_write_old.xml" name="test/Horde/Kolab/Format/Integration/fixtures/preferences_write_old.xml" />
<install as="Horde/Kolab/Format/Integration/fixtures/recur.xml" name="test/Horde/Kolab/Format/Integration/fixtures/recur.xml" />
<install as="Horde/Kolab/Format/Integration/fixtures/recur_fail.xml" name="test/Horde/Kolab/Format/Integration/fixtures/recur_fail.xml" />
+ <install as="Horde/Kolab/Format/Unit/CliTest.php" name="test/Horde/Kolab/Format/Unit/CliTest.php" />
<install as="Horde/Kolab/Format/Unit/FactoryTest.php" name="test/Horde/Kolab/Format/Unit/FactoryTest.php" />
<install as="Horde/Kolab/Format/Unit/Decorator/TimedTest.php" name="test/Horde/Kolab/Format/Unit/Decorator/TimedTest.php" />
<install as="COPYING" name="COPYING" />
<release>stable</release>
<api>stable</api>
</stability>
- <date>2010-12-09</date>
+ <date>2010-12-10</date>
<license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
<notes>
* Removed dependency on the Kolab package within the task handler.
--- /dev/null
+<?php
+/**
+ * Test the CLI interface.
+ *
+ * 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 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 <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_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
+ );
+ }
+}