Beispiel #1
0
function runUnitTest($testClassName, $classPath)
{
    $path = DATA_DIR . 'unit_test/' . $testClassName . '.dat';
    $dir = dirname($path);
    if (!file_exists($dir)) {
        mkdir($dir, 0777, true);
    }
    $suite = new PHPUnit2_Framework_TestSuite($testClassName);
    $result = PHPUnit2_TextUI_TestRunner::run($suite, $path);
    $text = file_get_contents($path);
    $data = unserialize($text);
    $lines = array();
    foreach ($data as $func => $targets) {
        $target = $targets[$classPath];
        if (!$target) {
            $classPath2 = str_replace('/', '\\', $classPath);
            $target = $targets[$classPath2];
        }
        if (!$target) {
            continue;
        }
        foreach ($target as $line => $value) {
            if ($lines[$line] < 1) {
                $lines[$line] = $value;
            } else {
                $lines[$line]++;
            }
        }
    }
    ksort($lines);
    //var_dump( $lines );
    $file = fopen($classPath, "r");
    if (!$file) {
        print "NOT FOUND ! {$classPath}\n";
        return;
    }
    print "<hr>\n<html>\n<style type='text/css'><!--\n";
    print "\t.no { background-color: #FF8888; }\n";
    print "\t.passed { background-color: #BBBBFF; }\n";
    print "--></style>\n<body>\n";
    $index = 1;
    while ($line = fgets($file)) {
        $line = rtrim($line);
        $line = str_replace("\t", "&nbsp;&nbsp;", $line);
        if ($lines[$index] > 0) {
            print "<div class='passed'>{$index}: ";
        } else {
            if ($lines[$index] == -1) {
                print "<div class='no'>{$index}: ";
            } else {
                print "<div>{$index}: ";
            }
        }
        print $line . "</div>\n";
        $index++;
    }
    fclose($file);
    print "</body></html>";
}
Beispiel #2
0
 public static function main()
 {
     $parameters = array();
     if (TESTS_GENERATE_REPORT && extension_loaded('xdebug')) {
         $parameters = array('reportDirectory' => TESTS_GENERATE_REPORT_TARGET);
     }
     PHPUnit2_TextUI_TestRunner::run(self::suite(), $parameters);
 }
Beispiel #3
0
 /**
  * Runs the test methods of this class.
  *
  * @access public
  * @static
  */
 public static function main()
 {
     require_once "PHPUnit2/TextUI/TestRunner.php";
     $suite = new PHPUnit2_Framework_TestSuite("InputFilterTest");
     $result = PHPUnit2_TextUI_TestRunner::run($suite);
 }
Beispiel #4
0
 public static function main()
 {
     PHPUnit2_TextUI_TestRunner::run(self::suite());
 }
    $dsn = $argv[1];
}
$testSuite = new PHPUnit2_Framework_TestSuite($dsn);
// ----------------------------------------------------------------------------
// TESTS ----------------------------------------------------------------------
// ----------------------------------------------------------------------------
$timer = new Benchmark_Timer();
$timer->start();
// (1) Add Generic (non-Driver) Tests
// ----------------------------------
require_once 'creole/CreoleTest.php';
$testSuite->addTestSuite(new ReflectionClass('CreoleTest'));
require_once 'creole/util/sql/SQLStatementExtractorTest.php';
$testSuite->addTestSuite(new ReflectionClass('SQLStatementExtractorTest'));
// (2) Driver Tests
// ----------------
include_once 'creole/drivers/DriverTestManager.php';
print "--------------------------------------\n";
print "| Running driver tests               |\n";
print "--------------------------------------\n";
$timer->setMarker("start driver tests");
print "DSN: " . $dsn . "\n\n";
print "[It is safe to ignore any errors related to dropping nonexistant tables.]\n\n";
try {
    DriverTestManager::addSuite($testSuite, $dsn);
    PHPUnit2_TextUI_TestRunner::run($testSuite);
} catch (Exception $e) {
    print "Could not add suite for " . $dsn . ": " . $e->getMessage();
}
$timer->stop();
$timer->display();
Beispiel #6
0
// ----------------------------------------------------------
$typesSuite = new PHPUnit2_Framework_TestSuite("Phing Types");
include_once 'phing/types/MapperTest.php';
$typesSuite->addTestSuite(new ReflectionClass('MapperTest'));
include_once 'phing/filters/LineContainsTest.php';
$typesSuite->addTestSuite(new ReflectionClass('LineContainsTest'));
include_once 'phing/types/CommandlineTest.php';
$typesSuite->addTestSuite(new ReflectionClass('CommandlineTest'));
include_once 'phing/types/FileSetTest.php';
$typesSuite->addTestSuite(new ReflectionClass('FileSetTest'));
// ----------------------------------------------------------
// tasks
// ----------------------------------------------------------
$tasksSuite = new PHPUnit2_Framework_TestSuite("Phing Tasks");
include_once 'phing/tasks/TypedefTaskTest.php';
$tasksSuite->addTestSuite(new ReflectionClass('TypedefTaskTest'));
// Conditions
include_once 'phing/tasks/condition/ContainsConditionTest.php';
include_once 'phing/tasks/condition/EqualsConditionTest.php';
$tasksSuite->addTestSuite(new ReflectionClass('ContainsConditionTest'));
$tasksSuite->addTestSuite(new ReflectionClass('EqualsConditionTest'));
include_once 'phing/tasks/PropertyTaskTest.php';
$tasksSuite->addTestSuite(new ReflectionClass('PropertyTaskTest'));
$suite = new PHPUnit2_Framework_TestSuite('Phing Tests');
$suite->addTest($coreSuite);
$suite->addTest($typesSuite);
$suite->addTest($tasksSuite);
// Run it!
PHPUnit2_TextUI_TestRunner::run($suite);
// SHUTDOWN PHING
Phing::shutdown();
Beispiel #7
0
* disappear under ZDE. The knack is to define our own ResultPrinter which just echoes the output. 
*
* This code started off looking like the skeleton code in http://www.phpunit.de/en/phpunit2_skeleton.php
* ... plus the calls to create a TestRunner and invoke it from from PHPUnit2_TextUI_TestRunner::run
* ... plus a bit of research to understand how to see how to define a result printer
* ... but its roots are probably now unrecognisable :-)
*
************************************************************************************************************/
/**********************************************************
* Get a TestRunner
* You have to define the PHPUnit2_MAIN_METHOD constant to something - the examples show this being the main
* method for the test suite but we do not need one here. Actually as long as it is not set to NULL it's OK. 
**********************************************************/
define("PHPUnit2_MAIN_METHOD", "anythingwilldo!!!ZDERunner::main");
require_once "PHPUnit2/TextUI/TestRunner.php";
$aTestRunner = new PHPUnit2_TextUI_TestRunner();
/**********************************************************
* Get a result printer and set it on the test runner
/**********************************************************/
require_once "PHPUnit2/TextUI/ResultPrinter.php";
class MYResultPrinter extends PHPUnit2_TextUI_ResultPrinter
{
    public function write($buffer)
    {
        // override the default implementation which uses fputs to stdout
        echo $buffer;
    }
}
$printer = new MYResultPrinter();
$aTestRunner->setPrinter($printer);
/**********************************************************
 /**
  * @param  PHPUnit2_Framework_Test $suite
  * @access public
  * @static
  */
 public static function runAndWait(PHPUnit2_Framework_Test $suite)
 {
     $aTestRunner = new PHPUnit2_TextUI_TestRunner();
     $aTestRunner->doRun($suite, true);
 }
Beispiel #9
0
 /**
  * @access private
  * @since  Method available since Release 2.2.0
  */
 private static function printVersionString()
 {
     if (!self::$versionStringPrinted) {
         print PHPUnit2_Runner_Version::getVersionString() . "\n\n";
         self::$versionStringPrinted = TRUE;
     }
 }
 public static function main()
 {
     require_once 'PHPUnit2/TextUI/TestRunner.php';
     $suite = new PHPUnit2_Framework_TestSuite("DocUpdateTestClassTest");
     $result = PHPUnit2_TextUI_TestRunner::run($suite);
 }