xref: /PHP-7.2/ext/dba/tests/dba_db4_018.phpt (revision 17ccbeec)
1--TEST--
2DBA DB4 with persistent connections
3--SKIPIF--
4<?php
5$handler = "db4";
6require_once(dirname(__FILE__) .'/skipif.inc');
7die("info $HND handler used");
8?>
9--FILE--
10<?php
11
12$handler = "db4";
13require_once(dirname(__FILE__) .'/test.inc');
14echo "database handler: $handler\n";
15
16echo "Test 1\n";
17$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
18dba_insert("key1", "This is a test insert 1", $db_file1);
19echo dba_fetch("key1", $db_file1), "\n";
20
21
22echo "Test 2\n";
23$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
24if ($db_file1 === $db_file2) {
25    echo "resources are the same\n";
26} else {
27    echo "resources are different\n";
28}
29
30
31echo "Test 3 - fetch both rows from second resource\n";
32dba_insert("key2", "This is a test insert 2", $db_file2);
33echo dba_fetch("key1", $db_file2), "\n";
34echo dba_fetch("key2", $db_file2), "\n";
35
36
37echo "Test 4 - fetch both rows from first resource\n";
38echo dba_fetch("key1", $db_file1), "\n";
39echo dba_fetch("key2", $db_file1), "\n";
40
41echo "Test 5 - close 2nd resource\n";
42dba_close($db_file2);
43var_dump($db_file1);
44var_dump($db_file2);
45
46echo "Test 6 - query after closing 2nd resource\n";
47echo dba_fetch("key1", $db_file1), "\n";
48echo dba_fetch("key2", $db_file1), "\n";
49
50?>
51===DONE===
52--CLEAN--
53<?php
54	require(dirname(__FILE__) .'/clean.inc');
55?>
56--XFAIL--
57Test 6 crashes with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278
58--EXPECTF--
59database handler: db4
60Test 1
61This is a test insert 1
62Test 2
63resources are different
64Test 3 - fetch both rows from second resource
65This is a test insert 1
66This is a test insert 2
67Test 4 - fetch both rows from first resource
68This is a test insert 1
69This is a test insert 2
70Test 5 - close 2nd resource
71resource(%d) of type (dba persistent)
72resource(%d) of type (Unknown)
73Test 6 - query after closing 2nd resource
74This is a test insert 1
75This is a test insert 2
76===DONE===
77