Skip to content

Commit e9035f3

Browse files
jrfnlgrogy
authored andcommitted
SettingsParseArgumentsTest: add new test for handling of unsupported arguments
1 parent 4af1a70 commit e9035f3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/Unit/SettingsParseArgumentsTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,48 @@
77

88
class SettingsParseArgumentsTest extends UnitTestCase
99
{
10+
/**
11+
* Test that an exception is thrown when an unsupported argument is passed.
12+
*
13+
* @dataProvider dataParseArgumentsInvalidArgument
14+
*
15+
* @param string $command The command as received from the command line.
16+
* @param string $unsupported The unsupported argument which should trigger the exception.
17+
*
18+
* @return void
19+
*/
20+
public function testParseArgumentsInvalidArgument($command, $unsupported)
21+
{
22+
$this->expectExceptionPolyfill('PHP_Parallel_Lint\PhpParallelLint\Exceptions\InvalidArgumentException');
23+
$this->expectExceptionMessagePolyfill('Invalid argument ' . $unsupported);
24+
25+
$argv = explode(' ', $command);
26+
Settings::parseArguments($argv);
27+
}
28+
29+
/**
30+
* Data provider.
31+
*
32+
* @return array
33+
*/
34+
public function dataParseArgumentsInvalidArgument()
35+
{
36+
return array(
37+
'Unsupported short argument' => array(
38+
'command' => './parallel-lint --colors -u . --exclude vendor',
39+
'unsupported' => '-u',
40+
),
41+
'Unsupported long argument' => array(
42+
'command' => './parallel-lint . --no-progress --unsupported-arg',
43+
'unsupported' => '--unsupported-arg',
44+
),
45+
'Unsupported argument split by = sign' => array(
46+
'command' => './parallel-lint --exclude=vendor',
47+
'unsupported' => '--exclude=vendor',
48+
),
49+
);
50+
}
51+
1052
/**
1153
* Test parsing the arguments received from the command line.
1254
*

0 commit comments

Comments
 (0)