home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / testUtils.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  758 b   |  30 lines

  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 = 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. ?>