$cli = $parameters['output'];
}
list($options, $arguments) = $parser->parseArgs();
- $cli->message('OK');
+ if (count($arguments) == 0) {
+ $parser->printHelp();
+ } else {
+ switch ($arguments[0]) {
+ case 'folder':
+ break;
+ default:
+ $parser->printHelp();
+ }
+ }
}
static private function _prepareParser(array $parameters = array())
} else {
$parser_class = $parameters['parser']['class'];
}
+ $options = array(
+ new Horde_Argv_Option(
+ '-d',
+ '--driver',
+ array(
+ 'action' => 'store',
+ 'choices' => array('horde', 'php', 'pear', 'roundcube', 'mock'),
+ 'help' => Horde_Kolab_Storage_Translation::t('The IMAP driver that should be used')
+ )
+ ),
+ );
+ $usage = Horde_Kolab_Storage_Translation::t(
+ "[options] MODULE ACTION\nPossible MODULEs and ACTIONs:
+
+ folder - Handle folders.
+ list [default] - List the folders
+"
+ );
return new $parser_class(
array(
- 'usage' => '%prog ' . _("[options]")
+ 'usage' => '%prog ' . $usage,
+ 'optionList' => $options
)
);
}
/** Catch strict standards */
error_reporting(E_ALL | E_STRICT);
+
+/** Load the basic test definition */
+require_once dirname(__FILE__) . '/TestCase.php';
public function setUp()
{
- if ($this->sharedFixture === null) {
+ if (!isset($this->sharedFixture)) {
$this->markTestSkipped('Testing of a running server skipped. No configuration fixture available.');
return;
}
--- /dev/null
+<?php
+/**
+ * Basic test case.
+ *
+ * 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
+ */
+
+/**
+ * Basic test case.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license instorageion (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @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
+ */
+class Horde_Kolab_Storage_TestCase
+extends PHPUnit_Framework_TestCase
+{
+ protected function runCli()
+ {
+ ob_start();
+ Horde_Kolab_Storage_Cli::main(
+ array(
+ 'output' => new Horde_Test_Stub_Cli(),
+ 'parser' => array('class' => 'Horde_Test_Stub_Parser')
+ )
+ );
+ $output = ob_get_contents();
+ ob_end_clean();
+ return $output;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the modules of the CLI interface.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../Autoload.php';
+
+/**
+ * Test the modules of 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_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
+ */
+class Horde_Kolab_Storage_Unit_Cli_ModuleTest
+extends Horde_Kolab_Storage_TestCase
+{
+ public function testFolderModule()
+ {
+ $_SERVER['argv'] = array(
+ 'kolab-storage'
+ );
+ $this->assertRegExp(
+ '/folder - Handle folders/',
+ $this->runCli()
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * Test the options of the CLI interface.
+ *
+ * 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
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../Autoload.php';
+
+/**
+ * Test the options of 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_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
+ */
+class Horde_Kolab_Storage_Unit_Cli_OptionsTest
+extends Horde_Kolab_Storage_TestCase
+{
+ public function testOptionHelp()
+ {
+ $_SERVER['argv'] = array(
+ 'kolab-storage'
+ );
+ $this->assertRegExp(
+ '/-h,[ ]*--help[ ]*show this help message and exit/',
+ $this->runCli()
+ );
+ }
+
+ public function testOptionDriver()
+ {
+ $_SERVER['argv'] = array(
+ 'kolab-storage'
+ );
+ $this->assertRegExp(
+ '/-d[ ]*DRIVER,[ ]*--driver=DRIVER/',
+ $this->runCli()
+ );
+ }
+}
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
class Horde_Kolab_Storage_Unit_CliTest
-extends PHPUnit_Framework_TestCase
+extends Horde_Kolab_Storage_TestCase
{
public function testCli()
{
$_SERVER['argv'] = array(
'kolab-storage'
);
- ob_start();
- Horde_Kolab_Storage_Cli::main(
- array(
- 'output' => new Horde_Test_Stub_Cli(),
- 'parser' => array('class' => 'Horde_Test_Stub_Parser')
- )
+ $this->runCli();
+ }
+
+ public function testFolderList()
+ {
+ $_SERVER['argv'] = array(
+ 'kolab-storage',
+ 'list'
);
- $output = ob_get_contents();
- ob_end_clean();
+ $this->assertContains('INBOX', $this->runCli());
}
}