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