From a1e2e89b3fc6fb5effa820367a88b3b95c10e187 Mon Sep 17 00:00:00 2001 From: Brian Scaturro Date: Tue, 22 Jan 2013 11:19:48 -0500 Subject: [PATCH] allow config to be present but don't verify file exists in console --- functional/PHPUnitTest.php | 9 +++++++++ src/ParaTest/Console/Testers/PHPUnit.php | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/functional/PHPUnitTest.php b/functional/PHPUnitTest.php index ac79ffc9..d57cf578 100644 --- a/functional/PHPUnitTest.php +++ b/functional/PHPUnitTest.php @@ -30,6 +30,14 @@ public function testWithConfigurationInDirWithoutConfigFile() $this->assertResults($results); } + public function testWithConfigurationThatDoesNotExist() + { + chdir(dirname(FIXTURES)); + $this->path = ''; + $results = $this->paratest(array('configuration' => FIXTURES . DS . 'phpunit.xml.disto')); + $this->assertRegExp('/Could not read ".*phpunit.xml.disto"./', $results); + } + public function testFunctionalWithBootstrap() { $results = $this->paratest(array('bootstrap' => BOOTSTRAP, 'functional' => '')); @@ -167,6 +175,7 @@ public function testRunWithFatalRuntimeErrorOutputsError() public function testRunWithoutPathArgumentDisplaysUsage() { $this->path = ''; + chdir(dirname(FIXTURES)); $result = $this->paratest(); $usage = file_get_contents(FIXTURES . DS . 'output' . DS . 'usage.txt'); $this->assertEquals($usage, $result); diff --git a/src/ParaTest/Console/Testers/PHPUnit.php b/src/ParaTest/Console/Testers/PHPUnit.php index 802cb4f3..5b717a36 100644 --- a/src/ParaTest/Console/Testers/PHPUnit.php +++ b/src/ParaTest/Console/Testers/PHPUnit.php @@ -26,7 +26,7 @@ public function configure(Command $command) public function execute(InputInterface $input, OutputInterface $output) { - if(!$this->canFindConfig($input) && !$this->hasPath($input)) + if(!$this->hasConfig($input) && !$this->hasPath($input)) $this->displayHelp($input, $output); $runner = new Runner($this->getRunnerOptions($input)); $runner->run(); @@ -40,11 +40,11 @@ protected function hasPath(InputInterface $input) return $argument || $option; } - protected function canFindConfig(InputInterface $input) + protected function hasConfig(InputInterface $input) { $cwd = getcwd() . DIRECTORY_SEPARATOR; - if($input->hasOption('configuration') && file_exists($input->getOption('configuration'))) + if($input->getOption('configuration')) return true; return file_exists($cwd . 'phpunit.xml.dist') || file_exists($cwd . 'phpunit.xml');