xref: /PHP-5.3/ext/dba/tests/dba_db4_008.phpt (revision 7b329d5a)
1--TEST--
2DBA DB4 Truncate Existing File popen("n")
3--SKIPIF--
4<?php
5$handler = "db4";
6require_once(dirname(__FILE__) .'/skipif.inc');
7die("info $HND handler used");
8?>
9--FILE--
10<?php
11
12$handler = "db4";
13require_once(dirname(__FILE__) .'/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(dirname(__FILE__) .'/clean.inc');
35?>
36--EXPECTF--
37database handler: db4
38int(14)
39database file created
40This is a test insert
41