summaryrefslogtreecommitdiff
path: root/_test/tests/inc/cli_options.test.php
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2014-09-28 13:46:04 +0200
committerGerrit Uitslag <klapinklapin@gmail.com>2014-09-28 13:46:04 +0200
commitb79379f2e598abaa2febb299cdfcebe0a95d034c (patch)
tree7098c3a758f606394f4b38d679b5198f8973cffe /_test/tests/inc/cli_options.test.php
parent73411587cb6d2c54aefebe90c87799c4aa1d31ec (diff)
parentda9572711f54d13ce3c5506971154b0bc359723f (diff)
downloadrpg-b79379f2e598abaa2febb299cdfcebe0a95d034c.tar.gz
rpg-b79379f2e598abaa2febb299cdfcebe0a95d034c.tar.bz2
Merge remote-tracking branch 'origin/master' into overridablelangstrings
Conflicts: inc/plugin.php
Diffstat (limited to '_test/tests/inc/cli_options.test.php')
-rw-r--r--_test/tests/inc/cli_options.test.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/_test/tests/inc/cli_options.test.php b/_test/tests/inc/cli_options.test.php
new file mode 100644
index 000000000..ab03ee29b
--- /dev/null
+++ b/_test/tests/inc/cli_options.test.php
@@ -0,0 +1,56 @@
+<?php
+
+class cli_options extends DokuWikiTest {
+
+ function test_simpleshort() {
+ $options = new DokuCLI_Options();
+ $options->registerOption('exclude', 'exclude files', 'x', 'file');
+
+ $options->args = array('-x', 'foo', 'bang');
+ $options->parseOptions();
+
+ $this->assertEquals('foo', $options->getOpt('exclude'));
+ $this->assertEquals(array('bang'), $options->args);
+ $this->assertFalse($options->getOpt('nothing'));
+ }
+
+ function test_simplelong1() {
+ $options = new DokuCLI_Options();
+ $options->registerOption('exclude', 'exclude files', 'x', 'file');
+
+ $options->args = array('--exclude', 'foo', 'bang');
+ $options->parseOptions();
+
+ $this->assertEquals('foo', $options->getOpt('exclude'));
+ $this->assertEquals(array('bang'), $options->args);
+ $this->assertFalse($options->getOpt('nothing'));
+ }
+
+ function test_simplelong2() {
+ $options = new DokuCLI_Options();
+ $options->registerOption('exclude', 'exclude files', 'x', 'file');
+
+ $options->args = array('--exclude=foo', 'bang');
+ $options->parseOptions();
+
+ $this->assertEquals('foo', $options->getOpt('exclude'));
+ $this->assertEquals(array('bang'), $options->args);
+ $this->assertFalse($options->getOpt('nothing'));
+ }
+
+ function test_complex() {
+ $options = new DokuCLI_Options();
+
+ $options->registerOption('plugins', 'run on plugins only', 'p');
+ $options->registerCommand('status', 'display status info');
+ $options->registerOption('long', 'display long lines', 'l', false, 'status');
+
+ $options->args = array('-p', 'status', '--long', 'foo');
+ $options->parseOptions();
+
+ $this->assertEquals('status', $options->getCmd());
+ $this->assertTrue($options->getOpt('plugins'));
+ $this->assertTrue($options->getOpt('long'));
+ $this->assertEquals(array('foo'), $options->args);
+ }
+} \ No newline at end of file