xref: /PHP-7.4/ext/dba/tests/dba_db4_008.phpt (revision 26dfce7f)
1--TEST--
2DBA DB4 Truncate Existing File popen("n")
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
16var_dump(file_put_contents($db_filename, "Dummy contents"));
17
18if (($db_file = dba_popen($db_filename, "n", $handler)) !== FALSE) {
19    if (file_exists($db_filename)) {
20        echo "database file created\n";
21        dba_insert("key1", "This is a test insert", $db_file);
22        echo dba_fetch("key1", $db_file), "\n";
23        dba_close($db_file);
24    } else {
25        echo "File did not get created\n";
26    }
27} else {
28    echo "Error creating $db_filename\n";
29}
30
31?>
32--CLEAN--
33<?php
34require(__DIR__ .'/clean.inc');
35?>
36--EXPECT--
37database handler: db4
38int(14)
39database file created
40This is a test insert
41