1--TEST--
2DBA with invalid array key
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7require_once __DIR__ . '/setup/setup_dba_tests.inc';
8check_skip_any();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/setup/setup_dba_tests.inc';
13$name = 'array_keys_errors.db';
14
15$db = get_any_db($name);
16
17try {
18    dba_insert([], "Content String 1", $db);
19} catch (\Error $e) {
20    echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
21}
22try {
23    dba_insert(["a", "b", "c"], "Content String 2", $db);
24} catch (\Error $e) {
25    echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
26}
27
28/* Use an object */
29$o = new stdClass();
30try {
31    var_dump(dba_insert([$o, 'obj'], 'Test', $db));
32} catch (\Error $e) {
33    echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
34}
35try {
36    var_dump(dba_insert(['group', $o], 'Test', $db));
37} catch (\Error $e) {
38    echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
39}
40
41dba_close($db);
42
43?>
44--CLEAN--
45<?php
46require_once __DIR__ . '/setup/setup_dba_tests.inc';
47$db_name = 'array_keys_errors.db';
48cleanup_standard_db($db_name);
49?>
50--EXPECTF--
51Using handler: "%s"
52Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name"
53Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name"
54Error: Object of class stdClass could not be converted to string
55Error: Object of class stdClass could not be converted to string
56