Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// +----------------------------------------------------------------------+
3
// | PHP versions 4 and 5                                                 |
4
// +----------------------------------------------------------------------+
5
// | Copyright (c) 1998-2006 Manuel Lemos, Paul Cooper                    |
6
// | All rights reserved.                                                 |
7
// +----------------------------------------------------------------------+
8
// | MDB2 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.18 2006/10/20 16:36:32 lsmith Exp $
45
 
46
/*
47
 This is a small test suite for MDB2 using PHPUnit
48
 */
49
 
50
require_once 'test_setup.php';
51
require_once 'PHPUnit.php';
52
require_once 'testUtils.php';
53
require_once 'MDB2.php';
54
require_once 'HTML_TestListener.php';
55
 
56
function htmlErrorHandler($errno, $errstr, $errfile, $errline)
57
{
58
    if ((!$GLOBALS['_show_silenced'] && !error_reporting()) || $errno == 2048) {
59
        return;
60
    }
61
    echo '<pre>';
62
    errorHandler($errno, $errstr, $errfile, $errline);
63
    echo '</pre>';
64
}
65
set_error_handler('htmlErrorHandler');
66
 
67
function htmlErrorHandlerPEAR($error_obj)
68
{
69
    echo '<pre>';
70
    errorHandlerPEAR($error_obj);
71
    echo '</pre>';
72
}
73
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'htmlErrorHandlerPEAR');
74
 
75
MDB2::loadFile('Date');
76
 
77
foreach ($testcases as $testcase) {
78
    include_once $testcase.'.php';
79
}
80
 
81
$database = 'driver_test';
82
 
83
$testmethods = !empty($_POST['testmethods']) ? $_POST['testmethods'] : null;
84
 
85
if (!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>MDB2 Tests</title>
95
<link href="tests.css" rel="stylesheet" type="text/css">
96
</head>
97
<body>
98
<?php
99
 
100
foreach ($dbarray as $db) {
101
    $dsn = $db['dsn'];
102
    $options = !empty($db['options']) ? $db['options'] : array();
103
    $GLOBALS['_show_silenced'] = !empty($options['debug']) ? $options['debug'] : false;
104
 
105
    $display_dsn = $dsn['phptype'] . "://" . $dsn['username'] . ":XXX@" . $dsn['hostspec'] . "/" . $database;
106
    echo "<div class=\"test\">\n";
107
    echo "<div class=\"title\">Testing $display_dsn on ".PHP_VERSION."</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
    $count = $result->runCount();
124
    $failed = $result->failureCount();
125
 
126
    echo "<div class=\"title\">Summary: $failed failed assertions in $count tests</div>\n";
127
    echo "\n</div>\n";
128
}
129
?>
130
</body>
131
</html>