xref: /PHP-8.1/ext/dba/tests/dba_db4_007.phpt (revision b5a14e6c)
1--TEST--
2DBA DB4 File Creation popen("c") with existing invalid 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_popen($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?>
32--CLEAN--
33<?php
34require(__DIR__ .'/clean.inc');
35?>
36--EXPECTF--
37database handler: db4
38int(14)
39
40Warning: dba_popen(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_007.php on line %d
41Error creating %stest0.dbm
42