summaryrefslogtreecommitdiff
path: root/ext/dba/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dba/tests')
-rw-r--r--ext/dba/tests/bug36436.phpt37
-rw-r--r--ext/dba/tests/bug38698.phpt26
-rw-r--r--ext/dba/tests/bug48240.phpt28
-rw-r--r--ext/dba/tests/bug49125.phpt30
-rw-r--r--ext/dba/tests/clean.inc5
-rw-r--r--ext/dba/tests/dba001.phpt25
-rw-r--r--ext/dba/tests/dba002.phpt26
-rw-r--r--ext/dba/tests/dba003.phpt28
-rw-r--r--ext/dba/tests/dba004.phpt32
-rw-r--r--ext/dba/tests/dba005.phpt39
-rw-r--r--ext/dba/tests/dba006.phpt41
-rw-r--r--ext/dba/tests/dba007.phpt52
-rw-r--r--ext/dba/tests/dba008.phpt37
-rw-r--r--ext/dba/tests/dba009.phpt37
-rw-r--r--ext/dba/tests/dba010.phpt44
-rw-r--r--ext/dba/tests/dba011.phpt38
-rw-r--r--ext/dba/tests/dba012.phpt42
-rw-r--r--ext/dba/tests/dba013.phpt27
-rw-r--r--ext/dba/tests/dba014.phpt27
-rw-r--r--ext/dba/tests/dba015.phpt76
-rw-r--r--ext/dba/tests/dba016.phpt23
-rw-r--r--ext/dba/tests/dba_cdb.phpt51
-rw-r--r--ext/dba/tests/dba_cdb_001.phpt89
-rw-r--r--ext/dba/tests/dba_cdb_make.phpt40
-rw-r--r--ext/dba/tests/dba_cdb_read.phpt65
-rw-r--r--ext/dba/tests/dba_db1.phpt46
-rw-r--r--ext/dba/tests/dba_db2.phpt46
-rw-r--r--ext/dba/tests/dba_db3.phpt46
-rw-r--r--ext/dba/tests/dba_db4_000.phpt50
-rw-r--r--ext/dba/tests/dba_db4_001.phpt32
-rw-r--r--ext/dba/tests/dba_db4_002.phpt32
-rw-r--r--ext/dba/tests/dba_db4_003.phpt46
-rw-r--r--ext/dba/tests/dba_db4_004.phpt40
-rw-r--r--ext/dba/tests/dba_db4_005.phpt32
-rw-r--r--ext/dba/tests/dba_db4_006.phpt32
-rw-r--r--ext/dba/tests/dba_db4_007.phpt41
-rw-r--r--ext/dba/tests/dba_db4_008.phpt40
-rw-r--r--ext/dba/tests/dba_db4_009.phpt53
-rw-r--r--ext/dba/tests/dba_db4_010.phpt38
-rw-r--r--ext/dba/tests/dba_db4_011.phpt36
-rw-r--r--ext/dba/tests/dba_db4_012.phpt31
-rw-r--r--ext/dba/tests/dba_db4_013.phpt40
-rw-r--r--ext/dba/tests/dba_db4_014.phpt32
-rw-r--r--ext/dba/tests/dba_db4_015.phpt39
-rw-r--r--ext/dba/tests/dba_db4_016.phpt59
-rw-r--r--ext/dba/tests/dba_db4_017.phpt37
-rw-r--r--ext/dba/tests/dba_db4_018.phpt76
-rw-r--r--ext/dba/tests/dba_db4_handlers.phpt50
-rw-r--r--ext/dba/tests/dba_db4_optimize.phpt38
-rw-r--r--ext/dba/tests/dba_db4_sync.phpt38
-rw-r--r--ext/dba/tests/dba_dbm.phpt46
-rw-r--r--ext/dba/tests/dba_flatfile.phpt50
-rw-r--r--ext/dba/tests/dba_gdbm.phpt34
-rw-r--r--ext/dba/tests/dba_handler.inc90
-rw-r--r--ext/dba/tests/dba_handlers.phpt69
-rw-r--r--ext/dba/tests/dba_inifile.phpt46
-rw-r--r--ext/dba/tests/dba_ndbm.phpt46
-rw-r--r--ext/dba/tests/dba_optimize.phpt51
-rw-r--r--ext/dba/tests/dba_qdbm.phpt34
-rw-r--r--ext/dba/tests/dba_split.phpt83
-rw-r--r--ext/dba/tests/dba_sync.phpt51
-rw-r--r--ext/dba/tests/dba_tcadb.phpt50
-rw-r--r--ext/dba/tests/skipif.inc23
-rw-r--r--ext/dba/tests/test.cdbbin0 -> 2230 bytes
-rw-r--r--ext/dba/tests/test.inc7
65 files changed, 2695 insertions, 0 deletions
diff --git a/ext/dba/tests/bug36436.phpt b/ext/dba/tests/bug36436.phpt
new file mode 100644
index 0000000..19254df
--- /dev/null
+++ b/ext/dba/tests/bug36436.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #36436 (DBA problem with Berkeley DB4)
+--SKIPIF--
+<?php
+ $handler = 'db4';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+
+$handler = 'db4';
+require_once(dirname(__FILE__) .'/test.inc');
+
+$db = dba_popen($db_filename, 'c', 'db4');
+
+dba_insert('X', 'XYZ', $db);
+dba_insert('Y', '123', $db);
+
+var_dump($db, dba_fetch('X', $db));
+
+var_dump(dba_firstkey($db));
+var_dump(dba_nextkey($db));
+
+dba_close($db);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+resource(%d) of type (dba persistent)
+string(3) "XYZ"
+string(1) "X"
+string(1) "Y"
+===DONE===
diff --git a/ext/dba/tests/bug38698.phpt b/ext/dba/tests/bug38698.phpt
new file mode 100644
index 0000000..56dde85
--- /dev/null
+++ b/ext/dba/tests/bug38698.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #38698 (Bug #38698 for some keys cdbmake creates corrupted db and cdb can't read valid db)
+--SKIPIF--
+<?php
+ $handler = 'cdb_make';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+
+$db_file = dirname(__FILE__) .'/129php.cdb';
+
+if (($db_make=dba_open($db_file, "n", 'cdb_make'))!==FALSE) {
+ dba_insert(pack('i',129), "Booo!", $db_make);
+ dba_close($db_make);
+ // write md5 checksum of generated database file
+ var_dump(md5_file($db_file));
+ @unlink($db_file);
+} else {
+ echo "Error creating database\n";
+}
+?>
+===DONE===
+--EXPECT--
+string(32) "1f34b74bde3744265acfc21e0f30af95"
+===DONE===
diff --git a/ext/dba/tests/bug48240.phpt b/ext/dba/tests/bug48240.phpt
new file mode 100644
index 0000000..5a72073
--- /dev/null
+++ b/ext/dba/tests/bug48240.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #48240 (DBA Segmentation fault dba_nextkey)
+--SKIPIF--
+<?php
+ $handler = 'db4';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+
+$handler = 'db4';
+require_once(dirname(__FILE__) .'/test.inc');
+
+$db = dba_open($db_filename, 'c', 'db4');
+
+var_dump(dba_nextkey($db));
+
+dba_close($db);
+
+?>
+===DONE===
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECT--
+bool(false)
+===DONE===
diff --git a/ext/dba/tests/bug49125.phpt b/ext/dba/tests/bug49125.phpt
new file mode 100644
index 0000000..e06495a
--- /dev/null
+++ b/ext/dba/tests/bug49125.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #49125 (Error in dba_exists C code)
+--SKIPIF--
+<?php
+ $handler = 'db4';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+$handler = 'db4';
+require_once(dirname(__FILE__) .'/test.inc');
+
+$db = dba_popen($db_filename, 'c', 'db4');
+
+dba_insert('foo', 'foo', $db);
+
+var_dump(dba_exists('foo', $db));
+
+dba_close($db);
+
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/dba/tests/clean.inc b/ext/dba/tests/clean.inc
new file mode 100644
index 0000000..7c53e7e
--- /dev/null
+++ b/ext/dba/tests/clean.inc
@@ -0,0 +1,5 @@
+<?php
+ $db_filename = dirname(__FILE__) .'/test0.dbm'; // see test.inc
+ @unlink($db_filename);
+ @unlink($db_filename.'.lck');
+?>
diff --git a/ext/dba/tests/dba001.phpt b/ext/dba/tests/dba001.phpt
new file mode 100644
index 0000000..b63829a
--- /dev/null
+++ b/ext/dba/tests/dba001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+DBA File Creation Test
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+ dba_close($db_file);
+ } else {
+ echo "$db_file does not exist\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+database file created
diff --git a/ext/dba/tests/dba002.phpt b/ext/dba/tests/dba002.phpt
new file mode 100644
index 0000000..e60e733
--- /dev/null
+++ b/ext/dba/tests/dba002.phpt
@@ -0,0 +1,26 @@
+--TEST--
+DBA Insert/Fetch Test
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file);
+ dba_close($db_file);
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+This is a test insert
diff --git a/ext/dba/tests/dba003.phpt b/ext/dba/tests/dba003.phpt
new file mode 100644
index 0000000..a027b53
--- /dev/null
+++ b/ext/dba/tests/dba003.phpt
@@ -0,0 +1,28 @@
+--TEST--
+DBA Insert/Replace/Fetch Test
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert("key1", "This is a test insert", $db_file);
+ dba_replace("key1", "This is the replacement text", $db_file);
+ $a = dba_fetch("key1", $db_file);
+ dba_close($db_file);
+ echo $a;
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+This is the replacement text
diff --git a/ext/dba/tests/dba004.phpt b/ext/dba/tests/dba004.phpt
new file mode 100644
index 0000000..6e7180c
--- /dev/null
+++ b/ext/dba/tests/dba004.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DBA Multiple Insert/Fetch Test
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ 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);
+ $a = dba_fetch("key4", $db_file);
+ $b = dba_fetch("key2", $db_file);
+ dba_close($db_file);
+ echo "$a $b";
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+Another Content String Content String 2
diff --git a/ext/dba/tests/dba005.phpt b/ext/dba/tests/dba005.phpt
new file mode 100644
index 0000000..68ad600
--- /dev/null
+++ b/ext/dba/tests/dba005.phpt
@@ -0,0 +1,39 @@
+--TEST--
+DBA FirstKey/NextKey Loop Test With 5 Items
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ 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);
+ $a = dba_firstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dba_nextkey($db_file);
+ $i++;
+ }
+ echo $i;
+ for ($i=1; $i<6; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ dba_close($db_file);
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+5YYYYY
diff --git a/ext/dba/tests/dba006.phpt b/ext/dba/tests/dba006.phpt
new file mode 100644
index 0000000..a3fc738
--- /dev/null
+++ b/ext/dba/tests/dba006.phpt
@@ -0,0 +1,41 @@
+--TEST--
+DBA FirstKey/NextKey with 2 deletes
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ 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);
+ $a = dba_firstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dba_nextkey($db_file);
+ $i++;
+ }
+ echo $i;
+ for ($i=1; $i<6; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ dba_close($db_file);
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+3NYNYY
diff --git a/ext/dba/tests/dba007.phpt b/ext/dba/tests/dba007.phpt
new file mode 100644
index 0000000..2519fdc
--- /dev/null
+++ b/ext/dba/tests/dba007.phpt
@@ -0,0 +1,52 @@
+--TEST--
+DBA Multiple File Creation Test
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ if (!function_exists('dba_list')) die('skip dba_list() not available');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ $db_file1 = $db_filename1 = dirname(__FILE__).'/test1.dbm';
+ $db_file2 = $db_filename2 = dirname(__FILE__).'/test2.dbm';
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ if (($db_file1=dba_open($db_file1, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ if (($db_file2=dba_open($db_file2, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ var_dump(dba_list());
+ dba_close($db_file);
+
+ @unlink($db_filename1);
+ @unlink($db_filename2);
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+database file created
+database file created
+database file created
+array(3) {
+ [%d]=>
+ string(%d) "%stest0.dbm"
+ [%d]=>
+ string(%d) "%stest1.dbm"
+ [%d]=>
+ string(%d) "%stest2.dbm"
+}
diff --git a/ext/dba/tests/dba008.phpt b/ext/dba/tests/dba008.phpt
new file mode 100644
index 0000000..f7015d9
--- /dev/null
+++ b/ext/dba/tests/dba008.phpt
@@ -0,0 +1,37 @@
+--TEST--
+DBA magic_quotes_runtime Test
+--SKIPIF--
+<?php
+ die('skip, magic_quotes removed');
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ ini_set('magic_quotes_runtime', 0);
+ dba_insert("key1", '"', $db_file);
+ var_dump(dba_fetch("key1", $db_file));
+ ini_set('magic_quotes_runtime', 1);
+ var_dump(dba_fetch("key1", $db_file));
+ dba_replace("key1", '\"', $db_file);
+ var_dump(dba_fetch("key1", $db_file));
+ ini_set('magic_quotes_runtime', 0);
+ var_dump(dba_fetch("key1", $db_file));
+ dba_close($db_file);
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+string(1) """
+string(2) "\""
+string(2) "\""
+string(1) """
diff --git a/ext/dba/tests/dba009.phpt b/ext/dba/tests/dba009.phpt
new file mode 100644
index 0000000..698657b
--- /dev/null
+++ b/ext/dba/tests/dba009.phpt
@@ -0,0 +1,37 @@
+--TEST--
+DBA dba_popen Test
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ print("info $HND handler used");
+?>
+--FILE--
+<?php
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ if (($db=dba_popen($db_file, "n", $handler))!==FALSE) {
+ echo "Opened\n";
+ dba_insert("a", "Inserted", $db);
+ echo dba_fetch("a", $db)."\n";
+ dba_close($db);
+ echo "Closed\n";
+ } else {
+ echo "Error creating database\n";
+ }
+ if (($db=dba_popen($db_file, "n", $handler))!==FALSE) {
+ echo "Opened\n";
+ dba_insert("a", "Inserted", $db);
+ echo dba_fetch("a", $db)."\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+Opened
+Inserted
+Closed
+Opened
+Inserted
diff --git a/ext/dba/tests/dba010.phpt b/ext/dba/tests/dba010.phpt
new file mode 100644
index 0000000..c818373
--- /dev/null
+++ b/ext/dba/tests/dba010.phpt
@@ -0,0 +1,44 @@
+--TEST--
+DBA with array keys
+--SKIPIF--
+<?php
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert(array("", "name0") , "Content String 1", $db_file);
+ dba_insert(array("key1", "name1") , "Content String 1", $db_file);
+ dba_insert(array("key2","name2"), "Content String 2", $db_file);
+ dba_insert("[key3]name3", "Third Content String", $db_file);
+ dba_insert(array("key4","name4"), "Another Content String", $db_file);
+ dba_insert(array("key5","name5"), "The last content string", $db_file);
+ $a = dba_firstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dba_nextkey($db_file);
+ $i++;
+ }
+ echo $i;
+ echo dba_exists(array("","name0"), $db_file) ? "Y" : "N";
+ for ($i=1; $i<5; $i++) {
+ echo dba_exists("[key$i]name$i", $db_file) ? "Y" : "N";
+ }
+ echo dba_exists(array("key5","name5"), $db_file) ? "Y" : "N";
+ echo "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+6YYYYYY
diff --git a/ext/dba/tests/dba011.phpt b/ext/dba/tests/dba011.phpt
new file mode 100644
index 0000000..71164be
--- /dev/null
+++ b/ext/dba/tests/dba011.phpt
@@ -0,0 +1,38 @@
+--TEST--
+DBA argument tests
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+var_dump(dba_open($db_file));
+var_dump(dba_open($db_file, 'n'));
+var_dump(dba_open($db_file, 'n', 'bogus'));
+var_dump(dba_open($db_file, 'q', $handler));
+var_dump(dba_open($db_file, 'nq', $handler));
+var_dump(dba_open($db_file, 'n', $handler, 2, 3, 4, 5, 6, 7, 8));
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: flatfile
+
+Warning: Wrong parameter count for dba_open() in %sdba011.php on line %d
+NULL
+resource(%d) of type (dba)
+
+Warning: dba_open(%stest0.dbm,n): No such handler: bogus in %sdba011.php on line %d
+bool(false)
+
+Warning: dba_open(%stest0.dbm,q): Illegal DBA mode in %sdba011.php on line %d
+bool(false)
+
+Warning: dba_open(%stest0.dbm,nq): Illegal DBA mode in %sdba011.php on line %d
+bool(false)
+resource(%d) of type (dba)
diff --git a/ext/dba/tests/dba012.phpt b/ext/dba/tests/dba012.phpt
new file mode 100644
index 0000000..821c4e2
--- /dev/null
+++ b/ext/dba/tests/dba012.phpt
@@ -0,0 +1,42 @@
+--TEST--
+DBA dba.default_handler tests
+--SKIPIF--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--INI--
+dba.default_handler=flatfile
+--FILE--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+echo "Test 1\n";
+
+ini_set('dba.default_handler', 'does_not_exist');
+
+var_dump(dba_open($db_filename, 'c'));
+
+echo "Test 2\n";
+
+ini_set('dba.default_handler', '');
+
+var_dump(dba_open($db_filename, 'n'));
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: flatfile
+Test 1
+
+Warning: ini_set(): No such handler: does_not_exist in %sdba012.php on line %d
+resource(%d) of type (dba)
+Test 2
+
+Warning: dba_open(%stest0.dbm,n): No default handler selected in %sdba012.php on line %d
+bool(false)
diff --git a/ext/dba/tests/dba013.phpt b/ext/dba/tests/dba013.phpt
new file mode 100644
index 0000000..bf95642
--- /dev/null
+++ b/ext/dba/tests/dba013.phpt
@@ -0,0 +1,27 @@
+--TEST--
+DBA with array key with empty array
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert(array(), "Content String 1", $db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+
+Catchable fatal error: dba_insert(): Key does not have exactly two elements: (key, name) in %sdba013.php on line %d
diff --git a/ext/dba/tests/dba014.phpt b/ext/dba/tests/dba014.phpt
new file mode 100644
index 0000000..7e52be7
--- /dev/null
+++ b/ext/dba/tests/dba014.phpt
@@ -0,0 +1,27 @@
+--TEST--
+DBA with array key with array containing too many elements
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert(array("a", "b", "c"), "Content String 2", $db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+
+Catchable fatal error: dba_insert(): Key does not have exactly two elements: (key, name) in %sdba014.php on line %d
diff --git a/ext/dba/tests/dba015.phpt b/ext/dba/tests/dba015.phpt
new file mode 100644
index 0000000..9f560c5
--- /dev/null
+++ b/ext/dba/tests/dba015.phpt
@@ -0,0 +1,76 @@
+--TEST--
+DBA with persistent connections
+--SKIPIF--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+echo "Test 1\n";
+$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
+dba_insert("key1", "This is a test insert 1", $db_file1);
+echo dba_fetch("key1", $db_file1), "\n";
+
+
+echo "Test 2\n";
+$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
+if ($db_file1 === $db_file2) {
+ echo "resources are the same\n";
+} else {
+ echo "resources are different\n";
+}
+
+
+echo "Test 3 - fetch both rows from second resource\n";
+dba_insert("key2", "This is a test insert 2", $db_file2);
+echo dba_fetch("key1", $db_file2), "\n";
+echo dba_fetch("key2", $db_file2), "\n";
+
+
+echo "Test 4 - fetch both rows from first resource\n";
+echo dba_fetch("key1", $db_file1), "\n";
+echo dba_fetch("key2", $db_file1), "\n";
+
+echo "Test 5 - close 2nd resource\n";
+dba_close($db_file2);
+var_dump($db_file1);
+var_dump($db_file2);
+
+echo "Test 6 - query after closing 2nd resource\n";
+echo dba_fetch("key1", $db_file1), "\n";
+echo dba_fetch("key2", $db_file1), "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--XFAIL--
+Test 6 crashes in flatfile_findkey with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278
+--EXPECTF--
+database handler: flatfile
+Test 1
+This is a test insert 1
+Test 2
+resources are different
+Test 3 - fetch both rows from second resource
+This is a test insert 1
+This is a test insert 2
+Test 4 - fetch both rows from first resource
+This is a test insert 1
+This is a test insert 2
+Test 5 - close 2nd resource
+resource(%d) of type (dba persistent)
+resource(%d) of type (Unknown)
+Test 6 - query after closing 2nd resource
+This is a test insert 1
+This is a test insert 2
+===DONE===
diff --git a/ext/dba/tests/dba016.phpt b/ext/dba/tests/dba016.phpt
new file mode 100644
index 0000000..29726ac
--- /dev/null
+++ b/ext/dba/tests/dba016.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DBA lock modifier error message test
+--SKIPIF--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+$db_file1 = dba_popen($db_filename, 'n-t', 'flatfile');
+
+?>
+===DONE===
+--EXPECTF--
+database handler: flatfile
+
+Warning: dba_popen(%stest0.dbm,n-t): You cannot combine modifiers - (no lock) and t (test lock) in %sdba016.php on line %d
+===DONE===
diff --git a/ext/dba/tests/dba_cdb.phpt b/ext/dba/tests/dba_cdb.phpt
new file mode 100644
index 0000000..b9ef68f
--- /dev/null
+++ b/ext/dba/tests/dba_cdb.phpt
@@ -0,0 +1,51 @@
+--TEST--
+DBA CDB handler test
+--SKIPIF--
+<?php
+ $handler = 'cdb';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die('info CDB does not support replace or delete');
+?>
+--FILE--
+<?php
+ $handler = 'cdb';
+ require_once(dirname(__FILE__) .'/test.inc');
+ require_once(dirname(__FILE__) .'/dba_handler.inc');
+?>
+===DONE===
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECT--
+database handler: cdb
+5YYYYY
+Content String 2
+array(5) {
+ ["key1"]=>
+ string(16) "Content String 1"
+ ["key2"]=>
+ 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-LOCK--
+5YYYYY
+Content String 2
+array(5) {
+ ["key1"]=>
+ string(16) "Content String 1"
+ ["key2"]=>
+ string(16) "Content String 2"
+ ["key3"]=>
+ string(20) "Third Content String"
+ ["key4"]=>
+ string(22) "Another Content String"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_cdb_001.phpt b/ext/dba/tests/dba_cdb_001.phpt
new file mode 100644
index 0000000..4372754
--- /dev/null
+++ b/ext/dba/tests/dba_cdb_001.phpt
@@ -0,0 +1,89 @@
+--TEST--
+DBA CDB handler test
+--SKIPIF--
+<?php
+$handler = 'cdb';
+require_once(dirname(__FILE__) .'/skipif.inc');
+die('info CDB does not support replace or delete');
+?>
+--FILE--
+<?php
+
+$handler = 'cdb';
+require_once(dirname(__FILE__) .'/test.inc');
+
+echo "Test 0\n";
+
+if (($db_file = dba_open($db_filename, 'n', $handler))!==FALSE) {
+ var_dump(dba_insert("key1", "Content String 1", $db_file));
+ var_dump(dba_replace("key1", "New Content String", $db_file));
+ var_dump(dba_fetch("key1", $db_file));
+ var_dump(dba_firstkey($db_file));
+ var_dump(dba_delete("key1", $db_file));
+ var_dump(dba_optimize($db_file));
+ var_dump(dba_sync($db_file));
+ dba_close($db_file);
+}
+else {
+ echo "Failed to open DB\n";
+}
+
+unlink($db_filename);
+
+echo "Test 1\n";
+
+if (($db_file = dba_open($db_filename, 'c', $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_close($db_file);
+}
+else {
+ echo "Failed to open DB\n";
+}
+
+echo "Test 2\n";
+
+if (($db_file = dba_open($db_filename, 'r', $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_close($db_file);
+}
+else {
+ echo "Failed to open DB\n";
+}
+
+echo "Test 3\n";
+
+if (($db_file = dba_open($db_filename, 'w', $handler))!==FALSE) {
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+}
+else {
+ echo "Failed to open DB\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+Test 0
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+Test 1
+
+Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
+Failed to open DB
+Test 2
+
+Warning: dba_insert(): You cannot perform a modification to a database without proper access in %sdba_cdb_001.php on line %d
+Test 3
+
+Warning: dba_open(%stest0.dbm,w): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
+Failed to open DB
+===DONE===
diff --git a/ext/dba/tests/dba_cdb_make.phpt b/ext/dba/tests/dba_cdb_make.phpt
new file mode 100644
index 0000000..6a5f2dd
--- /dev/null
+++ b/ext/dba/tests/dba_cdb_make.phpt
@@ -0,0 +1,40 @@
+--TEST--
+DBA CDB_MAKE handler test
+--SKIPIF--
+<?php
+ $handler = 'cdb_make';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+ die('info CDB_MAKE does not support reading');
+?>
+--FILE--
+<?php
+ $handler = 'cdb_make';
+ require_once(dirname(__FILE__) .'/test.inc');
+ echo "database handler: $handler\n";
+ // print md5 checksum of test.cdb which is generated by cdb_make program
+ var_dump(md5_file(dirname(__FILE__).'/test.cdb'));
+ if (($db_make=dba_open($db_file, "n", $handler))!==FALSE) {
+ dba_insert("1", "1", $db_make);
+ dba_insert("2", "2", $db_make);
+ dba_insert("1", "3", $db_make);
+ dba_insert("2", "1", $db_make);
+ dba_insert("3", "3", $db_make);
+ dba_insert("1", "2", $db_make);
+ dba_insert("4", "4", $db_make);
+// dba_replace cdb_make doesn't know replace
+ dba_close($db_make);
+ // write md5 checksum of generated database file
+ var_dump(md5_file($db_file));
+ // no need to test created database: this is done by dba_cdb_read.phpt
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECT--
+database handler: cdb_make
+string(32) "12fc5ba2b9dcfef2480e5324eeb5f3e5"
+string(32) "12fc5ba2b9dcfef2480e5324eeb5f3e5"
diff --git a/ext/dba/tests/dba_cdb_read.phpt b/ext/dba/tests/dba_cdb_read.phpt
new file mode 100644
index 0000000..71575f5
--- /dev/null
+++ b/ext/dba/tests/dba_cdb_read.phpt
@@ -0,0 +1,65 @@
+--TEST--
+DBA CDB handler test (read only)
+--SKIPIF--
+<?php
+ $handler = 'cdb_make';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ echo "database handler: cdb\n";
+ $handler = 'cdb';
+ $db_file = dirname(__FILE__).'/test.cdb';
+ if (($db_file=dba_open($db_file, "r", $handler))!==FALSE) {
+ // read key sequence
+ $a = dba_firstkey($db_file);
+ $count= 0;
+ $keys = $a;
+ while($a) {
+ $a = dba_nextkey($db_file);
+ $keys .= $a;
+ $count++;
+ }
+ // display number of entries and key existance
+ echo $count;
+ for ($i=1; $i<8; $i++) {
+ echo dba_exists($i, $db_file) ? "Y" : "N";
+ }
+ echo "\n=";
+ echo dba_fetch(1, $db_file);
+ echo dba_fetch(2, $db_file);
+ echo dba_fetch(3, $db_file);
+ echo dba_fetch(4, $db_file);
+ echo "\n#";
+ echo dba_fetch(1, $db_file);
+ echo dba_fetch(1, $db_file);
+ echo dba_fetch(2, $db_file);
+ echo dba_fetch(2, $db_file);
+ echo "\n?".$keys;
+ // with skip = 0 dba_fetch must fetch the first result
+ echo "\n#";
+ $skip = array();
+ for ($i=0; $i < strlen($keys); $i++) {
+ $key = substr($keys, $i, 1);
+ $skip[$key] = 0;
+ echo dba_fetch($key, $db_file);
+ }
+ echo "\n=";
+ for ($i=0; $i < strlen($keys); $i++) {
+ $key = substr($keys, $i, 1);
+ echo dba_fetch($key, $skip[$key], $db_file);
+ $skip[$key]++;
+ }
+ dba_close($db_file);
+ } else {
+ echo "Error creating database\n";
+ }
+?>
+--EXPECT--
+database handler: cdb
+7YYYYNNN
+=1234
+#1122
+?1212314
+#1212314
+=1231324
diff --git a/ext/dba/tests/dba_db1.phpt b/ext/dba/tests/dba_db1.phpt
new file mode 100644
index 0000000..a246003
--- /dev/null
+++ b/ext/dba/tests/dba_db1.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA DB1 handler test
+--SKIPIF--
+<?php
+ $handler = 'db1';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'db1';
+ require_once dirname(__FILE__) .'/test.inc';
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: db1
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt
new file mode 100644
index 0000000..89d8a92
--- /dev/null
+++ b/ext/dba/tests/dba_db2.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA DB2 handler test
+--SKIPIF--
+<?php
+ $handler = 'db2';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'db2';
+ require_once dirname(__FILE__) .'/test.inc';
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: db2
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt
new file mode 100644
index 0000000..257c882
--- /dev/null
+++ b/ext/dba/tests/dba_db3.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA DB3 handler test
+--SKIPIF--
+<?php
+ $handler = 'db3';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'db3';
+ require_once dirname(__FILE__) .'/test.inc';
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: db3
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_db4_000.phpt b/ext/dba/tests/dba_db4_000.phpt
new file mode 100644
index 0000000..bbbc52c
--- /dev/null
+++ b/ext/dba/tests/dba_db4_000.phpt
@@ -0,0 +1,50 @@
+--TEST--
+DBA DB4 handler test
+--SKIPIF--
+<?php
+$handler = 'db4';
+require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+$handler = 'db4';
+require_once(dirname(__FILE__) .'/test.inc');
+require_once(dirname(__FILE__) .'/dba_handler.inc');
+?>
+===DONE===
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECT--
+database handler: db4
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_db4_001.phpt b/ext/dba/tests/dba_db4_001.phpt
new file mode 100644
index 0000000..ecc8389
--- /dev/null
+++ b/ext/dba/tests/dba_db4_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DBA DB4 New File Creation open("c") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_002.phpt b/ext/dba/tests/dba_db4_002.phpt
new file mode 100644
index 0000000..18ac0ec
--- /dev/null
+++ b/ext/dba/tests/dba_db4_002.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DBA DB4 New File Creation open("n") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file = dba_open($db_filename, "n", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_003.phpt b/ext/dba/tests/dba_db4_003.phpt
new file mode 100644
index 0000000..7e8568c
--- /dev/null
+++ b/ext/dba/tests/dba_db4_003.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA DB4 File Creation open("c") with existing file
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+var_dump(file_put_contents($db_filename, "Dummy contents"));
+
+if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+// Check the file still exists
+$s = file_get_contents($db_filename);
+echo "$s\n";
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+int(14)
+
+Notice: dba_open(): %stest0.dbm: unexpected file type or format in %sdba_db4_003.php on line %d
+
+Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_003.php on line %d
+Error creating %stest0.dbm
+Dummy contents
diff --git a/ext/dba/tests/dba_db4_004.phpt b/ext/dba/tests/dba_db4_004.phpt
new file mode 100644
index 0000000..ca876f8
--- /dev/null
+++ b/ext/dba/tests/dba_db4_004.phpt
@@ -0,0 +1,40 @@
+--TEST--
+DBA DB4 Truncate Existing File open("n")
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+var_dump(file_put_contents($db_filename, "Dummy contents"));
+
+if (($db_file = dba_open($db_filename, "n", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+int(14)
+database file created
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_005.phpt b/ext/dba/tests/dba_db4_005.phpt
new file mode 100644
index 0000000..54bb475
--- /dev/null
+++ b/ext/dba/tests/dba_db4_005.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DBA DB4 New File Creation popen("c") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_006.phpt b/ext/dba/tests/dba_db4_006.phpt
new file mode 100644
index 0000000..7d95385
--- /dev/null
+++ b/ext/dba/tests/dba_db4_006.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DBA DB4 New File Creation popen("n") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file = dba_popen($db_filename, "n", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_007.phpt b/ext/dba/tests/dba_db4_007.phpt
new file mode 100644
index 0000000..bd95e0b
--- /dev/null
+++ b/ext/dba/tests/dba_db4_007.phpt
@@ -0,0 +1,41 @@
+--TEST--
+DBA DB4 File Creation popen("c") with existing invalid file
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+var_dump(file_put_contents($db_filename, "Dummy contents"));
+
+if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+int(14)
+
+Notice: dba_popen(): %stest0.dbm: unexpected file type or format in %sdba_db4_007.php on line %d
+
+Warning: dba_popen(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_007.php on line %d
+Error creating %stest0.dbm
diff --git a/ext/dba/tests/dba_db4_008.phpt b/ext/dba/tests/dba_db4_008.phpt
new file mode 100644
index 0000000..80f62ea
--- /dev/null
+++ b/ext/dba/tests/dba_db4_008.phpt
@@ -0,0 +1,40 @@
+--TEST--
+DBA DB4 Truncate Existing File popen("n")
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+var_dump(file_put_contents($db_filename, "Dummy contents"));
+
+if (($db_file = dba_popen($db_filename, "n", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+int(14)
+database file created
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_009.phpt b/ext/dba/tests/dba_db4_009.phpt
new file mode 100644
index 0000000..5a870c9
--- /dev/null
+++ b/ext/dba/tests/dba_db4_009.phpt
@@ -0,0 +1,53 @@
+--TEST--
+DBA DB4 Multiple File Creation Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+$db_file1 = $db_filename1 = dirname(__FILE__).'/test1.dbm';
+$db_file2 = $db_filename2 = dirname(__FILE__).'/test2.dbm';
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+} else {
+ echo "$db_file does not exist\n";
+}
+if (($db_file1=dba_open($db_file1, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+} else {
+ echo "$db_file does not exist\n";
+}
+if (($db_file2=dba_open($db_file2, "n", $handler))!==FALSE) {
+ echo "database file created\n";
+} else {
+ echo "$db_file does not exist\n";
+}
+var_dump(dba_list());
+dba_close($db_file);
+
+@unlink($db_filename1);
+@unlink($db_filename2);
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+database file created
+database file created
+array(3) {
+ [%d]=>
+ string(%d) "%stest0.dbm"
+ [%d]=>
+ string(%d) "%stest1.dbm"
+ [%d]=>
+ string(%d) "%stest2.dbm"
+}
diff --git a/ext/dba/tests/dba_db4_010.phpt b/ext/dba/tests/dba_db4_010.phpt
new file mode 100644
index 0000000..fb31f05
--- /dev/null
+++ b/ext/dba/tests/dba_db4_010.phpt
@@ -0,0 +1,38 @@
+--TEST--
+DBA DB4 magic_quotes_runtime Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ ini_set('magic_quotes_runtime', 0);
+ dba_insert("key1", '"', $db_file);
+ var_dump(dba_fetch("key1", $db_file));
+ ini_set('magic_quotes_runtime', 1);
+ var_dump(dba_fetch("key1", $db_file));
+ dba_replace("key1", '\"', $db_file);
+ var_dump(dba_fetch("key1", $db_file));
+ ini_set('magic_quotes_runtime', 0);
+ var_dump(dba_fetch("key1", $db_file));
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+string(1) """
+string(2) "\""
+string(2) "\""
+string(1) """
diff --git a/ext/dba/tests/dba_db4_011.phpt b/ext/dba/tests/dba_db4_011.phpt
new file mode 100644
index 0000000..ce9be27
--- /dev/null
+++ b/ext/dba/tests/dba_db4_011.phpt
@@ -0,0 +1,36 @@
+--TEST--
+DBA DB4 with repeated key
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_filename, "c", $handler))!==FALSE) {
+ var_dump(dba_insert("key1", "Content String 1", $db_file));
+ var_dump(dba_insert("key2", "Content String 2", $db_file));
+ var_dump(dba_insert("key2", "Same key", $db_file));
+ echo dba_fetch("key1", $db_file), "\n";
+ echo dba_fetch("key2", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+bool(true)
+bool(true)
+bool(false)
+Content String 1
+Content String 2
diff --git a/ext/dba/tests/dba_db4_012.phpt b/ext/dba/tests/dba_db4_012.phpt
new file mode 100644
index 0000000..2caa43c
--- /dev/null
+++ b/ext/dba/tests/dba_db4_012.phpt
@@ -0,0 +1,31 @@
+--TEST--
+DBA DB4 New File Creation open("rl")
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file = dba_open($db_filename, "rl", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+
+Warning: dba_open(%stest0.dbm,rl): Driver initialization failed for handler: db4: No such file or directory in %sdba_db4_012.php on line %d
+Error creating %stest0.dbm
diff --git a/ext/dba/tests/dba_db4_013.phpt b/ext/dba/tests/dba_db4_013.phpt
new file mode 100644
index 0000000..ba2d171
--- /dev/null
+++ b/ext/dba/tests/dba_db4_013.phpt
@@ -0,0 +1,40 @@
+--TEST--
+DBA DB4 File open("rl") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_close($db_file);
+}
+
+if (($db_file = dba_popen($db_filename, "rl", $handler)) !== FALSE) {
+ echo "database file opened\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+database file opened
+
+Warning: dba_insert(): You cannot perform a modification to a database without proper access in %sdba_db4_013.php on line %d
diff --git a/ext/dba/tests/dba_db4_014.phpt b/ext/dba/tests/dba_db4_014.phpt
new file mode 100644
index 0000000..6fb22f8
--- /dev/null
+++ b/ext/dba/tests/dba_db4_014.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DBA DB4 File open("wl") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file = dba_open($db_filename, "wl", $handler)) !== FALSE) {
+ echo "database file opened\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+
+Warning: dba_open(%stest0.dbm,wl): Driver initialization failed for handler: db4: No such file or directory in %sdba_db4_014.php on line %d
+Error creating %stest0.dbm
diff --git a/ext/dba/tests/dba_db4_015.phpt b/ext/dba/tests/dba_db4_015.phpt
new file mode 100644
index 0000000..a153567
--- /dev/null
+++ b/ext/dba/tests/dba_db4_015.phpt
@@ -0,0 +1,39 @@
+--TEST--
+DBA DB4 File open("wl") & Insert Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
+ echo "database file created\n";
+ dba_close($db_file);
+}
+
+if (($db_file = dba_popen($db_filename, "wl", $handler)) !== FALSE) {
+ echo "database file opened\n";
+ dba_insert("key1", "This is a test insert", $db_file);
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+database file opened
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_016.phpt b/ext/dba/tests/dba_db4_016.phpt
new file mode 100644
index 0000000..b79cc71
--- /dev/null
+++ b/ext/dba/tests/dba_db4_016.phpt
@@ -0,0 +1,59 @@
+--TEST--
+DBA DB4 File Creation popen("c") with existing valid file
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ var_dump(dba_insert("key1", "This is a test insert", $db_file));
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+// Now test reopening it
+if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ var_dump(dba_insert("key1", "second open test", $db_file));
+ var_dump(dba_insert("key2", "second open test row 2", $db_file));
+ echo dba_fetch("key1", $db_file), "\n";
+ echo dba_fetch("key2", $db_file), "\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+bool(true)
+This is a test insert
+database file created
+bool(false)
+bool(true)
+This is a test insert
+second open test row 2
diff --git a/ext/dba/tests/dba_db4_017.phpt b/ext/dba/tests/dba_db4_017.phpt
new file mode 100644
index 0000000..12bf3df
--- /dev/null
+++ b/ext/dba/tests/dba_db4_017.phpt
@@ -0,0 +1,37 @@
+--TEST--
+DBA DB4 file creation dba_open("cd")
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file = dba_open($db_filename, "cd", $handler)) !== FALSE) {
+ if (file_exists($db_filename)) {
+ echo "database file created\n";
+ var_dump(dba_insert("key1", "This is a test insert", $db_file));
+ echo dba_fetch("key1", $db_file), "\n";
+ dba_close($db_file);
+ } else {
+ echo "File did not get created\n";
+ }
+} else {
+ echo "Error creating $db_filename\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+database file created
+bool(true)
+This is a test insert
diff --git a/ext/dba/tests/dba_db4_018.phpt b/ext/dba/tests/dba_db4_018.phpt
new file mode 100644
index 0000000..ecd1980
--- /dev/null
+++ b/ext/dba/tests/dba_db4_018.phpt
@@ -0,0 +1,76 @@
+--TEST--
+DBA DB4 with persistent connections
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+echo "Test 1\n";
+$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
+dba_insert("key1", "This is a test insert 1", $db_file1);
+echo dba_fetch("key1", $db_file1), "\n";
+
+
+echo "Test 2\n";
+$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
+if ($db_file1 === $db_file2) {
+ echo "resources are the same\n";
+} else {
+ echo "resources are different\n";
+}
+
+
+echo "Test 3 - fetch both rows from second resource\n";
+dba_insert("key2", "This is a test insert 2", $db_file2);
+echo dba_fetch("key1", $db_file2), "\n";
+echo dba_fetch("key2", $db_file2), "\n";
+
+
+echo "Test 4 - fetch both rows from first resource\n";
+echo dba_fetch("key1", $db_file1), "\n";
+echo dba_fetch("key2", $db_file1), "\n";
+
+echo "Test 5 - close 2nd resource\n";
+dba_close($db_file2);
+var_dump($db_file1);
+var_dump($db_file2);
+
+echo "Test 6 - query after closing 2nd resource\n";
+echo dba_fetch("key1", $db_file1), "\n";
+echo dba_fetch("key2", $db_file1), "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--XFAIL--
+Test 6 crashes with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278
+--EXPECTF--
+database handler: db4
+Test 1
+This is a test insert 1
+Test 2
+resources are different
+Test 3 - fetch both rows from second resource
+This is a test insert 1
+This is a test insert 2
+Test 4 - fetch both rows from first resource
+This is a test insert 1
+This is a test insert 2
+Test 5 - close 2nd resource
+resource(%d) of type (dba persistent)
+resource(%d) of type (Unknown)
+Test 6 - query after closing 2nd resource
+This is a test insert 1
+This is a test insert 2
+===DONE===
diff --git a/ext/dba/tests/dba_db4_handlers.phpt b/ext/dba/tests/dba_db4_handlers.phpt
new file mode 100644
index 0000000..d238f43
--- /dev/null
+++ b/ext/dba/tests/dba_db4_handlers.phpt
@@ -0,0 +1,50 @@
+--TEST--
+DBA DB4 Handler Test
+--SKIPIF--
+<?php
+$handler="db4";
+require(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler="db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+function check($h)
+{
+ if (!$h) {
+ return;
+ }
+
+ foreach ($h as $key) {
+ if ($key === "db4") {
+ echo "Success: db4 enabled\n";
+ }
+ }
+}
+
+echo "Test 1\n";
+
+check(dba_handlers());
+
+echo "Test 2 - full info\n";
+$h = dba_handlers(1);
+foreach ($h as $key => $val) {
+ if ($key === "db4") {
+ echo "$val\n";
+ }
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTREGEX--
+database handler: db4
+Test 1
+Success: db4 enabled
+Test 2 - full info
+.*Berkeley DB (4|5).*
diff --git a/ext/dba/tests/dba_db4_optimize.phpt b/ext/dba/tests/dba_db4_optimize.phpt
new file mode 100644
index 0000000..de27dd8
--- /dev/null
+++ b/ext/dba/tests/dba_db4_optimize.phpt
@@ -0,0 +1,38 @@
+--TEST--
+DBA DB4 Optimize Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ for ($i=1; $i<3; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ echo "\n";
+ var_dump(dba_optimize($db_file));
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+YY
+bool(true)
+===DONE===
diff --git a/ext/dba/tests/dba_db4_sync.phpt b/ext/dba/tests/dba_db4_sync.phpt
new file mode 100644
index 0000000..8c4e248
--- /dev/null
+++ b/ext/dba/tests/dba_db4_sync.phpt
@@ -0,0 +1,38 @@
+--TEST--
+DBA DB4 Sync Test
+--SKIPIF--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler = "db4";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ for ($i=1; $i<3; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ echo "\n";
+ var_dump(dba_sync($db_file));
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: db4
+YY
+bool(true)
+===DONE===
diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt
new file mode 100644
index 0000000..dd1fe1e
--- /dev/null
+++ b/ext/dba/tests/dba_dbm.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA DBM handler test
+--SKIPIF--
+<?php
+ $handler = 'dbm';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'dbm';
+ require_once dirname(__FILE__) .'/test.inc';
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: dbm
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt
new file mode 100644
index 0000000..8e1ca6a
--- /dev/null
+++ b/ext/dba/tests/dba_flatfile.phpt
@@ -0,0 +1,50 @@
+--TEST--
+DBA FlatFile handler test
+--SKIPIF--
+<?php
+ $handler = 'flatfile';
+ require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--FILE--
+<?php
+ $handler = 'flatfile';
+ require_once(dirname(__FILE__) .'/test.inc');
+ require_once(dirname(__FILE__) .'/dba_handler.inc');
+?>
+===DONE===
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECT--
+database handler: flatfile
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_gdbm.phpt b/ext/dba/tests/dba_gdbm.phpt
new file mode 100644
index 0000000..33d7d20
--- /dev/null
+++ b/ext/dba/tests/dba_gdbm.phpt
@@ -0,0 +1,34 @@
+--TEST--
+DBA GDBM handler test
+--SKIPIF--
+<?php
+ $handler = 'gdbm';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'gdbm';
+ require_once dirname(__FILE__) .'/test.inc';
+ $lock_flag = ''; // lock in library
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+
+ // Read during write is system dependant. Important is that there is no deadlock
+?>
+===DONE===
+--EXPECTF--
+database handler: gdbm
+3NYNYY
+Content String 2
+Content 2 replaced
+Read during write:%sallowed
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc
new file mode 100644
index 0000000..1c3f512
--- /dev/null
+++ b/ext/dba/tests/dba_handler.inc
@@ -0,0 +1,90 @@
+<?php
+
+echo "database handler: $handler\n";
+
+do {
+ if (($db_file = dba_open($db_filename, 'n'.$lock_flag, $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ 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);
+ 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) {
+ $a = dba_nextkey($db_file);
+ $i++;
+ }
+ echo $i;
+ for ($i=1; $i<6; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ echo "\n";
+ 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";
+ }
+ if ($handler != 'cdb') {
+ $db_writer = dba_open($db_filename, 'c'.$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);
+ $res = array();
+ while($key) {
+ $res[$key] = dba_fetch($key, $db_file);
+ $key = dba_nextkey($db_file);
+ }
+ ksort($res);
+ var_dump($res);
+ dba_close($db_file);
+ } else {
+ echo "Error reading database\n";
+ }
+ if (!empty($dba_reader)) {
+ dba_close($dba_reader);
+ }
+ if (($db_file = dba_popen($db_filename, 'r'.($lock_flag==''?'':'-'), $handler))!==FALSE) {
+ if ($handler == 'dbm') {
+ dba_close($db_file);
+ }
+ }
+
+ if ($lock_flag == '') {
+ break;
+ } else {
+ echo "--NO-LOCK--\n";
+ $lock_flag = '';
+ }
+} while(1);
+
+?> \ No newline at end of file
diff --git a/ext/dba/tests/dba_handlers.phpt b/ext/dba/tests/dba_handlers.phpt
new file mode 100644
index 0000000..9f66a79
--- /dev/null
+++ b/ext/dba/tests/dba_handlers.phpt
@@ -0,0 +1,69 @@
+--TEST--
+DBA Handler Test
+--SKIPIF--
+<?php
+$handler="flatfile";
+require(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+$handler="flatfile";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+function check($h)
+{
+ if (!$h) {
+ return;
+ }
+
+ foreach ($h as $key) {
+ if ($key === "flatfile") {
+ echo "Success: flatfile enabled\n";
+ }
+ }
+}
+
+echo "Test 1\n";
+
+check(dba_handlers());
+
+echo "Test 2\n";
+
+check(dba_handlers(null));
+
+echo "Test 3\n";
+
+check(dba_handlers(1, 2));
+
+echo "Test 4\n";
+
+check(dba_handlers(0));
+
+echo "Test 5 - full info\n";
+$h = dba_handlers(1);
+foreach ($h as $key => $val) {
+ if ($key === "flatfile") {
+ echo "Success: flatfile enabled\n";
+ }
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: flatfile
+Test 1
+Success: flatfile enabled
+Test 2
+Success: flatfile enabled
+Test 3
+
+Warning: dba_handlers() expects at most 1 parameter, 2 given in %sdba_handlers.php on line %d
+Test 4
+Success: flatfile enabled
+Test 5 - full info
+Success: flatfile enabled
diff --git a/ext/dba/tests/dba_inifile.phpt b/ext/dba/tests/dba_inifile.phpt
new file mode 100644
index 0000000..81ab738
--- /dev/null
+++ b/ext/dba/tests/dba_inifile.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA INIFILE handler test
+--SKIPIF--
+<?php
+ $handler = 'inifile';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'inifile';
+ require_once dirname(__FILE__) .'/test.inc';
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: inifile
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_ndbm.phpt b/ext/dba/tests/dba_ndbm.phpt
new file mode 100644
index 0000000..b0f5542
--- /dev/null
+++ b/ext/dba/tests/dba_ndbm.phpt
@@ -0,0 +1,46 @@
+--TEST--
+DBA NDBM handler test
+--SKIPIF--
+<?php
+ $handler = 'ndbm';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'ndbm';
+ require_once dirname(__FILE__) .'/test.inc';
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: ndbm
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_optimize.phpt b/ext/dba/tests/dba_optimize.phpt
new file mode 100644
index 0000000..794d7e8
--- /dev/null
+++ b/ext/dba/tests/dba_optimize.phpt
@@ -0,0 +1,51 @@
+--TEST--
+DBA Optimize Test
+--SKIPIF--
+<?php
+ require_once dirname(__FILE__) .'/skipif.inc';
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ $a = dba_firstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dba_nextkey($db_file);
+ $i++;
+ }
+ echo $i;
+ for ($i=1; $i<3; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ echo "\n";
+ var_dump(dba_optimize());
+ var_dump(dba_optimize(""));
+ var_dump(dba_optimize($db_file));
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: flatfile
+2YY
+
+Warning: dba_optimize() expects exactly 1 parameter, 0 given in %sdba_optimize.php on line %d
+NULL
+
+Warning: dba_optimize() expects parameter 1 to be resource, string given in %sdba_optimize.php on line %d
+NULL
+bool(true)
+===DONE===
diff --git a/ext/dba/tests/dba_qdbm.phpt b/ext/dba/tests/dba_qdbm.phpt
new file mode 100644
index 0000000..ef216d9
--- /dev/null
+++ b/ext/dba/tests/dba_qdbm.phpt
@@ -0,0 +1,34 @@
+--TEST--
+DBA QDBM handler test
+--SKIPIF--
+<?php
+ $handler = 'qdbm';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'qdbm';
+ require_once dirname(__FILE__) .'/test.inc';
+ $lock_flag = ''; // lock in library
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECTF--
+database handler: qdbm
+3NYNYY
+Content String 2
+Content 2 replaced
+Read during write:%sallowed
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+
+Warning: dba_popen(%stest0.dbm,r-): Locking cannot be disabled for handler qdbm in %sdba_handler.inc on line %d
+===DONE===
diff --git a/ext/dba/tests/dba_split.phpt b/ext/dba/tests/dba_split.phpt
new file mode 100644
index 0000000..0989f09
--- /dev/null
+++ b/ext/dba/tests/dba_split.phpt
@@ -0,0 +1,83 @@
+--TEST--
+DBA Split Test
+--SKIPIF--
+<?php
+ require_once dirname(__FILE__) .'/skipif.inc';
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+var_dump(dba_key_split("key1", "name"));
+var_dump(dba_key_split(1));
+var_dump(dba_key_split(null));
+var_dump(dba_key_split(""));
+var_dump(dba_key_split("name1"));
+var_dump(dba_key_split("[key1"));
+var_dump(dba_key_split("[key1]"));
+var_dump(dba_key_split("key1]"));
+var_dump(dba_key_split("[key1]name1"));
+var_dump(dba_key_split("[key1]name1[key2]name2"));
+var_dump(dba_key_split("[key1]name1"));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Warning: Wrong parameter count for dba_key_split() in %sdba_split.php on line %d
+NULL
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(1) "1"
+}
+bool(false)
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "name1"
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "[key1"
+}
+array(2) {
+ [0]=>
+ string(4) "key1"
+ [1]=>
+ string(0) ""
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "key1]"
+}
+array(2) {
+ [0]=>
+ string(4) "key1"
+ [1]=>
+ string(5) "name1"
+}
+array(2) {
+ [0]=>
+ string(4) "key1"
+ [1]=>
+ string(16) "name1[key2]name2"
+}
+array(2) {
+ [0]=>
+ string(4) "key1"
+ [1]=>
+ string(5) "name1"
+}
+===DONE===
diff --git a/ext/dba/tests/dba_sync.phpt b/ext/dba/tests/dba_sync.phpt
new file mode 100644
index 0000000..e0906ee
--- /dev/null
+++ b/ext/dba/tests/dba_sync.phpt
@@ -0,0 +1,51 @@
+--TEST--
+DBA Sync Test
+--SKIPIF--
+<?php
+ require_once dirname(__FILE__) .'/skipif.inc';
+ die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) {
+ dba_insert("key1", "Content String 1", $db_file);
+ dba_insert("key2", "Content String 2", $db_file);
+ $a = dba_firstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dba_nextkey($db_file);
+ $i++;
+ }
+ echo $i;
+ for ($i=1; $i<3; $i++) {
+ echo dba_exists("key$i", $db_file) ? "Y" : "N";
+ }
+ echo "\n";
+ var_dump(dba_sync());
+ var_dump(dba_sync(""));
+ var_dump(dba_sync($db_file));
+ dba_close($db_file);
+} else {
+ echo "Error creating database\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--CLEAN--
+<?php
+ require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: flatfile
+2YY
+
+Warning: dba_sync() expects exactly 1 parameter, 0 given in %sdba_sync.php on line %d
+NULL
+
+Warning: dba_sync() expects parameter 1 to be resource, string given in %sdba_sync.php on line %d
+NULL
+bool(true)
+===DONE===
diff --git a/ext/dba/tests/dba_tcadb.phpt b/ext/dba/tests/dba_tcadb.phpt
new file mode 100644
index 0000000..52dd4de
--- /dev/null
+++ b/ext/dba/tests/dba_tcadb.phpt
@@ -0,0 +1,50 @@
+--TEST--
+DBA TCADB handler test
+--SKIPIF--
+<?php
+ $handler = 'tcadb';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+ $handler = 'tcadb';
+ require_once dirname(__FILE__) .'/skipif.inc';
+ $lock_flag = 'l';
+ $db_filename = $db_file = dirname(__FILE__) .'/test0.tch';
+ @unlink($db_filename);
+ @unlink($db_filename.'.lck');
+ require_once dirname(__FILE__) .'/dba_handler.inc';
+?>
+===DONE===
+--EXPECT--
+database handler: tcadb
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+--NO-LOCK--
+3NYNYY
+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"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
+===DONE===
diff --git a/ext/dba/tests/skipif.inc b/ext/dba/tests/skipif.inc
new file mode 100644
index 0000000..e75000f
--- /dev/null
+++ b/ext/dba/tests/skipif.inc
@@ -0,0 +1,23 @@
+<?php
+ if (!extension_loaded('dba')) die('skip dba extension not available');
+ if (!function_exists('dba_handlers')) die ('skip dba_handlers() not available');
+ if (!sizeof(dba_handlers())) die('skip no handlers installed');
+ if (!isset($handler)) {
+ $handlers = dba_handlers();
+ if (in_array('flatfile', $handlers)) {
+ $handler = 'flatfile';
+ } else {
+ $handlers = array_diff($handlers, array('cdb', 'cdb_make')); /* these can only read OR write */
+ if (count($handlers)==0) {
+ die('skip no handler available that can be used for the test');
+ }
+ $handler = array_shift($handlers);
+ }
+ } else {
+ if (!in_array($handler, dba_handlers())) {
+ $HND = strtoupper($handler);
+ die("skip $HND handler not available");
+ }
+ }
+ $HND = strtoupper($handler);
+?>
diff --git a/ext/dba/tests/test.cdb b/ext/dba/tests/test.cdb
new file mode 100644
index 0000000..21529c6
--- /dev/null
+++ b/ext/dba/tests/test.cdb
Binary files differ
diff --git a/ext/dba/tests/test.inc b/ext/dba/tests/test.inc
new file mode 100644
index 0000000..7c4e207
--- /dev/null
+++ b/ext/dba/tests/test.inc
@@ -0,0 +1,7 @@
+<?php
+ require_once dirname(__FILE__) .'/skipif.inc';
+ $lock_flag = 'l';
+ $db_filename = $db_file = dirname(__FILE__) .'/test0.dbm';
+ @unlink($db_filename);
+ @unlink($db_filename.'.lck');
+?>