diff options
| author | Ulf Wendel <uw@php.net> | 2011-01-25 14:01:00 +0000 |
|---|---|---|
| committer | Ulf Wendel <uw@php.net> | 2011-01-25 14:01:00 +0000 |
| commit | cad4c3451065061649b2094b3af740533a90de0e (patch) | |
| tree | f4be589dafd6da38099a3d0314f7f3fe8dc6b9b1 /ext/mysql/tests | |
| parent | 8e57ad193b2703c46f15a9bdc3b2ed79c6c721e3 (diff) | |
| download | php-git-cad4c3451065061649b2094b3af740533a90de0e.tar.gz | |
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
Diffstat (limited to 'ext/mysql/tests')
| -rw-r--r-- | ext/mysql/tests/mysql_db_name.phpt | 2 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_deprecated_api.phpt | 78 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_escape_string.phpt | 14 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_list_dbs.phpt | 6 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_trace_mode.phpt | 9 |
5 files changed, 91 insertions, 18 deletions
diff --git a/ext/mysql/tests/mysql_db_name.phpt b/ext/mysql/tests/mysql_db_name.phpt index be4f604d9c..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)) 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-- +<?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 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 3e12ce5501..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,4 +51,4 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- -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 6d163d40f7..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,11 +29,6 @@ print "done!\n"; 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! |
