1--TEST--
2Constants exported by ext/mysql
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10require("connect.inc");
11require("table.inc");
12
13$constants = get_defined_constants(true);
14sort($constants);
15
16$expected_constants = array(
17	'MYSQL_ASSOC'                   => true,
18	'MYSQL_NUM'                     => true,
19	'MYSQL_BOTH'                    => true,
20	'MYSQL_CLIENT_COMPRESS'         => true,
21	'MYSQL_CLIENT_INTERACTIVE'      => true,
22	'MYSQL_CLIENT_IGNORE_SPACE'     => true,
23);
24
25$version = mysql_get_server_info($link);
26if (!preg_match('@(\d+)\.(\d+)\.(\d+)@ism', $version, $matches))
27	printf("[001] Cannot get server version\n");
28$version = ($matches[1] * 100) + ($matches[2] * 10) + $matches[3];
29
30if ($version > 400) {
31	$expected_constants = array_merge($expected_constants, array(
32					"MYSQL_CLIENT_SSL"                => true,
33					));
34}
35
36
37$unexpected_constants = array();
38
39foreach ($constants as $group => $consts) {
40	foreach ($consts as $name => $value) {
41		if (stristr($name, 'mysql') && !preg_match("/^mysql([^_]+)_/iu", $name)) {
42			$name = strtoupper($name);
43			if (isset($expected_constants[$name])) {
44				unset($expected_constants[$name]);
45			} else {
46				$unexpected_constants[$name] = $name;
47			}
48		}
49	}
50}
51
52if (!empty($unexpected_constants)) {
53	printf("Dumping list of unexpected constants\n");
54	var_dump($unexpected_constants);
55}
56
57if (!empty($expected_constants)) {
58	printf("Dumping list of missing constants\n");
59	var_dump($expected_constants);
60}
61
62print "done!";
63?>
64--EXPECTF--
65done!