Skip to content

Commit

Permalink
Include more tests since other unit tests fails
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipxe13 authored and sebastianbergmann committed Feb 25, 2017
1 parent 48930fc commit 11ef962
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/Util/GetoptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,50 @@ public function testLongOptionDoesNotAllowAnArgumentException()

Getopt::getopt($args, '', ['foo']);
}

public function testItHandlesLongParametesWithValues()
{
$command = 'command parameter-0 --exec parameter-1 --conf config.xml --optn parameter-2 --optn=content-of-o parameter-n';
$args = explode(' ', $command);
unset($args[0]);
$expected = [
[
['--exec', null],
['--conf', 'config.xml'],
['--optn', null],
['--optn', 'content-of-o'],
],
[
'parameter-0',
'parameter-1',
'parameter-2',
'parameter-n',
],
];
$actual = Getopt::getopt($args, '', ['exec', 'conf=', 'optn==']);
$this->assertEquals($expected, $actual);
}

public function testItHandlesShortParametesWithValues()
{
$command = 'command parameter-0 -x parameter-1 -c config.xml -o parameter-2 -ocontent-of-o parameter-n';
$args = explode(' ', $command);
unset($args[0]);
$expected = [
[
['x', null],
['c', 'config.xml'],
['o', null],
['o', 'content-of-o'],
],
[
'parameter-0',
'parameter-1',
'parameter-2',
'parameter-n',
],
];
$actual = Getopt::getopt($args, 'xc:o::');
$this->assertEquals($expected, $actual);
}
}

0 comments on commit 11ef962

Please sign in to comment.