Fixing tab/spaces.

This commit is contained in:
mark_story 2011-02-12 17:39:42 -05:00
parent 8c2e0815ec
commit 8ebbccbd76

View file

@ -52,82 +52,84 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
} }
/** /**
* @param array $argv * Ugly hack to get around PHPUnit having a hard coded classname for the Runner. :(
* @param boolean $exit *
*/ * @param array $argv
public function run(array $argv, $exit = TRUE) * @param boolean $exit
{ */
$this->handleArguments($argv); public function run(array $argv, $exit = TRUE)
{
$this->handleArguments($argv);
$runner = new CakeTestRunner($this->arguments['loader']); $runner = new CakeTestRunner($this->arguments['loader']);
if (is_object($this->arguments['test']) && if (is_object($this->arguments['test']) &&
$this->arguments['test'] instanceof PHPUnit_Framework_Test) { $this->arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $this->arguments['test']; $suite = $this->arguments['test'];
} else { } else {
$suite = $runner->getTest( $suite = $runner->getTest(
$this->arguments['test'], $this->arguments['test'],
$this->arguments['testFile'], $this->arguments['testFile'],
$this->arguments['syntaxCheck'] $this->arguments['syntaxCheck']
); );
} }
if (count($suite) == 0) { if (count($suite) == 0) {
$skeleton = new PHPUnit_Util_Skeleton_Test( $skeleton = new PHPUnit_Util_Skeleton_Test(
$suite->getName(), $suite->getName(),
$this->arguments['testFile'] $this->arguments['testFile']
); );
$result = $skeleton->generate(TRUE); $result = $skeleton->generate(TRUE);
if (!$result['incomplete']) { if (!$result['incomplete']) {
eval(str_replace(array('<?php', '?>'), '', $result['code'])); eval(str_replace(array('<?php', '?>'), '', $result['code']));
$suite = new PHPUnit_Framework_TestSuite( $suite = new PHPUnit_Framework_TestSuite(
$this->arguments['test'] . 'Test' $this->arguments['test'] . 'Test'
); );
} }
} }
if ($this->arguments['listGroups']) { if ($this->arguments['listGroups']) {
PHPUnit_TextUI_TestRunner::printVersionString(); PHPUnit_TextUI_TestRunner::printVersionString();
print "Available test group(s):\n"; print "Available test group(s):\n";
$groups = $suite->getGroups(); $groups = $suite->getGroups();
sort($groups); sort($groups);
foreach ($groups as $group) { foreach ($groups as $group) {
print " - $group\n"; print " - $group\n";
} }
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} }
unset($this->arguments['test']); unset($this->arguments['test']);
unset($this->arguments['testFile']); unset($this->arguments['testFile']);
try { try {
$result = $runner->doRun($suite, $this->arguments); $result = $runner->doRun($suite, $this->arguments);
} }
catch (PHPUnit_Framework_Exception $e) { catch (PHPUnit_Framework_Exception $e) {
print $e->getMessage() . "\n"; print $e->getMessage() . "\n";
} }
if ($exit) { if ($exit) {
if (isset($result) && $result->wasSuccessful()) { if (isset($result) && $result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} }
else if (!isset($result) || $result->errorCount() > 0) { else if (!isset($result) || $result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} }
else { else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
} }
} }
} }
/** /**
* Handler for customizing the FixtureManager class/ * Handler for customizing the FixtureManager class/