--- /dev/null
+--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)
--- /dev/null
+--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
--- /dev/null
+--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
--- /dev/null
+--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===
echo "Error creating $db_filename\n";
}
+// Check the file still exists
+$s = file_get_contents($db_filename);
+echo "$s\n";
+
?>
--CLEAN--
<?php
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