uw Tue, 25 Jan 2011 14:01:00 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=307731
Log: 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 Changed paths: U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_db_name.phpt A php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_deprecated_api.phpt U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_escape_string.phpt U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_list_dbs.phpt U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_trace_mode.phpt U php/php-src/trunk/ext/mysql/tests/mysql_db_name.phpt A php/php-src/trunk/ext/mysql/tests/mysql_deprecated_api.phpt U php/php-src/trunk/ext/mysql/tests/mysql_escape_string.phpt U php/php-src/trunk/ext/mysql/tests/mysql_list_dbs.phpt U php/php-src/trunk/ext/mysql/tests/mysql_trace_mode.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_db_name.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_db_name.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_db_name.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -20,7 +20,7 @@ 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)) Added: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_deprecated_api.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_deprecated_api.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_deprecated_api.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -0,0 +1,78 @@ +--TEST-- +Check if deprecated API calls bail out +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--INI-- +mysql.trace_mode=1 +error_reporting=E_ALL | E_NOTICE | E_STRICT +--FILE-- +<?php +/* + We use an extra test to cover deprecation warning. + Due to this extra test we can silence deprecation warnings + in have other test using @ operator without loosing the information + which function is deprecated and, without reducing test portability. +*/ +include "table.inc"; + +if (version_compare(PHP_VERSION, '5.3.0') >= 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-- +<?php +require_once("clean_table.inc"); +?> +--EXPECTF-- +done! \ No newline at end of file Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_escape_string.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_escape_string.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_escape_string.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -12,13 +12,13 @@ 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!"; ?> Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_list_dbs.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_list_dbs.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_list_dbs.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -20,7 +20,7 @@ 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 @@ 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,4 +51,4 @@ require_once("clean_table.inc"); ?> --EXPECTF-- -done! +done! \ No newline at end of file Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_trace_mode.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_trace_mode.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_trace_mode.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -14,10 +14,10 @@ $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,11 +29,6 @@ require_once("clean_table.inc"); ?> --EXPECTF-- -Deprecated: Function mysql_db_query() is deprecated in %s on line %d - -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! Modified: php/php-src/trunk/ext/mysql/tests/mysql_db_name.phpt =================================================================== --- php/php-src/trunk/ext/mysql/tests/mysql_db_name.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/trunk/ext/mysql/tests/mysql_db_name.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -20,7 +20,7 @@ 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 @@ 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 Added: php/php-src/trunk/ext/mysql/tests/mysql_deprecated_api.phpt =================================================================== --- php/php-src/trunk/ext/mysql/tests/mysql_deprecated_api.phpt (rev 0) +++ php/php-src/trunk/ext/mysql/tests/mysql_deprecated_api.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -0,0 +1,78 @@ +--TEST-- +Check if deprecated API calls bail out +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--INI-- +mysql.trace_mode=1 +error_reporting=E_ALL | E_NOTICE | E_STRICT +--FILE-- +<?php +/* + We use an extra test to cover deprecation warning. + Due to this extra test we can silence deprecation warnings + in have other test using @ operator without loosing the information + which function is deprecated and, without reducing test portability. +*/ +include "table.inc"; + +if (version_compare(PHP_VERSION, '5.3.0') >= 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-- +<?php +require_once("clean_table.inc"); +?> +--EXPECTF-- +done! \ No newline at end of file Modified: php/php-src/trunk/ext/mysql/tests/mysql_escape_string.phpt =================================================================== --- php/php-src/trunk/ext/mysql/tests/mysql_escape_string.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/trunk/ext/mysql/tests/mysql_escape_string.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -12,13 +12,13 @@ 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!"; ?> Modified: php/php-src/trunk/ext/mysql/tests/mysql_list_dbs.phpt =================================================================== --- php/php-src/trunk/ext/mysql/tests/mysql_list_dbs.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/trunk/ext/mysql/tests/mysql_list_dbs.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -20,7 +20,7 @@ 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 @@ 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 @@ 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 Modified: php/php-src/trunk/ext/mysql/tests/mysql_trace_mode.phpt =================================================================== --- php/php-src/trunk/ext/mysql/tests/mysql_trace_mode.phpt 2011-01-25 12:51:29 UTC (rev 307730) +++ php/php-src/trunk/ext/mysql/tests/mysql_trace_mode.phpt 2011-01-25 14:01:00 UTC (rev 307731) @@ -14,10 +14,10 @@ $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 @@ 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!
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php