diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-05-18 21:02:24 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-05-18 21:02:24 +0200 |
commit | 54b26fbe1e0f9efaba143d88ea8581933f5c8dc8 (patch) | |
tree | 02ddfd47a36c16074ef4303ffcf0f892d5fef73a /_test | |
parent | 18496fe0decfb1382393daca3141bf315cda7254 (diff) | |
parent | b2e7cc706ef0f8a622d9973c418cc40e4addc436 (diff) | |
download | rpg-54b26fbe1e0f9efaba143d88ea8581933f5c8dc8.tar.gz rpg-54b26fbe1e0f9efaba143d88ea8581933f5c8dc8.tar.bz2 |
Merge pull request #720 from splitbrain/newcli
Refactored the CLI stuff
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/cli_options.test.php | 56 |
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 |