diff --git a/Makefile b/Makefile index 2d46fb1c7..142acd787 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,13 @@ # # Most users should simply visit the site root in your web browser. # - +# URL=`./cli-script.php SapphireInfo/baseurl` -test: windmill +test: phpunit + +phpunit: + php5 ./cli-script.php TestRunner windmill: functest ../cms/tests/test_windmill url=${URL}admin browser=firefox diff --git a/testing/TestRunner.php b/testing/TestRunner.php index 2134f9dc2..87ede895e 100644 --- a/testing/TestRunner.php +++ b/testing/TestRunner.php @@ -53,6 +53,7 @@ class TestRunner extends Controller { if(hasPhpUnit()) { $tests = ClassInfo::subclassesFor('SapphireTest'); array_shift($tests); + unset($tests['FunctionalTest']); $this->runTests($tests); } else { @@ -75,16 +76,21 @@ class TestRunner extends Controller { } function runTests($classList) { - self::$default_reporter->writeHeader(); - echo '
'; - echo "

Sapphire PHPUnit Test Runner

"; - echo "

Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "

"; - echo "
"; - echo '
'; - echo "
";
+		if(!Director::is_cli()) {
+			self::$default_reporter->writeHeader();
+			echo '
'; + echo "

Sapphire PHPUnit Test Runner

"; + echo "

Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "

"; + echo "
"; + echo '
'; + echo "
";
+		} else {
+			echo "Sapphire PHPUnit Test Runner\n";
+			echo "Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "\n\n";
+		}
 		
 		// Remove our error handler so that PHP can use its own
-		restore_error_handler();	
+		//restore_error_handler();	
 		
 		$suite = new PHPUnit_Framework_TestSuite();
 		foreach($classList as $className) {
@@ -94,13 +100,17 @@ class TestRunner extends Controller {
 		}
 
 		/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
-		PHPUnit_TextUI_TestRunner::run($suite);
-		echo '
'; + $testResult = PHPUnit_TextUI_TestRunner::run($suite); + + if(!Director::is_cli()) echo '
'; // Put the error handlers back Debug::loadErrorHandlers(); - self::$default_reporter->writeFooter(); + if(!Director::is_cli()) self::$default_reporter->writeFooter(); + + // Todo: we should figure out how to pass this data back through Director more cleanly + if(Director::is_cli() && $testResult->errorCount() > 0) exit(2); } }