xref: /PHP-8.1/ext/dba/tests/bug70825.phpt (revision 74859783)
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', -1, $db));
18var_dump(dba_fetch('foo', -1, $db));
19var_dump(dba_fetch('foo', -1, $db));
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'], -1, $db));
28var_dump(dba_fetch(['foo', 'bar'], -1, $db));
29var_dump(dba_fetch(['foo', 'bar'], -1, $db));
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', -1, $db));
38var_dump(dba_fetch('[foo]bar', -1, $db));
39var_dump(dba_fetch('[foo]bar', -1, $db));
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', 0, $db));
48var_dump(dba_fetch('[foo]bar', 1, $db));
49var_dump(dba_fetch('[foo]bar', 2, $db));
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';
69unlink($filename);
70?>
71