summaryrefslogtreecommitdiff
path: root/ext/mysql/tests/mysql_set_charset.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/mysql/tests/mysql_set_charset.phpt
downloadphp2-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/mysql/tests/mysql_set_charset.phpt')
-rw-r--r--ext/mysql/tests/mysql_set_charset.phpt61
1 files changed, 61 insertions, 0 deletions
diff --git a/ext/mysql/tests/mysql_set_charset.phpt b/ext/mysql/tests/mysql_set_charset.phpt
new file mode 100644
index 0000000..953323b
--- /dev/null
+++ b/ext/mysql/tests/mysql_set_charset.phpt
@@ -0,0 +1,61 @@
+--TEST--
+mysql_set_charset() - STUB, function usage not recommended
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+
+if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
+ die('skip set character set not functional with PHP 6 (fomerly PHP 6 && unicode.semantics=On)');
+}
+
+if (!function_exists('mysql_set_charset'))
+ die("skip Function not available");
+?>
+--FILE--
+<?php
+include_once "connect.inc";
+
+$tmp = NULL;
+$link = NULL;
+
+if (!is_null($tmp = @mysql_set_charset()))
+ printf("[001] Expecting NULL got %s/%s\n", $tmp, gettype($tmp));
+
+if (false !== ($tmp = @mysql_set_charset($link)))
+ printf("[002] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
+
+if (false !== ($tmp = @mysql_set_charset(-1)))
+ printf("[003] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
+
+if (!is_null($tmp = @mysql_set_charset('somecharset', $link)))
+ printf("[004] Expecting NULL got %s/%s\n", $tmp, gettype($tmp));
+
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+/* unicode mode should throw a warning */
+$tmp = mysql_set_charset('uFt8', $link);
+
+if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1))
+ $expect = false;
+else
+ $expect = true;
+
+$charsets = array('latin1', 'latin2');
+foreach ($charsets as $k => $charset) {
+ if (!($res = mysql_query(sprintf('SHOW CHARACTER SET LIKE "%s"', $charset), $link)))
+ continue;
+ mysql_free_result($res);
+ if ($expect !== ($tmp = @mysql_set_charset($charset, $link)))
+ printf("[006] Expecting %s/%s got %s/%s\n",
+ gettype($expect), $expect,
+ gettype($tmp), $tmp);
+}
+
+mysql_close($link);
+print "done!";
+?>
+--EXPECTF--
+done!