From: Ulf Wendel Date: Tue, 25 Jan 2011 14:01:00 +0000 (+0000) Subject: Handle deprecation messages differently in tests to reduce test differences between... X-Git-Tag: php-5.4.0alpha1~191^2~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5e8ca7f43896cbc8e29c0eda0974a08cf83ad7d;p=php Handle deprecation messages differently in tests to reduce test differences between 5.3 and trunk: suppress warnings by default, check warnings in a dedicated test --- diff --git a/ext/mysql/tests/mysql_db_name.phpt b/ext/mysql/tests/mysql_db_name.phpt index bed98bca52..b7f9042209 100644 --- a/ext/mysql/tests/mysql_db_name.phpt +++ b/ext/mysql/tests/mysql_db_name.phpt @@ -20,7 +20,7 @@ if (NULL !== ($tmp = @mysql_db_name($link, $link))) require('table.inc'); -if (!$res = mysql_list_dbs($link)) +if (!$res = @mysql_list_dbs($link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$num = mysql_num_rows($res)) @@ -58,10 +58,6 @@ mysql_close($link); print "done!\n"; ?> --EXPECTF-- -Deprecated: Function mysql_list_dbs() is deprecated in %s on line %d - -Deprecated: mysql_list_dbs(): This function is deprecated; use mysql_query() with SHOW DATABASES instead in %s on line %d - Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in %s on line %d Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_deprecated_api.phpt b/ext/mysql/tests/mysql_deprecated_api.phpt new file mode 100644 index 0000000000..d54307ca0e --- /dev/null +++ b/ext/mysql/tests/mysql_deprecated_api.phpt @@ -0,0 +1,78 @@ +--TEST-- +Check if deprecated API calls bail out +--SKIPIF-- + +--INI-- +mysql.trace_mode=1 +error_reporting=E_ALL | E_NOTICE | E_STRICT +--FILE-- += 0) { + $error = NULL; + ob_start(); + if (!$res = mysql_db_query($db, "SELECT * FROM test", $link)) + $error .= sprintf("[001] [%d] %s\n", mysql_errno($link), mysql_error($link)); + else + mysql_free_result($res); + $output = ob_get_contents(); + ob_end_clean(); + + if (!stristr($output, 'deprecated')) { + printf("[002] mysql_db_query has been deprecated in 5.3.0\n"); + } + + /* + Deprecated since 2002 or the like but documented to be deprecated since 5.3. + In 5.3 and before the deprecation message was bound to mysql.trace_mode=1. + In 5.3.99 the warning will always be thrown, independent of the mysql.trace_mode + setting. + */ + $error = NULL; + ob_start(); + if (!$query = mysql_escape_string("charsets will be ignored")) + $error .= sprintf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); + $output = ob_get_contents(); + ob_end_clean(); + + if (!stristr($output, 'deprecated')) { + printf("[006] mysql_escape_string has been deprecated in 5.3.0\n"); + } + +} + +if (version_compare(PHP_VERSION, '5.3.99') >= 0) { + $error = NULL; + ob_start(); + if (!$res = mysql_list_dbs($link)) + $error .= sprintf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); + else + mysql_free_result($res); + $output = ob_get_contents(); + ob_end_clean(); + + if (!stristr($output, 'deprecated')) { + printf("[004] mysql_db_query has been deprecated in 5.3.0\n"); + } +} + + + +print "done!"; +?> +--CLEAN-- + +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_escape_string.phpt b/ext/mysql/tests/mysql_escape_string.phpt index 45bf26978c..8e70da69c9 100644 --- a/ext/mysql/tests/mysql_escape_string.phpt +++ b/ext/mysql/tests/mysql_escape_string.phpt @@ -12,13 +12,13 @@ $link = NULL; if (NULL !== ($tmp = @mysql_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); -var_dump(mysql_escape_string("Am I a unicode string in PHP 6?")); -var_dump(mysql_escape_string('\\')); -var_dump(mysql_escape_string('"')); -var_dump(mysql_escape_string("'")); -var_dump(mysql_escape_string("\n")); -var_dump(mysql_escape_string("\r")); -var_dump(mysql_escape_string("foo" . chr(0) . "bar")); +var_dump(@mysql_escape_string("Am I a unicode string in PHP 6?")); +var_dump(@mysql_escape_string('\\')); +var_dump(@mysql_escape_string('"')); +var_dump(@mysql_escape_string("'")); +var_dump(@mysql_escape_string("\n")); +var_dump(@mysql_escape_string("\r")); +var_dump(@mysql_escape_string("foo" . chr(0) . "bar")); print "done!"; ?> diff --git a/ext/mysql/tests/mysql_list_dbs.phpt b/ext/mysql/tests/mysql_list_dbs.phpt index 6900ab0e0a..054e02ef98 100644 --- a/ext/mysql/tests/mysql_list_dbs.phpt +++ b/ext/mysql/tests/mysql_list_dbs.phpt @@ -20,7 +20,7 @@ if (NULL !== ($tmp = @mysql_list_dbs($link, $link))) require('table.inc'); -if (!$res = mysql_list_dbs($link)) +if (!$res = @mysql_list_dbs($link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$num = mysql_num_rows($res)) @@ -34,7 +34,7 @@ if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row[0])) { mysql_free_result($res); -if (!$res2 = mysql_list_dbs()) +if (!$res2 = @mysql_list_dbs()) printf("[006] [%d] %s\n", mysql_errno(), mysql_error()); $row2 = mysql_fetch_array($res2, MYSQL_NUM); @@ -51,9 +51,4 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- -Deprecated: Function mysql_list_dbs() is deprecated in %s on line 15 - -Deprecated: mysql_list_dbs(): This function is deprecated; use mysql_query() with SHOW DATABASES instead in %s on line %d - -Deprecated: mysql_list_dbs(): This function is deprecated; use mysql_query() with SHOW DATABASES instead in %s on line %d -done! +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_trace_mode.phpt b/ext/mysql/tests/mysql_trace_mode.phpt index 622f413062..2b6c61d27b 100644 --- a/ext/mysql/tests/mysql_trace_mode.phpt +++ b/ext/mysql/tests/mysql_trace_mode.phpt @@ -14,10 +14,10 @@ require_once('table.inc'); $res1 = mysql_query('SELECT id FROM test', $link); -if (!$res2 = mysql_db_query($db, 'SELECT id FROM test', $link)) +if (!$res2 = @mysql_db_query($db, 'SELECT id FROM test', $link)) printf("[001] [%d] %s\n", mysql_errno($link), mysql_error($link)); mysql_free_result($res2); -print mysql_escape_string("I don't mind character sets, do I?\n"); +print @mysql_escape_string("I don't mind character sets, do I?\n"); $res3 = mysql_query('BOGUS_SQL', $link); mysql_close($link); @@ -29,9 +29,6 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- -Deprecated: mysql_db_query(): %s - -Deprecated: mysql_escape_string(): %s I don\'t mind character sets, do I?\n Warning: mysql_query(): 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 'BOGUS_SQL' at line 1 in %s on line %d done!