Annotation of embedaddon/php/ext/mysqli/tests/mysqli_report_wo_ps.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_report()
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_once('skipifconnectfailure.inc');
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: require_once("connect.inc");
! 12:
! 13: $tmp = NULL;
! 14: $link = NULL;
! 15:
! 16: if (NULL !== ($tmp = @mysqli_report()))
! 17: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 18:
! 19: if (true !== ($tmp = mysqli_report(-1)))
! 20: printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n", gettype($tmp), $tmp);
! 21:
! 22: if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR)))
! 23: printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
! 24:
! 25: if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT)))
! 26: printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
! 27:
! 28: if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX)))
! 29: printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
! 30:
! 31: if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL)))
! 32: printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
! 33:
! 34: if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF)))
! 35: printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
! 36:
! 37: require('table.inc');
! 38:
! 39: /*
! 40: Internal macro MYSQL_REPORT_ERROR
! 41: */
! 42: mysqli_report(MYSQLI_REPORT_ERROR);
! 43:
! 44: mysqli_multi_query($link, "BAR; FOO;");
! 45: mysqli_query($link, "FOO");
! 46: mysqli_change_user($link, "0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789", "password", $db);
! 47: mysqli_kill($link, -1);
! 48:
! 49: // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it
! 50: mysqli_real_query($link, "FOO");
! 51: if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
! 52: printf("[009] select_db should have failed\n");
! 53: // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it
! 54:
! 55:
! 56: // Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would
! 57: // not have been set. If that would be the case, the test would be broken.
! 58: mysqli_report(MYSQLI_REPORT_OFF);
! 59:
! 60: mysqli_multi_query($link, "BAR; FOO;");
! 61: mysqli_query($link, "FOO");
! 62: mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db);
! 63: mysqli_kill($link, -1);
! 64: mysqli_real_query($link, "FOO");
! 65: mysqli_select_db($link, "Oh lord, let this be an unknown database name");
! 66:
! 67: mysqli_report(MYSQLI_REPORT_OFF);
! 68: mysqli_report(MYSQLI_REPORT_STRICT);
! 69:
! 70: try {
! 71:
! 72: if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
! 73: printf("[010] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
! 74: $host, $user . 'unknown_really', $db, $port, $socket);
! 75: mysqli_close($link);
! 76:
! 77: } catch (mysqli_sql_exception $e) {
! 78: printf("[011] %s\n", $e->getMessage());
! 79: }
! 80:
! 81: try {
! 82: if (!$link = mysqli_init())
! 83: printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
! 84:
! 85: if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
! 86: printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
! 87: $host, $user . 'unknown_really', $db, $port, $socket);
! 88: mysqli_close($link);
! 89: } catch (mysqli_sql_exception $e) {
! 90: printf("[014] %s\n", $e->getMessage());
! 91: }
! 92:
! 93: print "done!";
! 94: ?>
! 95: --CLEAN--
! 96: <?php
! 97: require_once("clean_table.inc");
! 98: ?>
! 99: --EXPECTF--
! 100: Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d
! 101:
! 102: Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
! 103:
! 104: Warning: mysqli_change_user(): (%d/%d): Access denied for user '%s'@'%s' (using password: %s) in %s on line %d
! 105:
! 106: Warning: mysqli_kill(): processid should have positive value in %s on line %d
! 107:
! 108: Warning: mysqli_real_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
! 109:
! 110: Warning: mysqli_kill(): processid should have positive value in %s on line %d
! 111: [011] Access denied for user '%s'@'%s' (using password: YES)
! 112: [014] Access denied for user '%s'@'%s' (using password: YES)
! 113: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>