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

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP Version 4                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2004 Manuel Lemos, Paul Cooper                    |
  6. // | All rights reserved.                                                 |
  7. // +----------------------------------------------------------------------+
  8. // | MDB is a merge of PEAR DB and Metabases that provides a unified DB   |
  9. // | API as well as database abstraction for PHP applications.            |
  10. // | This LICENSE is in the BSD license style.                            |
  11. // |                                                                      |
  12. // | Redistribution and use in source and binary forms, with or without   |
  13. // | modification, are permitted provided that the following conditions   |
  14. // | are met:                                                             |
  15. // |                                                                      |
  16. // | Redistributions of source code must retain the above copyright       |
  17. // | notice, this list of conditions and the following disclaimer.        |
  18. // |                                                                      |
  19. // | Redistributions in binary form must reproduce the above copyright    |
  20. // | notice, this list of conditions and the following disclaimer in the  |
  21. // | documentation and/or other materials provided with the distribution. |
  22. // |                                                                      |
  23. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
  24. // | Lukas Smith nor the names of his contributors may be used to endorse |
  25. // | or promote products derived from this software without specific prior|
  26. // | written permission.                                                  |
  27. // |                                                                      |
  28. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  29. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  30. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  31. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
  32. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
  33. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  34. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  35. // |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
  36. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
  37. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  38. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
  39. // | POSSIBILITY OF SUCH DAMAGE.                                          |
  40. // +----------------------------------------------------------------------+
  41. // | Author: Paul Cooper <pgc@ucecom.com>                                 |
  42. // +----------------------------------------------------------------------+
  43. //
  44. // $Id: test.php,v 1.19.4.2 2004/01/08 13:43:00 lsmith Exp $
  45.  
  46. /*
  47.  This is a small test suite for MDB using PHPUnit
  48.  */
  49.  
  50. // BC hack to define PATH_SEPARATOR for version of PHP prior 4.3
  51. if(!defined('PATH_SEPARATOR')) {
  52.     if(defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") {
  53.         define('PATH_SEPARATOR', ';');
  54.     } else {
  55.         define('PATH_SEPARATOR', ':');
  56.     }
  57. }
  58. ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path'));
  59.  
  60. require_once('PHPUnit.php');
  61. require_once('test_setup.php');
  62. require_once('testUtils.php');
  63. require_once('MDB.php');
  64. require_once('HTML_TestListener.php');
  65.  
  66. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error');
  67. function handle_pear_error ($error_obj)
  68. {
  69.     print '<pre><b>PEAR-Error</b><br />';
  70.     echo $error_obj->getMessage().': '.$error_obj->getUserinfo();
  71.     print '</pre>';
  72. }
  73.  
  74. // you may need to uncomment the line and modify the multiplier as you see fit
  75. set_time_limit(60*count($dbarray));
  76.  
  77. MDB::loadFile('Manager');
  78. MDB::loadFile('Date');
  79.  
  80. foreach ($testcases as $testcase) {
  81.     include_once($testcase.'.php');
  82. }
  83.  
  84. $database = 'driver_test';
  85.  
  86. $testmethods = isset($_POST['testmethods']) ? $_POST['testmethods'] : NULL;
  87.  
  88. if (!is_array($testmethods)) {
  89.     foreach ($testcases as $testcase) {
  90.         $testmethods[$testcase] = array_flip(getTests($testcase));
  91.     }
  92. }
  93.  
  94. ?>
  95. <html>
  96. <head>
  97. <title>MDB Tests</title>
  98. <link href="tests.css" rel="stylesheet" type="text/css">
  99. </head>
  100. <body>
  101. <?php
  102.  
  103. foreach ($dbarray as $db) {
  104.     $dsn = $db['dsn'];
  105.     $options = $db['options'];
  106.  
  107.     $display_dsn = $dsn['phptype'] . "://" . $dsn['username'] . ":" . $dsn['password'] . "@" . $dsn['hostspec'] . "/" . $database;
  108.     echo "<div class=\"test\">\n";
  109.     echo "<div class=\"title\">Testing $display_dsn</div>\n";
  110.  
  111.     $suite = new PHPUnit_TestSuite();
  112.  
  113.     foreach ($testcases as $testcase) {
  114.         if (is_array($testmethods[$testcase])) {
  115.             $methods = array_keys($testmethods[$testcase]);
  116.             foreach ($methods as $method) {
  117.                 $suite->addTest(new $testcase($method));
  118.             }
  119.         }
  120.     }
  121.  
  122.     $result = new PHPUnit_TestResult;
  123.     $result->addListener(new HTML_TestListener);
  124.     $suite->run($result);
  125.     echo "\n</div>\n";
  126. }
  127. ?>
  128. </body>
  129. </html>
  130.