xref: /PHP-7.4/ext/dba/tests/dba_db4_016.phpt (revision 26dfce7f)
1--TEST--
2DBA DB4 File Creation popen("c") with existing valid file
3--SKIPIF--
4<?php
5$handler = "db4";
6require_once(__DIR__ .'/skipif.inc');
7die("info $HND handler used");
8?>
9--FILE--
10<?php
11
12$handler = "db4";
13require_once(__DIR__ .'/test.inc');
14echo "database handler: $handler\n";
15
16if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
17    if (file_exists($db_filename)) {
18        echo "database file created\n";
19        var_dump(dba_insert("key1", "This is a test insert", $db_file));
20        echo dba_fetch("key1", $db_file), "\n";
21        dba_close($db_file);
22    } else {
23        echo "File did not get created\n";
24    }
25} else {
26    echo "Error creating $db_filename\n";
27}
28
29// Now test reopening it
30if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
31    if (file_exists($db_filename)) {
32        echo "database file created\n";
33        var_dump(dba_insert("key1", "second open test", $db_file));
34        var_dump(dba_insert("key2", "second open test row 2", $db_file));
35        echo dba_fetch("key1", $db_file), "\n";
36        echo dba_fetch("key2", $db_file), "\n";
37        dba_close($db_file);
38    } else {
39        echo "File did not get created\n";
40    }
41} else {
42    echo "Error creating $db_filename\n";
43}
44
45?>
46--CLEAN--
47<?php
48require(__DIR__ .'/clean.inc');
49?>
50--EXPECT--
51database handler: db4
52database file created
53bool(true)
54This is a test insert
55database file created
56bool(false)
57bool(true)
58This is a test insert
59second open test row 2
60