xref: /PHP-7.2/ext/mysqli/tests/mysqli_close.phpt (revision f1d7e3ca)
1--TEST--
2mysqli_close()
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_close()))
17		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19	if (!is_null($tmp = @mysqli_close($link, $link)))
20		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
21
22	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
23		printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
24			$host, $user, $db, $port, $socket);
25
26	$tmp = @mysqli_close(NULL);
27	if (NULL !== $tmp)
28		printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
29
30	$tmp = mysqli_close($link);
31	if (true !== $tmp)
32		printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
33
34	if (!is_null($tmp = @mysqli_query($link, "SELECT 1")))
35		printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
36
37	print "done!";
38?>
39--EXPECTF--
40done!
41