xref: /PHP-8.1/ext/dba/tests/dba_db4_003.phpt (revision b5a14e6c)
1--TEST--
2DBA DB4 File Creation open("c") with existing file
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7$handler = "db4";
8require_once(__DIR__ .'/skipif.inc');
9die("info $HND handler used");
10?>
11--FILE--
12<?php
13
14$handler = "db4";
15require_once(__DIR__ .'/test.inc');
16echo "database handler: $handler\n";
17
18var_dump(file_put_contents($db_filename, "Dummy contents"));
19
20if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) {
21    if (file_exists($db_filename)) {
22        echo "database file created\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// Check the file still exists
32$s = file_get_contents($db_filename);
33echo "$s\n";
34
35?>
36--CLEAN--
37<?php
38require(__DIR__ .'/clean.inc');
39?>
40--EXPECTF--
41database handler: db4
42int(14)
43
44Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_003.php on line %d
45Error creating %stest0.dbm
46Dummy contents
47