summaryrefslogtreecommitdiff
path: root/ext/mysql/tests/mysql_constants.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/mysql/tests/mysql_constants.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/mysql/tests/mysql_constants.phpt')
-rw-r--r--ext/mysql/tests/mysql_constants.phpt65
1 files changed, 65 insertions, 0 deletions
diff --git a/ext/mysql/tests/mysql_constants.phpt b/ext/mysql/tests/mysql_constants.phpt
new file mode 100644
index 0000000..1346100
--- /dev/null
+++ b/ext/mysql/tests/mysql_constants.phpt
@@ -0,0 +1,65 @@
+--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--
+done! \ No newline at end of file