Skip to content
Browse files

Positional argument count check introduced

  • Loading branch information...
1 parent 83aea0e commit 6ac554ede32330e3775c231cabe0f7b513770e6c @olivergondza olivergondza committed with edorian Aug 31, 2011
Showing with 27 additions and 0 deletions.
  1. +9 −0 PHPUnit/TextUI/Command.php
  2. +18 −0 Tests/TextUI/positional-arguments.phpt
View
9 PHPUnit/TextUI/Command.php
@@ -528,6 +528,15 @@ protected function handleArguments(array $argv)
$this->handleCustomTestSuite();
if (!isset($this->arguments['test'])) {
+ if (count($this->options[1]) > 2) {
+ $this->showMessage(
+ 'More than two positional arguments provided.',
+ false
+ );
+ $this->showHelp();
+ exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
+ }
+
if (isset($this->options[1][0])) {
$this->arguments['test'] = $this->options[1][0];
}
View
18 Tests/TextUI/positional-arguments.phpt
@@ -0,0 +1,18 @@
+--TEST--
+phpunit FailureTest ../_files/FailureTest.php SomethingElse
+--FILE--
+<?php
+$_SERVER['argv'][1] = '--no-configuration';
+$_SERVER['argv'][2] = 'FailureTest';
+$_SERVER['argv'][3] = dirname(dirname(__FILE__)) . '/_files/FailureTest.php';
+$_SERVER['argv'][4] = 'SomethingElse';
+
+require_once dirname(dirname(dirname(__FILE__))) . '/PHPUnit/Autoload.php';
+PHPUnit_TextUI_Command::main();
+?>
+--EXPECTF--
+PHPUnit %s by Sebastian Bergmann.
+
+More than two positional arguments provided.
+
+Usage: %s

0 comments on commit 6ac554e

Please sign in to comment.
Something went wrong with that request. Please try again.