xref: /PHP-7.2/ext/dba/tests/dba_cdb_001.phpt (revision 17ccbeec)
1--TEST--
2DBA CDB handler test
3--SKIPIF--
4<?php
5$handler = 'cdb';
6require_once(dirname(__FILE__) .'/skipif.inc');
7die('info CDB does not support replace or delete');
8?>
9--FILE--
10<?php
11
12$handler = 'cdb';
13require_once(dirname(__FILE__) .'/test.inc');
14
15echo "Test 0\n";
16
17if (($db_file = dba_open($db_filename, 'n', $handler))!==FALSE) {
18    var_dump(dba_insert("key1", "Content String 1", $db_file));
19    var_dump(dba_replace("key1", "New Content String", $db_file));
20    var_dump(dba_fetch("key1", $db_file));
21    var_dump(dba_firstkey($db_file));
22    var_dump(dba_delete("key1", $db_file));
23    var_dump(dba_optimize($db_file));
24    var_dump(dba_sync($db_file));
25    dba_close($db_file);
26}
27else {
28    echo "Failed to open DB\n";
29}
30
31unlink($db_filename);
32
33echo "Test 1\n";
34
35if (($db_file = dba_open($db_filename, 'c', $handler))!==FALSE) {
36    dba_insert("key1", "Content String 1", $db_file);
37    dba_close($db_file);
38}
39else {
40    echo "Failed to open DB\n";
41}
42
43echo "Test 2\n";
44
45if (($db_file = dba_open($db_filename, 'r', $handler))!==FALSE) {
46    dba_insert("key1", "Content String 1", $db_file);
47    dba_close($db_file);
48}
49else {
50    echo "Failed to open DB\n";
51}
52
53echo "Test 3\n";
54
55if (($db_file = dba_open($db_filename, 'w', $handler))!==FALSE) {
56    echo dba_fetch("key1", $db_file), "\n";
57    dba_close($db_file);
58}
59else {
60    echo "Failed to open DB\n";
61}
62
63?>
64===DONE===
65--CLEAN--
66<?php
67require(dirname(__FILE__) .'/clean.inc');
68?>
69--EXPECTF--
70Test 0
71bool(true)
72bool(false)
73bool(false)
74bool(false)
75bool(false)
76bool(true)
77bool(true)
78Test 1
79
80Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
81Failed to open DB
82Test 2
83
84Warning: dba_insert(): You cannot perform a modification to a database without proper access in %sdba_cdb_001.php on line %d
85Test 3
86
87Warning: dba_open(%stest0.dbm,w): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
88Failed to open DB
89===DONE===
90