xref: /PHP-5.4/ext/mysql/tests/mysql_stat.phpt (revision 20e76f44)
1--TEST--
2mysql_stat()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include_once "connect.inc";
11
12$dbname = 'test';
13$tmp    = NULL;
14$link   = NULL;
15
16if (!is_null($tmp = @mysql_stat($link)))
17	printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19require('table.inc');
20
21if (!is_null($tmp = @mysql_stat($link, "foo")))
22	printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
23
24if ((!is_string($stat = mysql_stat($link))) || ('' === $stat))
25	printf("[003] Expecting non empty string, got %s/'%s', [%d] %s\n",
26		gettype($stat), $stat, mysql_errno($link), mysql_error($link));
27
28if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($stat)) {
29	printf("[004] Expecting Unicode error message!\n");
30	var_inspect($stat);
31}
32
33if ((!is_string($stat_def = mysql_stat())) || ('' === $stat_def))
34	printf("[003] Expecting non empty string, got %s/'%s', [%d] %s\n",
35		gettype($stat_def), $stat_def, mysql_errno(), mysql_error());
36
37assert(soundex($stat) === soundex($stat_def));
38
39mysql_close($link);
40
41if (false !== ($tmp = mysql_stat($link)))
42	printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
43
44print "done!";
45?>
46--EXPECTF--
47Warning: mysql_stat(): %d is not a valid MySQL-Link resource in %s on line %d
48done!
49