VPN licensing server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.0KB

  1. #!/usr/bin/php
  2. <?php
  3. class SimpleTest {
  4. public function assert($boolean) {
  5. if (! $boolean) $this->fail();
  6. }
  7. protected function fail($msg = '') {
  8. echo "FAILURE! $msg\n";
  9. debug_print_backtrace();
  10. die;
  11. }
  12. }
  13. function microtime_float()
  14. {
  15. list($usec, $sec) = explode(" ", microtime());
  16. return ((float)$usec + (float)$sec);
  17. }
  18. if (phpversion() >= '5.3') $is_php_53 = true;
  19. else $is_php_53 = false;
  20. ini_set('date.timezone', 'America/Los_Angeles');
  21. error_reporting(E_ALL | E_STRICT);
  22. require_once '../db.class.php';
  23. include 'test_setup.php'; //test config values go here
  24. // WARNING: ALL tables in the database will be dropped before the tests, including non-test related tables.
  25. DB::$user = $set_db_user;
  26. DB::$password = $set_password;
  27. DB::$dbName = $set_db;
  28. DB::$host = $set_host;
  29. DB::get(); //connect to mysql
  30. require_once 'BasicTest.php';
  31. require_once 'CallTest.php';
  32. require_once 'ObjectTest.php';
  33. require_once 'WhereClauseTest.php';
  34. require_once 'ErrorTest.php';
  35. require_once 'TransactionTest.php';
  36. require_once 'HelperTest.php';
  37. $classes_to_test = array(
  38. 'BasicTest',
  39. 'CallTest',
  40. 'WhereClauseTest',
  41. 'ObjectTest',
  42. 'ErrorTest',
  43. 'TransactionTest',
  44. 'HelperTest',
  45. );
  46. if ($is_php_53) {
  47. require_once 'ErrorTest_53.php';
  48. $classes_to_test[] = 'ErrorTest_53';
  49. } else {
  50. echo "PHP 5.3 not detected, skipping 5.3 tests..\n";
  51. }
  52. $mysql_version = DB::serverVersion();
  53. if ($mysql_version >= '5.5') {
  54. require_once 'TransactionTest_55.php';
  55. $classes_to_test[] = 'TransactionTest_55';
  56. } else {
  57. echo "MySQL 5.5 not available (version is $mysql_version) -- skipping MySQL 5.5 tests\n";
  58. }
  59. $time_start = microtime_float();
  60. foreach ($classes_to_test as $class) {
  61. $object = new $class();
  62. foreach (get_class_methods($object) as $method) {
  63. if (substr($method, 0, 4) != 'test') continue;
  64. echo "Running $class::$method..\n";
  65. $object->$method();
  66. }
  67. }
  68. $time_end = microtime_float();
  69. $time = round($time_end - $time_start, 2);
  70. echo "Completed in $time seconds\n";
  71. ?>