mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
5606e9278b
svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/events ........ r47699 | sminnee | 2008-01-08 12:11:28 +1300 (Tue, 08 Jan 2008) | 1 line Fixed TestRunner ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47709 467b73ca-7a2a-4603-9d3b-597d59a354a9
68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php
|
|
|
|
// Check that PHPUnit is installed
|
|
$hasPhpUnit = false;
|
|
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
|
foreach($paths as $path) {
|
|
if(@file_exists("$path/PHPUnit/Framework.php")) $hasPhpUnit = true;
|
|
}
|
|
|
|
if($hasPhpUnit) {
|
|
|
|
require_once 'PHPUnit/Framework.php';
|
|
require_once 'PHPUnit/TextUI/TestRunner.php';
|
|
|
|
/**
|
|
* Controller that executes PHPUnit tests
|
|
*/
|
|
class TestRunner extends Controller {
|
|
/**
|
|
* Run all test classes
|
|
*/
|
|
function index() {
|
|
$tests = ClassInfo::subclassesFor('SapphireTest');
|
|
array_shift($tests);
|
|
|
|
$this->runTests($tests);
|
|
}
|
|
|
|
/**
|
|
* Run only a single test class
|
|
*/
|
|
function only() {
|
|
$className = $this->urlParams['ID'];
|
|
if(class_exists($className)) {
|
|
$this->runTests(array($className));
|
|
} else {
|
|
echo "Class '$className' not found";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function runTests($classList) {
|
|
echo "<h1>Sapphire PHPUnit Test Runner</h1>";
|
|
echo "<p>Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "</p>";
|
|
|
|
echo "<pre>";
|
|
$suite = new PHPUnit_Framework_TestSuite();
|
|
foreach($classList as $className) {
|
|
// Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this.
|
|
class_exists($className);
|
|
$suite->addTest(new PHPUnit_Framework_TestSuite($className));
|
|
}
|
|
|
|
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
|
|
PHPUnit_TextUI_TestRunner::run($suite);
|
|
}
|
|
}
|
|
|
|
} else {
|
|
|
|
class TestRunner extends Controller {
|
|
function index() {
|
|
echo "Please install PHPUnit using pear.";
|
|
}
|
|
}
|
|
|
|
} |