diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt')
-rw-r--r-- | ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt new file mode 100644 index 0000000..72d171f --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt @@ -0,0 +1,88 @@ +--TEST-- +mysqli_real_escape_string() +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifemb.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + require_once("connect.inc"); + + $tmp = NULL; + $link = NULL; + + if (NULL !== ($tmp = @mysqli_real_escape_string())) + printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + + if (NULL !== ($tmp = @mysqli_real_escape_string($link))) + printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + + require('table.inc'); + + if (NULL !== ($tmp =@mysqli_real_escape_string($link, "фуу", "бар"))) + printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + + if ('фу\\\\бар' !== ($tmp = mysqli_real_escape_string($link, 'фу\\бар'))) + printf("[004] Expecting фу\\\\бар, got %s\n", $tmp); + + if ('бар\"фус' !== ($tmp = mysqli_real_escape_string($link, 'бар"фус'))) + printf("[005] Expecting бар\"фус, got %s\n", $tmp); + + if ("лала\'лали" !== ($tmp = mysqli_real_escape_string($link, "лала'лали"))) + printf("[006] Expecting лала'лали, got %s\n", $tmp); + + if ("абра\\nкадабра" !== ($tmp = mysqli_real_escape_string($link, "абра\nкадабра"))) + printf("[007] Expecting абра\\nкадабра, got %s\n", $tmp); + + if ("манда\\rин" !== ($tmp = mysqli_real_escape_string($link, "манда\rин"))) + printf("[008] Expecting \\r, got %s\n", $tmp); + + if ("иху\\0аху" !== ($tmp = mysqli_real_escape_string($link, "иху" . chr(0) . "аху"))) + printf("[009] Expecting %s, got %s\n", "иху\\0аху", $tmp); + + if (($exp='абра\\\\ка\"да\\'."'".'бра\Zсим\\nсала\\rби\\0м') !== + ($tmp = mysqli_real_escape_string($link, "абра\\ка\"да'бра\032сим\nсала\rби" . chr(0) . "м"))) + { + printf("[010] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); + } + + if ('富\\\\酒吧' !== ($tmp = mysqli_real_escape_string($link, '富\\酒吧'))) + printf("[011] Expecting 富\\\\酒吧, got %s\n", $tmp); + + if ('酒吧\"小题大做' !== ($tmp = mysqli_real_escape_string($link, '酒吧"小题大做'))) + printf("[012] Expecting 酒吧\"小题大做, got %s\n", $tmp); + + if ("拉拉\'西雅图" !== ($tmp = mysqli_real_escape_string($link, "拉拉'西雅图"))) + printf("[013] Expecting 拉拉'西雅图, got %s\n", $tmp); + + if ("阿卜拉\\n轻" !== ($tmp = mysqli_real_escape_string($link, "阿卜拉\n轻"))) + printf("[014] Expecting 阿卜拉\\n轻, got %s\n", $tmp); + + if ("张明安\\r在" !== ($tmp = mysqli_real_escape_string($link, "张明安\r在"))) + printf("[015] Expecting 张明安\\r在, got %s\n", $tmp); + + if ("竺可桢\\0空调器" !== ($tmp = mysqli_real_escape_string($link, "竺可桢" . chr(0) . "空调器"))) + printf("[016] Expecting %s, got %s\n", "竺可桢\\0空调器", $tmp); + + if (($exp='阿卜拉\\\\嘉\"达丰\\'."'".'乳罩\Z辛\\n萨拉\\r毕\\0米') !== + ($tmp = mysqli_real_escape_string($link, "阿卜拉\\嘉\"达丰'乳罩\032辛\n萨拉\r毕" . chr(0) . "米"))) + { + printf("[017] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); + } + + mysqli_close($link); + + if (NULL !== ($tmp = mysqli_real_escape_string($link, 'foo'))) + printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + + print "done!"; +?> +--CLEAN-- +<?php + require_once("clean_table.inc"); +?> +--EXPECTF-- +Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d +done!
\ No newline at end of file |