mysql_drop_db.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. mysql_drop_db()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. if (!function_exists('mysql_drop_db'))
  7. die("Skip function is deprecated and not available");
  8. ?>
  9. --FILE--
  10. <?php
  11. include_once "connect.inc";
  12. $tmp = NULL;
  13. $link = NULL;
  14. // NOTE: again this test does not test all of the behaviour of the function
  15. if (NULL !== ($tmp = mysql_drop_db()))
  16. printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  17. require('table.inc');
  18. if (!mysql_query('DROP DATABASE IF EXISTS mysqldropdb'))
  19. printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
  20. if (!mysql_query('CREATE DATABASE mysqldropdb'))
  21. die(sprintf("[005] Skipping, can't create test database. [%d] %s\n", mysql_errno($link), mysql_error($link)));
  22. if (true !== ($tmp = mysql_drop_db('mysqldropdb', $link)))
  23. printf("[006] Can't drop, got %s/%s. [%d] %s\n",
  24. gettype($tmp), $tmp,
  25. mysql_errno($link), mysql_error($link));
  26. if (false !== ($tmp = mysql_drop_db('mysqldropdb', $link)))
  27. printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n",
  28. gettype($tmp), $tmp,
  29. mysql_errno($link), mysql_error($link));
  30. mysql_close($link);
  31. print "done!\n";
  32. ?>
  33. --CLEAN--
  34. <?php
  35. require_once('connect.inc');
  36. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
  37. printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  38. $host, $user, $db, $port, $socket);
  39. if (!mysql_query("DROP DATABASE IF EXISTS mysqldropdb", $link))
  40. printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  41. mysql_close($link);
  42. ?>
  43. --EXPECTF--
  44. 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
  45. done!