xref: /PHP-8.3/ext/dba/tests/bug70825.phpt (revision 134441ef)
1--TEST--
2Bug #70825 (Cannot fetch multiple values with group in ini file)
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7if (!in_array('inifile', dba_handlers())) die('skip inifile handler not available');
8?>
9--FILE--
10<?php
11$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
12
13$db = dba_open($filename, 'n', 'inifile');
14dba_insert('foo', 23, $db);
15dba_insert('foo', 42, $db);
16dba_insert('foo', 1337, $db);
17var_dump(dba_fetch('foo', $db, -1));
18var_dump(dba_fetch('foo', $db, -1));
19var_dump(dba_fetch('foo', $db, -1));
20dba_close($db);
21unlink($filename);
22
23$db = dba_open($filename, 'n', 'inifile');
24dba_insert(['foo', 'bar'], 23, $db);
25dba_insert(['foo', 'bar'], 42, $db);
26dba_insert(['foo', 'bar'], 1337, $db);
27var_dump(dba_fetch(['foo', 'bar'], $db, -1));
28var_dump(dba_fetch(['foo', 'bar'], $db, -1));
29var_dump(dba_fetch(['foo', 'bar'], $db, -1));
30dba_close($db);
31unlink($filename);
32
33$db = dba_open($filename, 'n', 'inifile');
34dba_insert('[foo]bar', 23, $db);
35dba_insert('[foo]bar', 42, $db);
36dba_insert('[foo]bar', 1337, $db);
37var_dump(dba_fetch('[foo]bar', $db, -1));
38var_dump(dba_fetch('[foo]bar', $db, -1));
39var_dump(dba_fetch('[foo]bar', $db, -1));
40dba_close($db);
41unlink($filename);
42
43$db = dba_open($filename, 'n', 'inifile');
44dba_insert('[foo]bar', 23, $db);
45dba_insert('[foo]bar', 42, $db);
46dba_insert('[foo]bar', 1337, $db);
47var_dump(dba_fetch('[foo]bar', $db, 0));
48var_dump(dba_fetch('[foo]bar', $db, 1));
49var_dump(dba_fetch('[foo]bar', $db, 2));
50dba_close($db);
51unlink($filename);
52?>
53--EXPECT--
54string(2) "23"
55string(2) "42"
56string(4) "1337"
57string(2) "23"
58string(2) "42"
59string(4) "1337"
60string(2) "23"
61string(2) "42"
62string(4) "1337"
63string(2) "23"
64string(2) "42"
65string(4) "1337"
66--CLEAN--
67<?php
68$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
69@unlink($filename);
70?>
71