summaryrefslogtreecommitdiff
path: root/ext/dba/tests
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-12-20 17:47:58 +0000
committerMarcus Boerger <helly@php.net>2002-12-20 17:47:58 +0000
commitefd314e7676ee15fce07e282b0655b539eb1f5cc (patch)
treebaf9c56a1a400886fbe21aefd0141be4df682b99 /ext/dba/tests
parent710e49a30b67ca589f49a0db64b0fad08634a2e5 (diff)
downloadphp-git-efd314e7676ee15fce07e282b0655b539eb1f5cc.tar.gz
-Fix memory handling of persistent dba connections.
-Update tests. # cdb and flatfile still FAIL for dba_popen since the known streams problem
Diffstat (limited to 'ext/dba/tests')
-rw-r--r--ext/dba/tests/dba_cdb.phpt22
-rw-r--r--ext/dba/tests/dba_handler.inc53
2 files changed, 44 insertions, 31 deletions
diff --git a/ext/dba/tests/dba_cdb.phpt b/ext/dba/tests/dba_cdb.phpt
index 2390acbce5..9a881706ee 100644
--- a/ext/dba/tests/dba_cdb.phpt
+++ b/ext/dba/tests/dba_cdb.phpt
@@ -4,7 +4,7 @@ DBA CDB handler test
<?php
require_once('skipif.inc');
if (!in_array('cdb', dba_handlers())) die('skip CDB handler not available');
- die('skip CDB does not support replace or delete');
+ die('info CDB does not support replace or delete');
?>
--FILE--
<?php
@@ -14,17 +14,17 @@ DBA CDB handler test
?>
--EXPECT--
database handler: cdb
-3NYNYY
+5YYYYY
Content String 2
-Content 2 replaced
-Read during write: not allowed
-Content 2 replaced 2nd time
-The 6th value
-array(3) {
- ["key number 6"]=>
- string(13) "The 6th value"
+array(5) {
+ ["key1"]=>
+ string(16) "Content String 1"
["key2"]=>
- string(27) "Content 2 replaced 2nd time"
+ string(16) "Content String 2"
+ ["key3"]=>
+ string(20) "Third Content String"
+ ["key4"]=>
+ string(22) "Another Content String"
["key5"]=>
string(23) "The last content string"
-} \ No newline at end of file
+}
diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc
index dafc991025..66a356bb18 100644
--- a/ext/dba/tests/dba_handler.inc
+++ b/ext/dba/tests/dba_handler.inc
@@ -6,8 +6,15 @@
dba_insert("key3", "Third Content String", $db_file);
dba_insert("key4", "Another Content String", $db_file);
dba_insert("key5", "The last content string", $db_file);
- dba_delete("key3", $db_file);
- dba_delete("key1", $db_file);
+ if ($handler != 'cdb') {
+ dba_delete("key3", $db_file);
+ dba_delete("key1", $db_file);
+ } else {
+ dba_close($db_file);
+ if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))===FALSE) {
+ echo "Error reopening database\n";
+ }
+ }
$a = dba_firstkey($db_file);
$i=0;
while($a) {
@@ -20,28 +27,32 @@
}
echo "\n";
echo dba_fetch("key2", $db_file)."\n";
- dba_replace("key2", "Content 2 replaced", $db_file);
- echo dba_fetch("key2", $db_file)."\n";
+ if ($handler != 'cdb') {
+ dba_replace("key2", "Content 2 replaced", $db_file);
+ echo dba_fetch("key2", $db_file)."\n";
+ }
dba_close($db_file);
} else {
echo "Error creating database\n";
}
- $db_writer = dba_open($db_filename, 'w'.$lock_flag, $handler);
- if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.($lock_flag ? 't' : ''), $handler))===false) {
- echo "Read during write: not allowed\n";
- } else {
- echo "Read during write: allowed\n";
- }
- if ($db_writer!==FALSE) {
- dba_insert("key number 6", "The 6th value", $db_writer);
- @dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer);
- dba_replace("key2", "Content 2 replaced 2nd time", $db_writer);
- dba_delete("key4", $db_writer);
- echo dba_fetch("key2", $db_writer)."\n";
- echo dba_fetch("key number 6", $db_writer)."\n";
- dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io.
- } else {
- die("Error reopening database\n");
+ if ($handler != 'cdb') {
+ $db_writer = dba_open($db_filename, 'w'.$lock_flag, $handler);
+ if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.($lock_flag ? 't' : ''), $handler))===false) {
+ echo "Read during write: not allowed\n";
+ } else {
+ echo "Read during write: allowed\n";
+ }
+ if ($db_writer!==FALSE) {
+ dba_insert("key number 6", "The 6th value", $db_writer);
+ @dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer);
+ dba_replace("key2", "Content 2 replaced 2nd time", $db_writer);
+ dba_delete("key4", $db_writer);
+ echo dba_fetch("key2", $db_writer)."\n";
+ echo dba_fetch("key number 6", $db_writer)."\n";
+ dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io.
+ } else {
+ die("Error reopening database\n");
+ }
}
if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))!==FALSE) {
$key = dba_firstkey($db_file);
@@ -59,4 +70,6 @@
if ($dba_reader) {
dba_close($dba_reader);
}
+ if (($db_file = dba_popen($db_filename, 'r'.($handler!='gdbm'?'-':''), $handler))!==FALSE) {
+ }
?> \ No newline at end of file