| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/* Some utility functions for the test scripts */
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* this is used (with array filter) to filter out the test*
|
|
|
7 |
* methods from a PHPUnit testcase
|
|
|
8 |
*/
|
|
|
9 |
function grepForTest($var) {
|
|
|
10 |
return preg_match('/\btest.*/', $var);
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* given a class name it returns an array of test* methods
|
|
|
15 |
*
|
|
|
16 |
* @param $class text classname
|
|
|
17 |
* @return array of methods beginning with test
|
|
|
18 |
*/
|
|
|
19 |
function getTests($class) {
|
|
|
20 |
$methods = array_flip(array_change_key_case(array_flip(get_class_methods($class))));
|
|
|
21 |
return array_filter($methods, 'grepForTest');
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Little helper function that outputs check for boxes with suitable names
|
|
|
26 |
*/
|
|
|
27 |
function testCheck($testcase, $testmethod) {
|
|
|
28 |
return "<input type=\"checkbox\" name=\"testmethods[$testcase][$testmethod]\" value=\"1\">$testmethod <br>\n";
|
|
|
29 |
}
|
|
|
30 |
?>
|