diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-05-19 20:45:57 +0200 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-05-19 20:45:57 +0200 |
commit | b66e5840006078112b8da741b2c612e446afd452 (patch) | |
tree | a7067fa152428b3c0b41cae8435a94997167bacb /_test/tests/inc/cli_options.test.php | |
parent | c8d7c9382a31eaccc516f088312894797f4fe4bb (diff) | |
parent | 54b26fbe1e0f9efaba143d88ea8581933f5c8dc8 (diff) | |
download | rpg-b66e5840006078112b8da741b2c612e446afd452.tar.gz rpg-b66e5840006078112b8da741b2c612e446afd452.tar.bz2 |
Merge remote-tracking branch 'origin/master' into trailingcolons
Conflicts:
lib/plugins/usermanager/lang/nl/intro.txt
Diffstat (limited to '_test/tests/inc/cli_options.test.php')
-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 |