Created
June 28, 2012 19:59
-
-
Save gcorne/3013507 to your computer and use it in GitHub Desktop.
WP test suite runner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wptest_run_tests($classes, $classnames = array(), $filter = null ) { | |
$suite = new PHPUnit_Framework_TestSuite(); | |
if ( ! is_array($classnames) ) // For strings, Accept a comma separated list, or a space separated list. | |
$classnames = preg_split('![,\s]+!', $classnames); | |
$classnames = array_map('strtolower', $classnames); | |
$classnames = array_filter($classnames); //strip out any empty items | |
foreach ( $classes as $testcase ) { | |
if ( ( empty($classnames) || in_array( strtolower( $testcase ), $classnames ) ) && | |
( is_null( $filter ) || strstr( $testcase, $filter ) ) | |
) { | |
$suite->addTestSuite($testcase); | |
} | |
} | |
#return PHPUnit::run($suite); | |
$result = new PHPUnit_Framework_TestResult; | |
require_once('PHPUnit/TextUI/ResultPrinter.php'); | |
$printer = new PHPUnit_TextUI_ResultPrinter(NULL, WP_PHPUNIT_VERBOSE, !stristr(PHP_OS, 'WIN') ); | |
$result->addListener($printer); | |
return array($suite->run($result, FALSE ), $printer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment