1--TEST--
2function test: mysqli_character_set_name
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
8mysqli_check_skip_test();
9?>
10--FILE--
11<?php
12require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
13
14$link = default_mysqli_connect();
15
16$result = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation');
17$tmp = mysqli_fetch_assoc($result);
18mysqli_free_result($result);
19
20if (!$tmp['charset']) {
21    throw new Exception("Cannot determine current character set and collation");
22}
23
24$charset = mysqli_character_set_name($link);
25if ($tmp['charset'] !== $charset) {
26    printf("[001] Expecting character set %s/%s, got %s/%s\n", get_debug_type($tmp['charset']), $tmp['charset'], get_debug_type($charset), $charset);
27}
28
29mysqli_close($link);
30
31try {
32    mysqli_character_set_name($link);
33} catch (Error $exception) {
34    echo $exception->getMessage() . "\n";
35}
36
37print "done!";
38?>
39--EXPECT--
40mysqli object is already closed
41done!
42