mysql_constants.phpt 1.7 KB

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