Skip to content

Commit

Permalink
Fix fatal error when checking for PHPUnit.
Browse files Browse the repository at this point in the history
Doubly including PHPUnit/Autoload.php causes fatal errors.
Having access to one of the PHPUnit classes means phpunit exists as
well.

Fixes cakephp#2890
  • Loading branch information
markstory committed May 19, 2012
1 parent c6258fa commit 7107cd6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Cake/Console/Shell.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -680,12 +680,14 @@ public function createFile($path, $contents) {
* @return boolean Success * @return boolean Success
*/ */
protected function _checkUnitTest() { protected function _checkUnitTest() {
if (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) { if (class_exists('PHPUnit_Framework_TestCase')) {
return true; return true;
} } elseif (@include 'PHPUnit' . DS . 'Autoload.php') {
if (@include 'PHPUnit' . DS . 'Autoload.php') { return true;
} elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) {
return true; return true;
} }

$prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?'); $prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?');
$unitTest = $this->in($prompt, array('y', 'n'), 'y'); $unitTest = $this->in($prompt, array('y', 'n'), 'y');
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes'; $result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
Expand Down

0 comments on commit 7107cd6

Please sign in to comment.