xref: /PHP-5.5/ext/mysqli/tests/mysqli_ping.phpt (revision eb0e09f5)
1--TEST--
2mysqli_ping()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11	require_once("connect.inc");
12
13	$tmp    = NULL;
14	$link   = NULL;
15
16	if (!is_null($tmp = @mysqli_ping()))
17		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19	require('table.inc');
20
21	if (!is_null($tmp = @mysqli_ping($link, $link)))
22		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
23
24	var_dump(mysqli_ping($link));
25
26	// provoke an error to check if mysqli_ping resets it
27	$res = mysqli_query($link, 'SELECT * FROM unknown_table');
28	if (!($errno = mysqli_errno($link)))
29		printf("[003] Statement should have caused an error\n");
30
31	var_dump(mysqli_ping($link));
32	if ($errno === mysqli_errno($link))
33		printf("[004] Error codes should have been reset\n");
34
35	mysqli_close($link);
36
37	if (!is_null($tmp = mysqli_ping($link)))
38		printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
39
40	print "done!";
41?>
42--EXPECTF--
43bool(true)
44bool(true)
45
46Warning: mysqli_ping(): Couldn't fetch mysqli in %s on line %d
47done!