xref: /PHP-7.4/ext/dba/tests/dba_db4_003.phpt (revision 26dfce7f)
1--TEST--
2DBA DB4 File Creation open("c") with existing 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
16var_dump(file_put_contents($db_filename, "Dummy contents"));
17
18if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) {
19    if (file_exists($db_filename)) {
20        echo "database file created\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// Check the file still exists
30$s = file_get_contents($db_filename);
31echo "$s\n";
32
33?>
34--CLEAN--
35<?php
36require(__DIR__ .'/clean.inc');
37?>
38--EXPECTF--
39database handler: db4
40int(14)
41
42Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_003.php on line %d
43Error creating %stest0.dbm
44Dummy contents
45