xref: /PHP-7.1/ext/dba/tests/bug70825.phpt (revision 84512a11)
1--TEST--
2Bug #70825 (Cannot fetch multiple values with group in ini file)
3--SKIPIF--
4<?php
5if (!extension_loaded('dba')) die('skip dba extension not available');
6if (!in_array('inifile', dba_handlers())) die('skip inifile handler not available');
7?>
8--FILE--
9<?php
10$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
11
12$db = dba_open($filename, 'n', 'inifile');
13dba_insert('foo', 23, $db);
14dba_insert('foo', 42, $db);
15dba_insert('foo', 1337, $db);
16var_dump(dba_fetch('foo', -1, $db));
17var_dump(dba_fetch('foo', -1, $db));
18var_dump(dba_fetch('foo', -1, $db));
19dba_close($db);
20unlink($filename);
21
22$db = dba_open($filename, 'n', 'inifile');
23dba_insert(['foo', 'bar'], 23, $db);
24dba_insert(['foo', 'bar'], 42, $db);
25dba_insert(['foo', 'bar'], 1337, $db);
26var_dump(dba_fetch(['foo', 'bar'], -1, $db));
27var_dump(dba_fetch(['foo', 'bar'], -1, $db));
28var_dump(dba_fetch(['foo', 'bar'], -1, $db));
29dba_close($db);
30unlink($filename);
31
32$db = dba_open($filename, 'n', 'inifile');
33dba_insert('[foo]bar', 23, $db);
34dba_insert('[foo]bar', 42, $db);
35dba_insert('[foo]bar', 1337, $db);
36var_dump(dba_fetch('[foo]bar', -1, $db));
37var_dump(dba_fetch('[foo]bar', -1, $db));
38var_dump(dba_fetch('[foo]bar', -1, $db));
39dba_close($db);
40unlink($filename);
41
42$db = dba_open($filename, 'n', 'inifile');
43dba_insert('[foo]bar', 23, $db);
44dba_insert('[foo]bar', 42, $db);
45dba_insert('[foo]bar', 1337, $db);
46var_dump(dba_fetch('[foo]bar', 0, $db));
47var_dump(dba_fetch('[foo]bar', 1, $db));
48var_dump(dba_fetch('[foo]bar', 2, $db));
49dba_close($db);
50unlink($filename);
51?>
52==DONE==
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==DONE==
67--CLEAN--
68<?php
69$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
70unlink($filename);
71?>
72