Annotation of embedaddon/php/ext/mysql/tests/mysql_db_name.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysql_db_name()
3: --SKIPIF--
4: <?php
5: require_once('skipif.inc');
6: require_once('skipifconnectfailure.inc');
7: ?>
8: --FILE--
9: <?php
10: include "connect.inc";
11:
12: $tmp = NULL;
13: $link = NULL;
14:
15: if (NULL !== ($tmp = @mysql_db_name()))
16: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
17:
18: if (NULL !== ($tmp = @mysql_db_name($link, $link)))
19: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
20:
21: require('table.inc');
22:
23: if (!$res = @mysql_list_dbs($link))
24: printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
25:
26: if (!$num = mysql_num_rows($res))
27: printf("[004] Empty database list? [%d] %s\n", mysql_errno($link), mysql_error($link));
28:
29: if (false !== ($tmp = mysql_db_name($res, -1)))
30: printf("[005] Expecting boolean/false, got %s/%s. [%d] %s\n",
31: gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
32:
33: if (false !== ($tmp = mysql_db_name($res, $num + 1)))
34: printf("[006] Expecting boolean/false, got %s/%s. [%d] %s\n",
35: gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
36:
37: $unicode = (boolean)(version_compare(PHP_VERSION, '5.9.9', '>') == 1);
38: for ($i = 0; $i < $num; $i++) {
39: if ('' === ($dbname = mysql_db_name($res, $i)))
40: printf("[%03d] Got empty database name! [%d] %s\n",
41: (($i * 2) + 1) + 6, mysql_errno($link), mysql_error($link));
42:
43: if ($unicode && !is_unicode($dbname)) {
44: printf("[%03d] Expecting unicode string! [%d] %s\n",
45: (($i * 2) + 2) + 6, mysql_errno($link), mysql_error($link));
46: var_inspect($dbname);
47: }
48: }
49:
50: mysql_free_result($res);
51:
52: if (false !== ($tmp = mysql_db_name($res, $num)))
53: printf("[999] Expecting boolean/false, got %s/%s. [%d] %s\n",
54: gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
55:
56: mysql_close($link);
57:
58: print "done!\n";
59: ?>
60: --EXPECTF--
61: Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in %s on line %d
62:
63: Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in %s on line %d
64:
65: Warning: mysql_db_name(): %d is not a valid MySQL result resource in %s on line %d
66: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>