1
0
mirror of synced 2024-12-14 07:06:04 +03:00

fixing to adhere to coding standards

This commit is contained in:
meus 2007-09-02 22:34:02 +00:00
parent 60d62da717
commit dc0c08aa58
2 changed files with 30 additions and 30 deletions

View File

@ -20,14 +20,14 @@ class GroupTest extends UnitTestCase
} }
public function shouldBeRun($testCase, $filter){ public function shouldBeRun($testCase, $filter){
if( ! is_array($filter)){ if( ! is_array($filter)) {
return true; return true;
} }
foreach($filter as $subFilter){ foreach($filter as $subFilter) {
$name = strtolower(get_class($testCase)); $name = strtolower(get_class($testCase));
$pos = strpos($name, strtolower($subFilter)); $pos = strpos($name, strtolower($subFilter));
//it can be 0 so we have to use === to see if false //it can be 0 so we have to use === to see if false
if($pos === false){ if ($pos === false) {
return false; return false;
} }
} }

View File

@ -3,11 +3,11 @@
ini_set('max_execution_time', 900); ini_set('max_execution_time', 900);
function parseOptions($array) { function parseOptions($array) {
$currentName=""; $currentName='';
$options=array(); $options=array();
foreach($array as $name) { foreach($array as $name) {
if(strpos($name,"-")===0) { if(strpos($name,'-')===0) {
$name=str_replace("-","",$name); $name=str_replace('-','',$name);
$currentName=$name; $currentName=$name;
if( ! isset($options[$currentName])) { if( ! isset($options[$currentName])) {
$options[$currentName]=array(); $options[$currentName]=array();
@ -415,39 +415,39 @@ class MyReporter extends HtmlReporter {
public function paintFooter() public function paintFooter()
{ {
print "<pre>"; print '<pre>';
foreach ($this->_test->getMessages() as $message) { foreach ($this->_test->getMessages() as $message) {
print $message . "\n"; print $message . '\n';
} }
print "</pre>"; print '</pre>';
$colour = ($this->_test->getFailCount() > 0 ? "red" : "green"); $colour = ($this->_test->getFailCount() > 0 ? 'red' : 'green');
print "<div style=\""; print '<div style=\'';
print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;"; print 'padding: 8px; margin-top: 1em; background-color: $colour; color: white;';
print "\">"; print '\'>';
print $this->_test->getTestCaseCount() . ' test cases'; print $this->_test->getTestCaseCount() . ' test cases';
print " test cases complete:\n"; print ' test cases complete:\n';
print "<strong>" . $this->_test->getPassCount() . "</strong> passes and "; print '<strong>' . $this->_test->getPassCount() . '</strong> passes and ';
print "<strong>" . $this->_test->getFailCount() . "</strong> fails."; print '<strong>' . $this->_test->getFailCount() . '</strong> fails.';
print "</div>\n"; print '</div>';
} }
} }
?> ?>
<?php <?php
if (PHP_SAPI === "cli") { if (PHP_SAPI === 'cli') {
$reporter = new CliReporter(); $reporter = new CliReporter();
} else { } else {
$reporter = new MyReporter(); $reporter = new MyReporter();
} }
$argv = $_SERVER["argv"]; $argv = $_SERVER['argv'];
array_shift($argv); array_shift($argv);
$options = parseOptions($argv); $options = parseOptions($argv);
if( isset($options["group"])) { if( isset($options['group'])) {
$testGroup = new GroupTest("Custom"); $testGroup = new GroupTest('Custom');
foreach($options["group"] as $group) { foreach($options['group'] as $group) {
if( ! isset($$group)) { if( ! isset($$group)) {
if (class_exists($group)) { if (class_exists($group)) {
$testGroup->addTestCase(new $group); $testGroup->addTestCase(new $group);
@ -459,12 +459,12 @@ if( isset($options["group"])) {
} else { } else {
$testGroup = $test; $testGroup = $test;
} }
$filter = ""; $filter = '';
if(isset($options["filter"])){ if (isset($options['filter'])) {
$filter = $options["filter"]; $filter = $options['filter'];
} }
if (isset($options["help"])) { if (isset($options['help'])) {
echo "Doctrine test runner help\n"; echo "Doctrine test runner help\n";
echo "===========================\n"; echo "===========================\n";
echo " To run all tests simply run this script without arguments. \n"; echo " To run all tests simply run this script without arguments. \n";
@ -476,13 +476,13 @@ if (isset($options["help"])) {
die(); die();
} }
if (isset($options["coverage"])) { if (isset($options['coverage'])) {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$testGroup->run($reporter, $filter); $testGroup->run($reporter, $filter);
$result["path"] = Doctrine::getPath() . DIRECTORY_SEPARATOR; $result['path'] = Doctrine::getPath() . DIRECTORY_SEPARATOR;
$result["coverage"] = xdebug_get_code_coverage(); $result['coverage'] = xdebug_get_code_coverage();
xdebug_stop_code_coverage(); xdebug_stop_code_coverage();
file_put_contents("coverage.txt", serialize($result)); file_put_contents('coverage.txt', serialize($result));
} else { } else {
$testGroup->run($reporter, $filter); $testGroup->run($reporter, $filter);
} }