| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
DB_driver::getListOf
|
|
|
3 |
--INI--
|
|
|
4 |
error_reporting = 2047
|
|
|
5 |
--SKIPIF--
|
|
|
6 |
<?php chdir(dirname(__FILE__)); require_once './skipif.inc'; ?>
|
|
|
7 |
--FILE--
|
|
|
8 |
<?php
|
|
|
9 |
|
|
|
10 |
require_once './mktable.inc';
|
|
|
11 |
|
|
|
12 |
/*
|
|
|
13 |
* An array with keys containing the $type to be passed to the getListOf()
|
|
|
14 |
* method. The values of the main array are a sub-array that has keys
|
|
|
15 |
* listing the phptype and dbsyntax of each driver and values of the
|
|
|
16 |
* result expected from the combination of all these factors.
|
|
|
17 |
*/
|
|
|
18 |
$tests = array(
|
|
|
19 |
'tables' => array(
|
|
|
20 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
21 |
'fbsql:fbsql' => 'array',
|
|
|
22 |
'ibase:ibase' => 'array',
|
|
|
23 |
'ibase:firebird' => 'array',
|
|
|
24 |
'ifx:ifx' => 'array',
|
|
|
25 |
'msql:msql' => 'array',
|
|
|
26 |
'mssql:mssql' => 'array',
|
|
|
27 |
'mysql:mysql' => 'array',
|
|
|
28 |
'mysqli:mysqli' => 'array',
|
|
|
29 |
'oci8:oci8' => 'array',
|
|
|
30 |
'odbc:access' => 'array',
|
|
|
31 |
'odbc:db2' => 'array',
|
|
|
32 |
'pgsql:pgsql' => 'array',
|
|
|
33 |
'sqlite:sqlite' => 'array',
|
|
|
34 |
'sybase:sybase' => 'array',
|
|
|
35 |
),
|
|
|
36 |
'views' => array(
|
|
|
37 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
38 |
'fbsql:fbsql' => 'array',
|
|
|
39 |
'ibase:ibase' => 'array',
|
|
|
40 |
'ibase:firebird' => 'array',
|
|
|
41 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
42 |
'msql:msql' => DB_ERROR_UNSUPPORTED,
|
|
|
43 |
'mssql:mssql' => 'array',
|
|
|
44 |
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
|
|
|
45 |
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
|
|
|
46 |
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
|
|
|
47 |
'odbc:access' => 'array',
|
|
|
48 |
'odbc:db2' => 'array',
|
|
|
49 |
'pgsql:pgsql' => 'array',
|
|
|
50 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
51 |
'sybase:sybase' => 'array',
|
|
|
52 |
),
|
|
|
53 |
'users' => array(
|
|
|
54 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
55 |
'fbsql:fbsql' => 'array',
|
|
|
56 |
'ibase:ibase' => 'array',
|
|
|
57 |
'ibase:firebird' => 'array',
|
|
|
58 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
59 |
'msql:msql' => DB_ERROR_UNSUPPORTED,
|
|
|
60 |
'mssql:mssql' => DB_ERROR_UNSUPPORTED,
|
|
|
61 |
'mysql:mysql' => DB_ERROR_ACCESS_VIOLATION,
|
|
|
62 |
'mysqli:mysqli' => DB_ERROR_ACCESS_VIOLATION,
|
|
|
63 |
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
|
|
|
64 |
'odbc:access' => DB_ERROR_UNSUPPORTED,
|
|
|
65 |
'odbc:db2' => DB_ERROR_UNSUPPORTED,
|
|
|
66 |
'pgsql:pgsql' => 'array',
|
|
|
67 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
68 |
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
|
|
|
69 |
),
|
|
|
70 |
'databases' => array(
|
|
|
71 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
72 |
'fbsql:fbsql' => DB_ERROR_UNSUPPORTED,
|
|
|
73 |
'ibase:ibase' => DB_ERROR_UNSUPPORTED,
|
|
|
74 |
'ibase:firebird' => DB_ERROR_UNSUPPORTED,
|
|
|
75 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
76 |
'msql:msql' => 'array',
|
|
|
77 |
'mssql:mssql' => DB_ERROR_UNSUPPORTED,
|
|
|
78 |
'mysql:mysql' => 'array',
|
|
|
79 |
'mysqli:mysqli' => 'array',
|
|
|
80 |
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
|
|
|
81 |
'odbc:access' => 'array',
|
|
|
82 |
'odbc:db2' => 'array',
|
|
|
83 |
'pgsql:pgsql' => 'array',
|
|
|
84 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
85 |
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
|
|
|
86 |
),
|
|
|
87 |
'functions' => array(
|
|
|
88 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
89 |
'fbsql:fbsql' => 'array',
|
|
|
90 |
'ibase:ibase' => DB_ERROR_UNSUPPORTED,
|
|
|
91 |
'ibase:firebird' => DB_ERROR_UNSUPPORTED,
|
|
|
92 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
93 |
'msql:msql' => DB_ERROR_UNSUPPORTED,
|
|
|
94 |
'mssql:mssql' => DB_ERROR_UNSUPPORTED,
|
|
|
95 |
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
|
|
|
96 |
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
|
|
|
97 |
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
|
|
|
98 |
'odbc:access' => DB_ERROR_UNSUPPORTED,
|
|
|
99 |
'odbc:db2' => DB_ERROR_UNSUPPORTED,
|
|
|
100 |
'pgsql:pgsql' => 'array',
|
|
|
101 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
102 |
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
|
|
|
103 |
),
|
|
|
104 |
'procedures' => array(
|
|
|
105 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
106 |
'fbsql:fbsql' => 'array',
|
|
|
107 |
'ibase:ibase' => DB_ERROR_UNSUPPORTED,
|
|
|
108 |
'ibase:firebird' => DB_ERROR_UNSUPPORTED,
|
|
|
109 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
110 |
'msql:msql' => DB_ERROR_UNSUPPORTED,
|
|
|
111 |
'mssql:mssql' => DB_ERROR_UNSUPPORTED,
|
|
|
112 |
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
|
|
|
113 |
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
|
|
|
114 |
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
|
|
|
115 |
'odbc:access' => DB_ERROR_UNSUPPORTED,
|
|
|
116 |
'odbc:db2' => DB_ERROR_UNSUPPORTED,
|
|
|
117 |
'pgsql:pgsql' => 'array',
|
|
|
118 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
119 |
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
|
|
|
120 |
),
|
|
|
121 |
'schema.tables' => array(
|
|
|
122 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
123 |
'fbsql:fbsql' => DB_ERROR_UNSUPPORTED,
|
|
|
124 |
'ibase:ibase' => DB_ERROR_UNSUPPORTED,
|
|
|
125 |
'ibase:firebird' => DB_ERROR_UNSUPPORTED,
|
|
|
126 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
127 |
'msql:msql' => DB_ERROR_UNSUPPORTED,
|
|
|
128 |
'mssql:mssql' => DB_ERROR_UNSUPPORTED,
|
|
|
129 |
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
|
|
|
130 |
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
|
|
|
131 |
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
|
|
|
132 |
'odbc:access' => 'array',
|
|
|
133 |
'odbc:db2' => 'array',
|
|
|
134 |
'pgsql:pgsql' => 'array',
|
|
|
135 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
136 |
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
|
|
|
137 |
),
|
|
|
138 |
'synonyms' => array(
|
|
|
139 |
'dbase:dbase' => DB_ERROR_UNSUPPORTED,
|
|
|
140 |
'fbsql:fbsql' => DB_ERROR_UNSUPPORTED,
|
|
|
141 |
'ibase:ibase' => DB_ERROR_UNSUPPORTED,
|
|
|
142 |
'ibase:firebird' => DB_ERROR_UNSUPPORTED,
|
|
|
143 |
'ifx:ifx' => DB_ERROR_UNSUPPORTED,
|
|
|
144 |
'msql:msql' => DB_ERROR_UNSUPPORTED,
|
|
|
145 |
'mssql:mssql' => DB_ERROR_UNSUPPORTED,
|
|
|
146 |
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
|
|
|
147 |
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
|
|
|
148 |
'oci8:oci8' => 'array',
|
|
|
149 |
'odbc:access' => DB_ERROR_UNSUPPORTED,
|
|
|
150 |
'odbc:db2' => DB_ERROR_UNSUPPORTED,
|
|
|
151 |
'pgsql:pgsql' => DB_ERROR_UNSUPPORTED,
|
|
|
152 |
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
|
|
|
153 |
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
|
|
|
154 |
),
|
|
|
155 |
);
|
|
|
156 |
|
|
|
157 |
/**
|
|
|
158 |
* Determine if the output from the driver matches what we expect
|
|
|
159 |
*
|
|
|
160 |
* If things are as we expect, nothing is printed out.
|
|
|
161 |
*
|
|
|
162 |
* If things go wrong, print "UNEXPECTED OUTCOME" and display
|
|
|
163 |
* what happened.
|
|
|
164 |
*
|
|
|
165 |
* @param mixed $result the result from getListOf
|
|
|
166 |
* @param mixed $expected the expected result
|
|
|
167 |
* @param string $name the name of the current test
|
|
|
168 |
*
|
|
|
169 |
* @return void
|
|
|
170 |
*/
|
|
|
171 |
function check_output($result, $expected, $name) {
|
|
|
172 |
if (is_object($result)) {
|
|
|
173 |
if ($result->getCode() !== $expected) {
|
|
|
174 |
echo "UNEXPECTED OUTCOME FOR $name...\n";
|
|
|
175 |
echo $result->getDebugInfo() . "\n";
|
|
|
176 |
}
|
|
|
177 |
} else {
|
|
|
178 |
$type = gettype($result);
|
|
|
179 |
if ($type != $expected) {
|
|
|
180 |
if ($expected === DB_ERROR_ACCESS_VIOLATION
|
|
|
181 |
&& $type == 'array')
|
|
|
182 |
{
|
|
|
183 |
// This user has access to the mysql table.
|
|
|
184 |
// Not a problem
|
|
|
185 |
} else {
|
|
|
186 |
echo "UNEXPECTED OUTCOME FOR $name...\n";
|
|
|
187 |
echo " Expected: $expected\n";
|
|
|
188 |
echo ' Result: ';
|
|
|
189 |
print_r($result);
|
|
|
190 |
echo "\n";
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
}
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
$dbh->setErrorHandling(PEAR_ERROR_RETURN);
|
|
|
198 |
foreach ($tests as $test => $dbms) {
|
|
|
199 |
check_output($dbh->getListOf($test),
|
|
|
200 |
$dbms[$dbh->phptype . ':' . $dbh->dbsyntax],
|
|
|
201 |
$test);
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
drop_table($dbh, 'phptest');
|
|
|
206 |
|
|
|
207 |
?>
|
|
|
208 |
--EXPECT--
|