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