Skip to content

Instantly share code, notes, and snippets.

@gcorne
Created June 28, 2012 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcorne/3013507 to your computer and use it in GitHub Desktop.
Save gcorne/3013507 to your computer and use it in GitHub Desktop.
WP test suite runner
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