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