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 = $link->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation');
17$tmp = $result->fetch_assoc();
18$result->free_result();
19
20if (!$tmp['charset']) {
21    throw new Exception("Cannot determine current character set and collation");
22}
23
24$charset = $link->character_set_name();
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
29$link->close();
30
31try {
32    $link->character_set_name();
33} catch (Error $exception) {
34    echo $exception->getMessage() . "\n";
35}
36
37print "done!";
38?>
39--EXPECT--
40mysqli object is already closed
41done!
42