--- /dev/null
+--TEST--
+DBA File Creation Test
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ echo "database file created with $handler.\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ dba_close($db_file);
+?>
+--EXPECTF--
+database file created with %s.
\ No newline at end of file
--- /dev/null
+--TEST--
+DBA Insert/Fetch Test
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ 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";
+ }
+?>
+--EXPECT--
+This is a test insert
--- /dev/null
+--TEST--
+DBA Insert/Replace/Fetch Test
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ 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";
+ }
+?>
+--EXPECT--
+This is the replacement text
--- /dev/null
+--TEST--
+DBA Multiple Insert/Fetch Test
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ 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";
+ }
+?>
+--EXPECT--
+Another Content String Content String 2
--- /dev/null
+--TEST--
+DBA FirstKey/NextKey Loop Test With 5 Items
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ 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";
+ }
+?>
+--EXPECT--
+5YYYYY
--- /dev/null
+--TEST--
+DBA FirstKey/NextKey with 2 deletes
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ 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";
+ }
+?>
+--EXPECT--
+3NYNYY
\ No newline at end of file
--- /dev/null
+<?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');
+?>
--- /dev/null
+<?php
+ $db_file = dirname(__FILE__).'/test.dbm';
+ $handler = dba_handlers();
+ $handler = $handler[0];
+?>