<?php

require_once 'PHPUnit/Util/Filter.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__);

require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'PHPEdit_ResultPrinter.php';

class PHPEdit_TestResult extends PHPUnit_Framework_TestResult
{
    public function run(PHPUnit_Framework_Test $test)
    {
        $this->startTest($test);
        $this->endTest($test, '');
	}
}

class PHPEdit_TestRunner extends PHPUnit_TextUI_TestRunner
{
    public static function run($test, array $parameters = array())
    {
        if ($test instanceof ReflectionClass) {
            $test = new PHPUnit_Framework_TestSuite($test);
        }

        if ($test instanceof PHPUnit_Framework_Test) {
            $aTestRunner = new PHPEdit_TestRunner;

            return $aTestRunner->doRun(
              $test,
              $parameters
            );
        }
    }

    protected function createTestResult()
    {
    	if (isset($_GET['findTests']) && $_GET['findTests'] == 'true')
		{
	        return new PHPEdit_TestResult();
    	}
    	return parent::createTestResult();
    }
}

?>
