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.5 2004/04/08 17:17:05 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 51if(!defined('PATH_SEPARATOR')) { 52 if(defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") { 53 define('PATH_SEPARATOR', ';'); 54 } else { 55 define('PATH_SEPARATOR', ':'); 56 } 57} 58ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path')); 59 60require_once('PHPUnit.php'); 61require_once('test_setup.php'); 62require_once('testUtils.php'); 63require_once('MDB.php'); 64require_once('HTML_TestListener.php'); 65 66PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error'); 67function 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 74MDB::loadFile('Manager'); 75MDB::loadFile('Date'); 76 77foreach ($testcases as $testcase) { 78 include_once($testcase.'.php'); 79} 80 81$database = 'driver_test'; 82 83$testmethods = isset($_POST['testmethods']) ? $_POST['testmethods'] : NULL; 84 85if (!is_array($testmethods)) { 86 foreach ($testcases as $testcase) { 87 $testmethods[$testcase] = array_flip(getTests($testcase)); 88 } 89} 90 91?> 92<html> 93<head> 94<title>MDB Tests</title> 95<link href="tests.css" rel="stylesheet" type="text/css"> 96</head> 97<body> 98<?php 99 100foreach ($dbarray as $db) { 101 $dsn = $db['dsn']; 102 $options = $db['options']; 103 $options['optimize'] = 'portability'; 104 105 $display_dsn = $dsn['phptype'] . "://" . $dsn['username'] . ":" . $dsn['password'] . "@" . $dsn['hostspec'] . "/" . $database; 106 echo "<div class=\"test\">\n"; 107 echo "<div class=\"title\">Testing $display_dsn</div>\n"; 108 109 $suite = new PHPUnit_TestSuite(); 110 111 foreach ($testcases as $testcase) { 112 if (isset($testmethods[$testcase]) && is_array($testmethods[$testcase])) { 113 $methods = array_keys($testmethods[$testcase]); 114 foreach ($methods as $method) { 115 $suite->addTest(new $testcase($method)); 116 } 117 } 118 } 119 120 $result = new PHPUnit_TestResult; 121 $result->addListener(new HTML_TestListener); 122 $suite->run($result); 123 echo "\n</div>\n"; 124} 125?> 126</body> 127</html> 128