Annotation of embedaddon/php/ext/mysql/tests/mysql_set_charset.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysql_set_charset() - STUB, function usage not recommended
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifconnectfailure.inc');
! 7:
! 8: if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
! 9: die('skip set character set not functional with PHP 6 (fomerly PHP 6 && unicode.semantics=On)');
! 10: }
! 11:
! 12: if (!function_exists('mysql_set_charset'))
! 13: die("skip Function not available");
! 14: ?>
! 15: --FILE--
! 16: <?php
! 17: include_once "connect.inc";
! 18:
! 19: $tmp = NULL;
! 20: $link = NULL;
! 21:
! 22: if (!is_null($tmp = @mysql_set_charset()))
! 23: printf("[001] Expecting NULL got %s/%s\n", $tmp, gettype($tmp));
! 24:
! 25: if (false !== ($tmp = @mysql_set_charset($link)))
! 26: printf("[002] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
! 27:
! 28: if (false !== ($tmp = @mysql_set_charset(-1)))
! 29: printf("[003] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
! 30:
! 31: if (!is_null($tmp = @mysql_set_charset('somecharset', $link)))
! 32: printf("[004] Expecting NULL got %s/%s\n", $tmp, gettype($tmp));
! 33:
! 34: if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
! 35: printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
! 36: $host, $user, $db, $port, $socket);
! 37:
! 38: /* unicode mode should throw a warning */
! 39: $tmp = mysql_set_charset('uFt8', $link);
! 40:
! 41: if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1))
! 42: $expect = false;
! 43: else
! 44: $expect = true;
! 45:
! 46: $charsets = array('latin1', 'latin2');
! 47: foreach ($charsets as $k => $charset) {
! 48: if (!($res = mysql_query(sprintf('SHOW CHARACTER SET LIKE "%s"', $charset), $link)))
! 49: continue;
! 50: mysql_free_result($res);
! 51: if ($expect !== ($tmp = @mysql_set_charset($charset, $link)))
! 52: printf("[006] Expecting %s/%s got %s/%s\n",
! 53: gettype($expect), $expect,
! 54: gettype($tmp), $tmp);
! 55: }
! 56:
! 57: mysql_close($link);
! 58: print "done!";
! 59: ?>
! 60: --EXPECTF--
! 61: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>