php-src/ext/mysql/tests/mysql_constants.phpt
Adam Harvey b7091aaf01 Deprecate ext/mysql.
Per https://wiki.php.net/rfc/mysql_deprecation, connecting to a MySQL database
via ext/mysql now generates an E_DEPRECATED error. This commit includes the
minimal EXPECTF updates required for the test suite to pass: it may be
preferable to refactor some of the tests to suppress deprecation errors in
situations where no other error is expected from mysql_[p]connect(), but I'm
not enough of a MySQL expert to want to get my hands that dirty in a long
standing test suite.
2012-12-10 22:12:09 +08:00

67 lines
1.7 KiB
PHP

--TEST--
Constants exported by ext/mysql
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require("connect.inc");
require("table.inc");
$constants = get_defined_constants(true);
sort($constants);
$expected_constants = array(
'MYSQL_ASSOC' => true,
'MYSQL_NUM' => true,
'MYSQL_BOTH' => true,
'MYSQL_CLIENT_COMPRESS' => true,
'MYSQL_CLIENT_INTERACTIVE' => true,
'MYSQL_CLIENT_IGNORE_SPACE' => true,
);
$version = mysql_get_server_info($link);
if (!preg_match('@(\d+)\.(\d+)\.(\d+)@ism', $version, $matches))
printf("[001] Cannot get server version\n");
$version = ($matches[1] * 100) + ($matches[2] * 10) + $matches[3];
if ($version > 400) {
$expected_constants = array_merge($expected_constants, array(
"MYSQL_CLIENT_SSL" => true,
));
}
$unexpected_constants = array();
foreach ($constants as $group => $consts) {
foreach ($consts as $name => $value) {
if (stristr($name, 'mysql') && !preg_match("/^mysql([^_]+)_/iu", $name)) {
$name = strtoupper($name);
if (isset($expected_constants[$name])) {
unset($expected_constants[$name]);
} else {
$unexpected_constants[$name] = $name;
}
}
}
}
if (!empty($unexpected_constants)) {
printf("Dumping list of unexpected constants\n");
var_dump($unexpected_constants);
}
if (!empty($expected_constants)) {
printf("Dumping list of missing constants\n");
var_dump($expected_constants);
}
print "done!";
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!