Improve DBA test suite (#8904)

Generalises tests for all the different drivers.
Run the general test for the various drivers.

This allows support for parallel testing as the tests now do not rely on the same DB file.
This commit is contained in:
George Peter Banyard 2022-07-28 19:36:04 +01:00 committed by GitHub
parent b948f8048b
commit eddab74021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 2887 additions and 1663 deletions

View file

@ -1,2 +0,0 @@
# Many of these tests work on the same database file
dba

View file

@ -4,21 +4,17 @@ Bug #36436 (DBA problem with Berkeley DB4)
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'db4'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('db4');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'bug36436.db';
$handler = 'db4'; $db = set_up_db_ex('db4', $db_name, LockFlag::DbLock, persistent: true);
require_once(__DIR__ .'/test.inc');
$db = dba_popen($db_filename, 'c', 'db4'); var_dump($db, dba_fetch('key1', $db));
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_firstkey($db));
var_dump(dba_nextkey($db)); var_dump(dba_nextkey($db));
@ -28,10 +24,12 @@ dba_close($db);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'bug36436.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECTF-- --EXPECTF--
resource(%d) of type (dba persistent) resource(%d) of type (dba persistent)
string(3) "XYZ" string(16) "Content String 1"
string(1) "X" string(13) "[key10]name10"
string(1) "Y" string(13) "[key30]name30"

View file

@ -1,28 +0,0 @@
--TEST--
Bug #48240 (DBA Segmentation fault dba_nextkey)
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = 'db4';
require_once(__DIR__ .'/skipif.inc');
?>
--FILE--
<?php
$handler = 'db4';
require_once(__DIR__ .'/test.inc');
$db = dba_open($db_filename, 'c', 'db4');
var_dump(dba_nextkey($db));
dba_close($db);
?>
--CLEAN--
<?php
require(__DIR__ .'/clean.inc');
?>
--EXPECT--
bool(false)

View file

@ -1,32 +0,0 @@
--TEST--
Bug #49125 (Error in dba_exists C code)
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = 'db4';
require_once(__DIR__ .'/skipif.inc');
?>
--FILE--
<?php
error_reporting(E_ALL);
$handler = 'db4';
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
bool(true)

View file

@ -1,43 +0,0 @@
--TEST--
Bug #62490 (dba_delete returns true on missing item (inifile))
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "inifile";
include "skipif.inc";
?>
--FILE--
<?php
$handler = "inifile";
include "test.inc";
$dba = dba_open($db_filename, "n", $handler)
or die;
for ($i = 0; $i < 3; ++$i) {
echo "insert $i:";
var_dump(dba_insert("a", $i, $dba));
}
echo "exists:";
var_dump(dba_exists("a", $dba));
echo "delete:";
var_dump(dba_delete("a", $dba));
echo "exists:";
var_dump(dba_exists("a", $dba));
echo "delete:";
var_dump(dba_delete("a", $dba));
?>
--CLEAN--
<?php
include "clean.inc";
?>
--EXPECT--
insert 0:bool(true)
insert 1:bool(true)
insert 2:bool(true)
exists:bool(true)
delete:bool(true)
exists:bool(false)
delete:bool(false)

View file

@ -4,16 +4,15 @@ Bug #65708 (dba functions cast $key param to string in-place, bypassing copy on
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__ .'/skipif.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip_any();
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$name = 'bug65708.db';
error_reporting(E_ALL); $db = get_any_db($name);
require_once(__DIR__ .'/test.inc');
$db = dba_popen($db_filename, 'c');
$key = 1; $key = 1;
$copy = $key; $copy = $key;
@ -31,9 +30,12 @@ dba_close($db);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'bug65708.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECTF--
Using handler: "%s"
integer integer
integer integer
integer integer

View file

@ -1,28 +0,0 @@
--TEST--
Bug #72885 flatfile: dba_fetch() fails to read replaced entry
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "flatfile";
require_once(__DIR__ .'/skipif.inc');
?>
--FILE--
<?php
require_once(__DIR__ .'/test.inc');
$db = dba_open($db_filename, 'c', 'flatfile');
dba_insert('foo', 'bar', $db);
var_dump(dba_replace('foo', 'baz', $db));
var_dump(dba_fetch('foo', $db));
dba_close($db);
?>
--CLEAN--
<?php
require_once(__DIR__ .'/clean.inc');
?>
--EXPECT--
bool(true)
string(3) "baz"

View file

@ -4,15 +4,16 @@ Bug #78808 ([LMDB] MDB_MAP_FULL: Environment mapsize limit reached)
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'lmdb'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('lmdb');
?> ?>
--FILE-- --FILE--
<?php <?php
$handler = 'lmdb'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/test.inc'; $db_name = 'bug78808.db';
$value = str_repeat('*', 0x100000); $value = str_repeat('*', 0x100000);
$lmdb_h = dba_open($db_filename, 'c', 'lmdb', 0644, 5*1048576); $lmdb_h = dba_open($db_name, 'c', 'lmdb', 0644, 5*1048576);
for ($i = 0; $i < 3; $i++) { for ($i = 0; $i < 3; $i++) {
dba_insert('key' . $i, $value, $lmdb_h); dba_insert('key' . $i, $value, $lmdb_h);
} }
@ -23,5 +24,7 @@ echo "done\n";
done done
--CLEAN-- --CLEAN--
<?php <?php
require_once dirname(__FILE__) .'/clean.inc'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'bug78808.db';
cleanup_standard_db($db_name);
?> ?>

View file

@ -1,27 +0,0 @@
--TEST--
DBA File Creation Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
database file created

View file

@ -1,28 +0,0 @@
--TEST--
DBA Insert/Fetch Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
This is a test insert

View file

@ -1,30 +0,0 @@
--TEST--
DBA Insert/Replace/Fetch Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
This is the replacement text

View file

@ -1,34 +0,0 @@
--TEST--
DBA Multiple Insert/Fetch Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
Another Content String Content String 2

View file

@ -1,41 +0,0 @@
--TEST--
DBA FirstKey/NextKey Loop Test With 5 Items
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
5YYYYY

View file

@ -1,43 +0,0 @@
--TEST--
DBA FirstKey/NextKey with 2 deletes
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
3NYNYY

View file

@ -8,6 +8,8 @@ dba
if (!function_exists('dba_list')) die('skip dba_list() not available'); if (!function_exists('dba_list')) die('skip dba_list() not available');
die("info $HND handler used"); die("info $HND handler used");
?> ?>
--CONFLICTS--
dba
--FILE-- --FILE--
<?php <?php
require_once(__DIR__ .'/test.inc'); require_once(__DIR__ .'/test.inc');

View file

@ -7,6 +7,8 @@ dba
require_once(__DIR__ .'/skipif.inc'); require_once(__DIR__ .'/skipif.inc');
print("info $HND handler used"); print("info $HND handler used");
?> ?>
--CONFLICTS--
dba
--FILE-- --FILE--
<?php <?php
require_once(__DIR__ .'/test.inc'); require_once(__DIR__ .'/test.inc');

View file

@ -1,46 +0,0 @@
--TEST--
DBA with array keys
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
6YYYYYY

View file

@ -1,33 +0,0 @@
--TEST--
DBA with array key with empty array
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
Fatal error: Uncaught Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name" in %s.php:%d
Stack trace:
#0 %sdba013.php(6): dba_insert(Array, '%s', Resource id #%d)
#1 {main}
thrown in %sdba013.php on line 6

View file

@ -1,33 +0,0 @@
--TEST--
DBA with array key with array containing too many elements
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: %s
Fatal error: Uncaught Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name" in %s.php:%d
Stack trace:
#0 %sdba014.php(6): dba_insert(Array, '%s', Resource id #%d)
#1 {main}
thrown in %sdba014.php on line 6

View file

@ -8,6 +8,8 @@ $handler = "flatfile";
require_once(__DIR__ .'/skipif.inc'); require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used"); die("info $HND handler used");
?> ?>
--CONFLICTS--
dba
--FILE-- --FILE--
<?php <?php

View file

@ -4,34 +4,35 @@ DBA check behaviour of array keys
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__ .'/skipif.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
die("info $HND handler used"); check_skip_any();
?> ?>
--FILE-- --FILE--
<?php <?php
require_once(__DIR__ .'/test.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_file = dba_open($db_file, "n", $handler); $name = 'array_keys_basic.db';
if ($db_file === false) { $db = get_any_db($name);
die('Error creating database');
}
var_dump(dba_insert(['group', 'name'], 'Normal group', $db_file)); var_dump(dba_insert(['group', 'name'], 'Normal group', $db));
var_dump(dba_insert(['group', ''], 'Empty name', $db_file)); var_dump(dba_insert(['group', ''], 'Empty name', $db));
var_dump(dba_insert(['', 'name'], 'Empty group', $db_file)); var_dump(dba_insert(['', 'name'], 'Empty group', $db));
var_dump(dba_insert(['', ''], 'Empty keys', $db_file)); var_dump(dba_insert(['', ''], 'Empty keys', $db));
var_dump(dba_fetch(['group', 'name'], $db_file)); var_dump(dba_fetch(['group', 'name'], $db));
var_dump(dba_fetch(['group', ''], $db_file)); var_dump(dba_fetch(['group', ''], $db));
var_dump(dba_fetch(['', 'name'], $db_file)); var_dump(dba_fetch(['', 'name'], $db));
var_dump(dba_fetch(['', ''], $db_file)); var_dump(dba_fetch(['', ''], $db));
dba_close($db_file); dba_close($db);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'array_keys_basic.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECTF--
Using handler: "%s"
bool(true) bool(true)
bool(true) bool(true)
bool(true) bool(true)

View file

@ -0,0 +1,55 @@
--TEST--
DBA with invalid array key
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip_any();
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$name = 'array_keys_errors.db';
$db = get_any_db($name);
try {
dba_insert([], "Content String 1", $db);
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
try {
dba_insert(["a", "b", "c"], "Content String 2", $db);
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
/* Use an object */
$o = new stdClass();
try {
var_dump(dba_insert([$o, 'obj'], 'Test', $db));
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
try {
var_dump(dba_insert(['group', $o], 'Test', $db));
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
dba_close($db);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'array_keys_errors.db';
cleanup_standard_db($db_name);
?>
--EXPECTF--
Using handler: "%s"
Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name"
Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name"
Error: Object of class stdClass could not be converted to string
Error: Object of class stdClass could not be converted to string

View file

@ -0,0 +1,42 @@
--TEST--
DBA check behaviour of array keys (inifile version)
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('inifile');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$name = __DIR__ . '/array_keys_basic.db';
$db = dba_open($name, 'c', 'inifile');
var_dump(dba_insert(['group', 'name'], 'Normal group', $db));
var_dump(dba_insert(['group', ''], 'Empty name', $db));
var_dump(dba_insert(['', 'name'], 'Empty group', $db));
var_dump(dba_insert(['', ''], 'Empty keys', $db));
var_dump(dba_fetch(['group', 'name'], $db));
var_dump(dba_fetch(['group', ''], $db));
var_dump(dba_fetch(['', 'name'], $db));
var_dump(dba_fetch(['', ''], $db));
dba_close($db);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = __DIR__ . '/array_keys_basic.db';
cleanup_standard_db($db_name);
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
string(12) "Normal group"
string(0) ""
string(11) "Empty group"
bool(false)

View file

@ -1,41 +0,0 @@
--TEST--
DBA check behaviour of key as an array with elements not convertable to string
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
require_once(__DIR__ .'/test.inc');
$db_file = dba_open($db_file, "n", $handler);
if ($db_file === false) {
die('Error creating database');
}
/* Use an object */
$o = new stdClass();
try {
var_dump(dba_insert([$o, 'obj'], 'Test', $db_file));
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
try {
var_dump(dba_insert(['group', $o], 'Test', $db_file));
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
}
dba_close($db_file);
?>
--CLEAN--
<?php
require(__DIR__ .'/clean.inc');
?>
--EXPECT--
Error: Object of class stdClass could not be converted to string
Error: Object of class stdClass could not be converted to string

View file

@ -4,34 +4,35 @@ DBA check behaviour of key as an array with non string elements
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__ .'/skipif.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
die("info $HND handler used"); check_skip_any();
?> ?>
--FILE-- --FILE--
<?php <?php
require_once(__DIR__ .'/test.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_file = dba_open($db_file, "n", $handler); $name = 'array_keys_non_string.db';
if ($db_file === false) { $db = get_any_db($name);
die('Error creating database');
}
$key = [5, 5.21]; $key = [5, 5.21];
var_dump($key); var_dump($key);
var_dump(dba_insert($key, 'Test', $db_file)); var_dump(dba_insert($key, 'Test', $db));
var_dump($key); var_dump($key);
var_dump(dba_fetch($key, $db_file)); var_dump(dba_fetch($key, $db));
var_dump($key); var_dump($key);
dba_close($db_file); dba_close($db);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'array_keys_non_string.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECTF--
Using handler: "%s"
array(2) { array(2) {
[0]=> [0]=>
int(5) int(5)

View file

@ -4,25 +4,34 @@ DBA CDB handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'cdb'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('cdb');
die('info CDB does not support replace or delete');
?> ?>
--FILE-- --FILE--
<?php <?php
$handler = 'cdb'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/test.inc'); $db_name = 'dba_cdb.db';
require_once(__DIR__ .'/dba_handler.inc');
set_up_cdb_db_and_run($db_name);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_cdb.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: cdb Key 1 exists? Y
5YYYYY Key 2 exists? Y
Content String 2 Key 3 exists? Y
array(5) { Key 4 exists? Y
Key 5 exists? Y
array(8) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key1"]=> ["key1"]=>
string(16) "Content String 1" string(16) "Content String 1"
["key2"]=> ["key2"]=>
@ -33,11 +42,20 @@ array(5) {
string(22) "Another Content String" string(22) "Another Content String"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
--NO-LOCK-- --NO-LOCK--
5YYYYY Key 1 exists? Y
Content String 2 Key 2 exists? Y
array(5) { Key 3 exists? Y
Key 4 exists? Y
Key 5 exists? Y
array(8) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key1"]=> ["key1"]=>
string(16) "Content String 1" string(16) "Content String 1"
["key2"]=> ["key2"]=>
@ -48,4 +66,6 @@ array(5) {
string(22) "Another Content String" string(22) "Another Content String"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }

View file

@ -8,6 +8,8 @@ $handler = 'cdb';
require_once(__DIR__ .'/skipif.inc'); require_once(__DIR__ .'/skipif.inc');
die('info CDB does not support replace or delete'); die('info CDB does not support replace or delete');
?> ?>
--CONFLICTS--
dba
--FILE-- --FILE--
<?php <?php

View file

@ -0,0 +1,195 @@
--TEST--
DBA CDB opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('cdb');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'cdb';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'cdb';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(cdb_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "cl":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "nl":
Cannot fetch insertion
Mode parameter is "nd":
Cannot fetch insertion
Mode parameter is "n-":
Cannot fetch insertion
Mode parameter is "n":
Cannot fetch insertion
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "cl":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "nl":
Cannot fetch insertion
Mode parameter is "nd":
Cannot fetch insertion
Mode parameter is "n-":
Cannot fetch insertion
Mode parameter is "n":
Cannot fetch insertion
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "cl":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: cdb: Update operations are not supported in %s on line %d
Opening DB failed
Mode parameter is "nl":
Cannot fetch insertion
Mode parameter is "nd":
Cannot fetch insertion
Mode parameter is "n-":
Cannot fetch insertion
Mode parameter is "n":
Cannot fetch insertion

View file

@ -4,14 +4,15 @@ DBA CDB_MAKE handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'cdb_make'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('cdb_make');
die('info CDB_MAKE does not support reading');
?> ?>
--CONFLICTS--
test.cdb
--FILE-- --FILE--
<?php <?php
$handler = 'cdb_make'; $handler = 'cdb_make';
require_once(__DIR__ .'/test.inc'); $db_file = 'recreate_testcdb.cdb';
echo "database handler: $handler\n"; echo "database handler: $handler\n";
// print md5 checksum of test.cdb which is generated by cdb_make program // print md5 checksum of test.cdb which is generated by cdb_make program
var_dump(md5_file(__DIR__.'/test.cdb')); var_dump(md5_file(__DIR__.'/test.cdb'));
@ -34,7 +35,9 @@ dba
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'recreate_testcdb.cdb';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: cdb_make database handler: cdb_make

View file

@ -4,9 +4,11 @@ DBA CDB handler test (read only)
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'cdb_make'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('cdb_make');
?> ?>
--CONFLICTS--
test.cdb
--FILE-- --FILE--
<?php <?php
echo "database handler: cdb\n"; echo "database handler: cdb\n";

View file

@ -4,47 +4,70 @@ DBA DB1 handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'db1'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('db1');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db1.db';
$handler = 'db1'; $handler = 'db1';
require_once __DIR__ .'/test.inc'; run_standard_tests($handler, $db_name);
require_once __DIR__ .'/dba_handler.inc';
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db1.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: db1 === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(6) {
["key5"]=> ["[key10]name10"]=>
string(23) "The last content string" string(17) "Content String 10"
} ["[key30]name30"]=>
--NO-LOCK-- string(17) "Content String 30"
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

View file

@ -4,47 +4,70 @@ DBA DB2 handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'db2'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('db2');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db2.db';
$handler = 'db2'; $handler = 'db2';
require_once __DIR__ .'/test.inc'; run_standard_tests($handler, $db_name);
require_once __DIR__ .'/dba_handler.inc';
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db2.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: db2 === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(6) {
["key5"]=> ["[key10]name10"]=>
string(23) "The last content string" string(17) "Content String 10"
} ["[key30]name30"]=>
--NO-LOCK-- string(17) "Content String 30"
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

View file

@ -4,47 +4,70 @@ DBA DB3 handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'db3'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('db3');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db3.db';
$handler = 'db3'; $handler = 'db3';
require_once __DIR__ .'/test.inc'; run_standard_tests($handler, $db_name);
require_once __DIR__ .'/dba_handler.inc';
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db3.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: db3 === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(6) {
["key5"]=> ["[key10]name10"]=>
string(23) "The last content string" string(17) "Content String 10"
} ["[key30]name30"]=>
--NO-LOCK-- string(17) "Content String 30"
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

View file

@ -4,51 +4,71 @@ DBA DB4 handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'db4'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('db4');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db4.db';
$handler = 'db4'; $handler = 'db4';
require_once(__DIR__ .'/test.inc'); set_up_db($handler, $db_name);
require_once(__DIR__ .'/dba_handler.inc'); run_standard_tests($handler, $db_name);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_db4.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: db4 === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(6) {
["key5"]=> ["[key10]name10"]=>
string(23) "The last content string" string(17) "Content String 10"
} ["[key30]name30"]=>
--NO-LOCK-- string(17) "Content String 30"
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

View file

@ -1,34 +0,0 @@
--TEST--
DBA DB4 New File Creation open("c") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
database file created
This is a test insert

View file

@ -1,34 +0,0 @@
--TEST--
DBA DB4 New File Creation open("n") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
database file created
This is a test insert

View file

@ -1,46 +0,0 @@
--TEST--
DBA DB4 File Creation open("c") with existing file
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: db4
int(14)
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_003.php on line %d
Error creating %stest0.dbm
Dummy contents

View file

@ -1,42 +0,0 @@
--TEST--
DBA DB4 Truncate Existing File open("n")
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
int(14)
database file created
This is a test insert

View file

@ -1,34 +0,0 @@
--TEST--
DBA DB4 New File Creation popen("c") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
database file created
This is a test insert

View file

@ -1,34 +0,0 @@
--TEST--
DBA DB4 New File Creation popen("n") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
database file created
This is a test insert

View file

@ -1,41 +0,0 @@
--TEST--
DBA DB4 File Creation popen("c") with existing invalid file
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: db4
int(14)
Warning: dba_popen(): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_007.php on line %d
Error creating %stest0.dbm

View file

@ -1,42 +0,0 @@
--TEST--
DBA DB4 Truncate Existing File popen("n")
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
int(14)
database file created
This is a test insert

View file

@ -4,50 +4,32 @@ DBA DB4 Multiple File Creation Test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = "db4"; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('db4');
die("info $HND handler used");
?> ?>
--FILE-- --FILE--
<?php <?php
$handler = "db4"; $handler = "db4";
require_once(__DIR__ .'/test.inc');
echo "database handler: $handler\n"; echo "database handler: $handler\n";
$db_file1 = $db_filename1 = __DIR__.'/test1.dbm'; $db_file1 = __DIR__.'/test1.dbm';
$db_file2 = $db_filename2 = __DIR__.'/test2.dbm'; $db_file2 = __DIR__.'/test2.dbm';
if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { $db_file1 = dba_open($db_file1, "n", $handler);
echo "database file created\n"; $db_file2 = dba_open($db_file2, "n", $handler);
} 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()); var_dump(dba_list());
dba_close($db_file); dba_close($db_file1);
dba_close($db_file2);
@unlink($db_filename1);
@unlink($db_filename2);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); $db_filename1 = __DIR__.'/test1.dbm';
$db_filename2 = __DIR__.'/test2.dbm';
@unlink($db_filename1);
@unlink($db_filename2);
?> ?>
--EXPECTF-- --EXPECTF--
database handler: db4 database handler: db4
database file created array(2) {
database file created
database file created
array(3) {
[%d]=>
string(%d) "%stest0.dbm"
[%d]=> [%d]=>
string(%d) "%stest1.dbm" string(%d) "%stest1.dbm"
[%d]=> [%d]=>

View file

@ -1,38 +0,0 @@
--TEST--
DBA DB4 with repeated key
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
bool(true)
bool(true)
bool(false)
Content String 1
Content String 2

View file

@ -1,33 +0,0 @@
--TEST--
DBA DB4 New File Creation open("rl")
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: db4
Warning: dba_open(): Driver initialization failed for handler: db4: No such file or directory in %sdba_db4_012.php on line %d
Error creating %stest0.dbm

View file

@ -1,42 +0,0 @@
--TEST--
DBA DB4 File open("rl") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/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

View file

@ -1,34 +0,0 @@
--TEST--
DBA DB4 File open("wl") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECTF--
database handler: db4
Warning: dba_open(): Driver initialization failed for handler: db4: No such file or directory in %sdba_db4_014.php on line %d
Error creating %stest0.dbm

View file

@ -1,41 +0,0 @@
--TEST--
DBA DB4 File open("wl") & Insert Test
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
database file created
database file opened
This is a test insert

View file

@ -1,61 +0,0 @@
--TEST--
DBA DB4 File Creation popen("c") with existing valid file
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
die("info $HND handler used");
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
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

View file

@ -1,39 +0,0 @@
--TEST--
DBA DB4 file creation dba_open("cd")
--EXTENSIONS--
dba
--SKIPIF--
<?php
$handler = "db4";
require_once(__DIR__ .'/skipif.inc');
?>
--FILE--
<?php
$handler = "db4";
require_once(__DIR__ .'/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(__DIR__ .'/clean.inc');
?>
--EXPECT--
database handler: db4
database file created
bool(true)
This is a test insert

View file

@ -2,6 +2,8 @@
DBA DB4 with persistent connections DBA DB4 with persistent connections
--EXTENSIONS-- --EXTENSIONS--
dba dba
--CONFLICTS--
dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = "db4"; $handler = "db4";

View file

@ -0,0 +1,171 @@
--TEST--
DBA DB4 opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('db4');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'db4';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'db4';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Warning: dba_open(): Driver initialization failed for handler: db4: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(db4_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Driver initialization failed for handler: db4: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(db4_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(): Driver initialization failed for handler: db4: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(db4_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Driver initialization failed for handler: db4: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(db4_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
This is a test insert
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "cl":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: db4: Invalid argument in %s on line %d
Opening DB failed
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert

View file

@ -2,6 +2,8 @@
DBA DB4 Handler Test DBA DB4 Handler Test
--EXTENSIONS-- --EXTENSIONS--
dba dba
--CONFLICTS--
dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler="db4"; $handler="db4";

View file

@ -2,6 +2,8 @@
DBA DB4 Optimize Test DBA DB4 Optimize Test
--EXTENSIONS-- --EXTENSIONS--
dba dba
--CONFLICTS--
dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = "db4"; $handler = "db4";

View file

@ -2,6 +2,8 @@
DBA DB4 Sync Test DBA DB4 Sync Test
--EXTENSIONS-- --EXTENSIONS--
dba dba
--CONFLICTS--
dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = "db4"; $handler = "db4";

View file

@ -4,46 +4,42 @@ DBA DBM handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'dbm'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('dbm');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_dbm.db';
$handler = 'dbm'; $handler = 'dbm';
require_once __DIR__ .'/test.inc'; set_up_db($handler, $db_name, false /* Locking done by the library */);
require_once __DIR__ .'/dba_handler.inc'; run_standard_tests($handler, $db_name, false /* Locking done by the library */);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_dbm.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: dbm key4: Another Content String
3NYNYY key2: Content String 2
Content String 2 key5: The last content string
Total keys: 3
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Delete "key4"
The 6th value Fetch "key2": Content 2 replaced 2nd time
array(3) { Fetch "key number 6": The 6th value
["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
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) { array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"

View file

@ -4,27 +4,28 @@ dba_fetch() legacy signature
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__ .'/skipif.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
die("info $HND handler used"); check_skip_any();
?> ?>
--FILE-- --FILE--
<?php <?php
require_once(__DIR__ .'/test.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_file = dba_open($db_file, "n", $handler); $name = 'legacy_fetch_signature.db';
if ($db_file === false) { $db = get_any_db($name);
die('Error creating database');
}
dba_insert("key1", "This is a test insert", $db_file); dba_insert("key1", "This is a test insert", $db);
echo dba_fetch("key1", 0, $db_file), \PHP_EOL, dba_fetch("key1", $db_file, 0); echo dba_fetch("key1", 0, $db), \PHP_EOL, dba_fetch("key1", $db, 0);
dba_close($db_file); dba_close($db);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'legacy_fetch_signature.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECTF--
Using handler: "%s"
This is a test insert This is a test insert
This is a test insert This is a test insert

View file

@ -4,51 +4,70 @@ DBA FlatFile handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'flatfile'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('flatfile');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_flatfile.db';
$handler = 'flatfile'; $handler = 'flatfile';
require_once(__DIR__ .'/test.inc'); run_standard_tests($handler, $db_name);
require_once(__DIR__ .'/dba_handler.inc');
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_flatfile.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: flatfile === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(6) {
["key5"]=> ["[key10]name10"]=>
string(23) "The last content string" string(17) "Content String 10"
} ["[key30]name30"]=>
--NO-LOCK-- string(17) "Content String 30"
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

View file

@ -0,0 +1,155 @@
--TEST--
DBA flatfile opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('flatfile');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'flatfile';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'flatfile';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(flatfile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
This is a test insert
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
Cannot fetch insertion
Mode parameter is "wd":
Cannot fetch insertion
Mode parameter is "w-":
Cannot fetch insertion
Mode parameter is "w":
Cannot fetch insertion
Mode parameter is "cl":
Cannot fetch insertion
Mode parameter is "cd":
Cannot fetch insertion
Mode parameter is "c-":
Cannot fetch insertion
Mode parameter is "c":
Cannot fetch insertion
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert

View file

@ -4,33 +4,122 @@ DBA GDBM handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'gdbm'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('gdbm');
?> ?>
--FILE-- --FILE--
<?php <?php
$handler = 'gdbm'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/test.inc'; $db_name = 'dba_gdbm.db';
$lock_flag = ''; // lock in library
require_once __DIR__ .'/dba_handler.inc';
// Read during write is system dependent. Important is that there is no deadlock $handler = 'gdbm';
run_standard_tests($handler, $db_name);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_gdbm.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECTF-- --EXPECTF--
database handler: gdbm === RUNNING WITH FILE LOCK ===
3NYNYY
Content String 2 Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
key2: Content String 2
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write:%sallowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
Notice: dba_open(): Handler gdbm does locking internally in %s on line 1%d
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
key2: Content String 2
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced
Read during write: not allowed
Expected: Added a new data entry
Expected: Failed to insert data for already used key
Replace second key data
bool(true)
Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=>
string(13) "The 6th value"
["key2"]=>
string(27) "Content 2 replaced 2nd time"
["key5"]=>
string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
}
=== RUNNING WITH NO LOCK ===
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Failed to create DB

View file

@ -0,0 +1,207 @@
--TEST--
DBA GDBM opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('gdbm');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'gdbm';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'gdbm';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: gdbm: File open error in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: gdbm: File open error in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: gdbm: File open error in %s on line %d
Opening DB failed
Mode parameter is "wl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: gdbm: File open error in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: gdbm: File open error in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: gdbm: File open error in %s on line %d
Opening DB failed
Mode parameter is "cl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "wl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "cl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: gdbm: Unexpected end of file in %s on line %d
Opening DB failed
Mode parameter is "nl":
Notice: dba_open(): Handler gdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler gdbm in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert

View file

@ -1,98 +0,0 @@
<?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.'t', $handler))===false) {
echo "Read during write: not allowed\n";
} else {
echo "Read during write: allowed\n";
}
if ($db_writer!==FALSE) {
if (dba_insert("key number 6", "The 6th value", $db_writer)) {
echo '"key number 6" written' . "\n";
} else {
echo 'Failed to write "key number 6"' . "\n";
}
if (dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer)) {
echo '"key number 6" written 2nd time' . "\n";
} else {
echo 'Failed to write "key number 6" 2nd time' . "\n";
}
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' || $handler == "tcadb") {
dba_close($db_file);
}
}
if ($lock_flag == '') {
break;
} else {
echo "--NO-LOCK--\n";
$lock_flag = '';
}
} while(1);
?>

View file

@ -4,51 +4,77 @@ DBA INIFILE handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'inifile'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('inifile');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_inifile.db';
$handler = 'inifile'; $handler = 'inifile';
require_once __DIR__ .'/test.inc'; run_standard_tests($handler, $db_name);
require_once __DIR__ .'/dba_handler.inc';
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_inifile.db';
cleanup_standard_db($db_name);
?> ?>
--WHITESPACE_SENSITIVE--
--EXPECT-- --EXPECT--
database handler: inifile === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]:
[key10]name10: Content String 10
[key30]:
[key30]name30: Content String 30
Total keys: 8
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
"key number 6" written 2nd time Unexpected: Wrote data to already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(8) {
["key5"]=> ["[key10]"]=>
string(23) "The last content string" string(0) ""
} ["[key10]name10"]=>
--NO-LOCK-- string(17) "Content String 10"
3NYNYY ["[key30]"]=>
Content String 2 string(0) ""
Content 2 replaced ["[key30]name30"]=>
Read during write: not allowed string(17) "Content String 30"
"key number 6" written
"key number 6" written 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

View file

@ -0,0 +1,155 @@
--TEST--
DBA INIFILE opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('inifile');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'inifile';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'inifile';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(inifile_not_existing.db): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
This is a test insert
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
This is a test insert
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert

View file

@ -4,35 +4,126 @@ DBA LMDB handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'lmdb'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('lmdb');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_lmdb.db';
$handler = 'lmdb'; $handler = 'lmdb';
require_once __DIR__ .'/test.inc'; run_standard_tests($handler, $db_name);
$lock_flag = ''; // lock in library
require_once __DIR__ .'/dba_handler.inc';
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require_once __DIR__ .'/clean.inc'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_lmdb.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECTF-- --EXPECTF--
database handler: lmdb === RUNNING WITH FILE LOCK ===
3NYNYY
Content String 2 Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
Warning: dba_delete(): MDB_NOTFOUND: No matching key/data pair found in %s on line %d
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write:%sallowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
Warning: dba_delete(): MDB_NOTFOUND: No matching key/data pair found in %s on line %d
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced
Read during write: not allowed
Expected: Added a new data entry
Expected: Failed to insert data for already used key
Replace second key data
bool(true)
Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=>
string(13) "The 6th value"
["key2"]=>
string(27) "Content 2 replaced 2nd time"
["key5"]=>
string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
}
=== RUNNING WITH NO LOCK ===
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Failed to create DB

View file

@ -0,0 +1,207 @@
--TEST--
DBA LMDB opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('lmdb');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'lmdb';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'lmdb';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: lmdb: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: lmdb: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: lmdb: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "wl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "cl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "nl":
Notice: dba_open(): Handler lmdb does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "nd":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler lmdb in %s on line %d
Opening DB failed
Mode parameter is "n":
Warning: dba_open(): Driver initialization failed for handler: lmdb: MDB_INVALID: File is not an LMDB file in %s on line %d
Opening DB failed

View file

@ -4,47 +4,123 @@ DBA NDBM handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'ndbm'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('ndbm');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_ndbm.db';
$handler = 'ndbm'; $handler = 'ndbm';
require_once __DIR__ .'/test.inc'; set_up_db($handler, $db_name, false /* Locking done by the library */);
require_once __DIR__ .'/dba_handler.inc'; run_standard_tests($handler, $db_name, false /* Locking done by the library */);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_ndbm.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: ndbm === RUNNING WITH FILE LOCK ===
3NYNYY
Content String 2 Notice: dba_open(): Handler ndbm does locking internally in /home/girgias/Dev/php-src/ext/dba/tests/setup/setup_dba_tests.inc on line 40
Notice: dba_open(): Handler ndbm does locking internally in /home/girgias/Dev/php-src/ext/dba/tests/setup/setup_dba_tests.inc on line 40
Notice: dba_open(): Handler ndbm does locking internally in /home/girgias/Dev/php-src/ext/dba/tests/setup/setup_dba_tests.inc on line 82
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
key2: Content String 2
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
Notice: dba_open(): Handler ndbm does locking internally in /home/girgias/Dev/php-src/ext/dba/tests/setup/setup_dba_tests.inc on line 149
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
--NO-LOCK-- === RUNNING WITH DB LOCK (default) ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
key2: Content String 2
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH NO LOCK ===
Warning: dba_open(): Locking cannot be disabled for handler ndbm in /home/girgias/Dev/php-src/ext/dba/tests/setup/setup_dba_tests.inc on line 40
Failed to create DB

View file

@ -4,35 +4,122 @@ DBA QDBM handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'qdbm'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('qdbm');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_qdbm.db';
$handler = 'qdbm'; $handler = 'qdbm';
require_once __DIR__ .'/test.inc'; run_standard_tests($handler, $db_name);
$lock_flag = ''; // lock in library
require_once __DIR__ .'/dba_handler.inc';
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_qdbm.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECTF-- --EXPECTF--
database handler: qdbm === RUNNING WITH FILE LOCK ===
3NYNYY
Content String 2 Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write:%sallowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
Notice: dba_open(): Handler qdbm does locking internally in %s on line 1%d
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
Remove key 1 and 3
bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced
Read during write: not allowed
Expected: Added a new data entry
Expected: Failed to insert data for already used key
Replace second key data
bool(true)
Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=>
string(13) "The 6th value"
["key2"]=>
string(27) "Content 2 replaced 2nd time"
["key5"]=>
string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
}
=== RUNNING WITH NO LOCK ===
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Failed to create DB

View file

@ -0,0 +1,207 @@
--TEST--
DBA QDBM opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('qdbm');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'qdbm';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'qdbm';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: qdbm: open error in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: qdbm: open error in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: qdbm: open error in %s on line %d
Opening DB failed
Mode parameter is "wl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: qdbm: open error in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: qdbm: open error in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: qdbm: open error in %s on line %d
Opening DB failed
Mode parameter is "cl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "wl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "cl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: qdbm: broken database file in %s on line %d
Opening DB failed
Mode parameter is "nl":
Notice: dba_open(): Handler qdbm does locking internally in %s on line %d
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
Warning: dba_open(): Locking cannot be disabled for handler qdbm in %s on line %d
Opening DB failed
Mode parameter is "n":
This is a test insert

View file

@ -2,11 +2,6 @@
DBA Split Test DBA Split Test
--EXTENSIONS-- --EXTENSIONS--
dba dba
--SKIPIF--
<?php
require_once __DIR__ .'/skipif.inc';
die("info $HND handler used");
?>
--FILE-- --FILE--
<?php <?php
var_dump(dba_key_split(null)); var_dump(dba_key_split(null));

View file

@ -2,6 +2,8 @@
DBA Sync Test DBA Sync Test
--EXTENSIONS-- --EXTENSIONS--
dba dba
--CONFLICTS--
dba
--SKIPIF-- --SKIPIF--
<?php <?php
require_once __DIR__ .'/skipif.inc'; require_once __DIR__ .'/skipif.inc';

View file

@ -4,56 +4,71 @@ DBA TCADB handler test
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = 'tcadb'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once __DIR__ .'/skipif.inc'; check_skip('tcadb');
?> ?>
--FILE-- --FILE--
<?php <?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'dba_tcadb.tch';
$handler = 'tcadb'; $handler = 'tcadb';
$lock_flag = 'l'; set_up_db($handler, $db_name);
$db_filename = $db_file = __DIR__ .'/test0.tch'; run_standard_tests($handler, $db_name);
@unlink($db_filename);
@unlink($db_filename.'.lck');
require_once __DIR__ .'/dba_handler.inc';
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
$db_filename = $db_file = __DIR__ .'/test0.tch'; require_once __DIR__ . '/setup/setup_dba_tests.inc';
@unlink($db_filename); $db_name = 'dba_tcadb.tch';
@unlink($db_filename.'.lck'); cleanup_standard_db($db_name);
?> ?>
--EXPECT-- --EXPECT--
database handler: tcadb === RUNNING WITH FILE LOCK ===
3NYNYY Remove key 1 and 3
Content String 2 bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Key 3 exists? N
Key 4 exists? Y
Key 5 exists? Y
Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
["key number 6"]=> bool(true)
string(13) "The 6th value" Fetch "key2": Content 2 replaced 2nd time
["key2"]=> Fetch "key number 6": The 6th value
string(27) "Content 2 replaced 2nd time" array(6) {
["key5"]=> ["[key10]name10"]=>
string(23) "The last content string" string(17) "Content String 10"
} ["[key30]name30"]=>
--NO-LOCK-- string(17) "Content String 30"
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN

View file

@ -0,0 +1,179 @@
--TEST--
DBA tcadb opening matrix of combination
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('tcadb');
?>
--FILE--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'tcadb';
run_creation_tests($handler);
?>
--CLEAN--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
$handler = 'tcadb';
clean_creation_tests($handler);
?>
--EXPECTF--
=== OPENING NON-EXISTING FILE ===
Mode parameter is "rl":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(tcadb_not_existing.tch): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(tcadb_not_existing.tch): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(tcadb_not_existing.tch): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(tcadb_not_existing.tch): Failed to open stream: No such file or directory in %s on line %d
Opening DB failed
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING DB FILE ===
Mode parameter is "rl":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "rd":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r-":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "r":
Warning: dba_insert(): Cannot perform a modification on a readonly database in %s on line %d
Insertion failed
Mode parameter is "wl":
This is a test insert
Mode parameter is "wd":
This is a test insert
Mode parameter is "w-":
This is a test insert
Mode parameter is "w":
This is a test insert
Mode parameter is "cl":
This is a test insert
Mode parameter is "cd":
This is a test insert
Mode parameter is "c-":
This is a test insert
Mode parameter is "c":
This is a test insert
Mode parameter is "nl":
This is a test insert
Mode parameter is "nd":
This is a test insert
Mode parameter is "n-":
This is a test insert
Mode parameter is "n":
This is a test insert
=== OPENING EXISTING RANDOM FILE ===
Mode parameter is "rl":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "rd":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "r-":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "r":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "wl":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "wd":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "w-":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "w":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "cl":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "cd":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "c-":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "c":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "nl":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "nd":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "n-":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed
Mode parameter is "n":
Warning: dba_open(): Driver initialization failed for handler: tcadb in %s on line %d
Opening DB failed

View file

@ -4,15 +4,15 @@ DBA dba.default_handler tests
dba dba
--SKIPIF-- --SKIPIF--
<?php <?php
$handler = "flatfile"; require_once __DIR__ . '/setup/setup_dba_tests.inc';
require_once(__DIR__ .'/skipif.inc'); check_skip('flatfile');
?> ?>
--INI-- --INI--
dba.default_handler=flatfile dba.default_handler=flatfile
--FILE-- --FILE--
<?php <?php
$handler = "flatfile"; $handler = "flatfile";
require_once(__DIR__ .'/test.inc'); $db_filename = 'ini_test_default_handler.db';
echo "database handler: $handler\n"; echo "database handler: $handler\n";
echo "Test 1\n"; echo "Test 1\n";
@ -30,15 +30,17 @@ var_dump(dba_open($db_filename, 'n'));
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require(__DIR__ .'/clean.inc'); require_once __DIR__ . '/setup/setup_dba_tests.inc';
$db_name = 'ini_test_default_handler.db';
cleanup_standard_db($db_name);
?> ?>
--EXPECTF-- --EXPECTF--
database handler: flatfile database handler: flatfile
Test 1 Test 1
Warning: ini_set(): No such handler: does_not_exist in %sdba012.php on line %d Warning: ini_set(): No such handler: does_not_exist in %s on line %d
resource(%d) of type (dba) resource(%d) of type (dba)
Test 2 Test 2
Warning: dba_open(): No default handler selected in %sdba012.php on line %d Warning: dba_open(): No default handler selected in %s on line %d
bool(false) bool(false)

View file

@ -0,0 +1,297 @@
<?php
function check_skip_any() {
if (dba_handlers() === []) {
die('skip no handlers installed');
}
if (dba_handlers() === ['cdb']) {
die('skip only cdb installed which is not suitable');
}
if (dba_handlers() === ['cdb_make']) {
die('skip only cdb_make installed which is not suitable');
}
}
function check_skip(string $handler) {
$handlers = dba_handlers();
if ($handlers === []) {
die('skip no handlers installed');
}
if (!in_array($handler, $handlers)) {
$HND = strtoupper($handler);
die("skip $HND handler not available");
}
}
function get_any_handler(): string {
foreach (dba_handlers() as $handler) {
// Those are weird
if ($handler !== 'cdb' && $handler !== 'cdb_make' && $handler !== 'inifile') {
echo 'Using handler: "', $handler, '"', \PHP_EOL;
return $handler;
}
}
return 'should_not_happen';
}
function get_any_db(string $name) {
return dba_open($name, 'c', get_any_handler());
}
enum LockFlag: string {
case FileLock = 'l';
case DbLock = 'd';
case NoLock = '-';
}
function set_up_db_ex(string $handler, string $name, LockFlag $lock, bool $persistent = false) {
$lock_flag = $lock->value;
// Open file in creation/truncation mode
$func = $persistent ? 'dba_popen' : 'dba_open';
$db_file = $func($name, 'n'.$lock_flag, $handler);
if ($db_file === false) {
die("Failed to create DB");
}
// Insert some data
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);
// Insert date with array keys
dba_insert(["", "name9"], "Content String 9", $db_file);
dba_insert(["key10", "name10"] , "Content String 10", $db_file);
dba_insert("[key30]name30", "Content String 30", $db_file);
return $db_file;
}
function set_up_db(string $handler, string $name, LockFlag $lock = LockFlag::FileLock): void {
$db_file = set_up_db_ex($handler, $name, $lock);
// Close creation/truncation handler
dba_close($db_file);
}
function run_common_read_only_test($dbHandle): void {
$key = dba_firstkey($dbHandle);
$result = [];
while ($key) {
$result[$key] = dba_fetch($key, $dbHandle);
$key = dba_nextkey($dbHandle);
}
ksort($result);
var_dump($result);
}
function run_standard_tests_ex(string $handler, string $name, LockFlag $lock, bool $persistent = false): void
{
$lock_flag = $lock->value;
set_up_db($handler, $name, $lock);
$db_writer = dba_open($name, 'w'.$lock_flag, $handler);
if ($db_writer === false) {
die("Failed to open DB for write");
}
echo 'Remove key 1 and 3', \PHP_EOL;
var_dump(dba_delete("key3", $db_writer));
var_dump(dba_delete("key1", $db_writer));
echo 'Try to remove key 1 again', \PHP_EOL;
var_dump(dba_delete("key1", $db_writer));
// Fetch data
$key = dba_firstkey($db_writer);
$total_keys = 0;
while ($key) {
echo $key, ': ', dba_fetch($key, $db_writer), \PHP_EOL;
$key = dba_nextkey($db_writer);
$total_keys++;
}
echo 'Total keys: ', $total_keys, \PHP_EOL;
for ($i = 1; $i < 6; $i++) {
echo "Key $i exists? ", dba_exists("key$i", $db_writer) ? 'Y' : 'N', \PHP_EOL;
}
echo 'Replace second key data', \PHP_EOL;
var_dump(dba_replace('key2', 'Content 2 replaced', $db_writer));
echo dba_fetch('key2', $db_writer), \PHP_EOL;
// Check that read is possible when a lock is used
$test_flag = 't';
if ($lock === LockFlag::NoLock) {
// No point testing when we don't use locks
$test_flag = '';
}
$db_reader = @dba_open($name, 'r'.$lock_flag.$test_flag, $handler);
if ($db_reader === false) {
echo 'Read during write: not allowed', \PHP_EOL;
} else {
echo 'Read during write: allowed', \PHP_EOL;
dba_close($db_reader);
}
if (dba_insert('key number 6', 'The 6th value', $db_writer)) {
echo 'Expected: Added a new data entry', \PHP_EOL;
} else {
echo 'Unexpected: Failed to add a new data entry', \PHP_EOL;
}
if (dba_insert('key number 6', 'The 6th value inserted again would be an error', $db_writer)) {
echo 'Unexpected: Wrote data to already used key', \PHP_EOL;
} else {
echo 'Expected: Failed to insert data for already used key', \PHP_EOL;
}
echo 'Replace second key data', \PHP_EOL;
var_dump(dba_replace('key2', 'Content 2 replaced 2nd time', $db_writer));
echo 'Delete "key4"', \PHP_EOL;
var_dump(dba_delete('key4', $db_writer));
echo 'Fetch "key2": ', dba_fetch('key2', $db_writer), \PHP_EOL;
echo 'Fetch "key number 6": ', dba_fetch('key number 6', $db_writer), \PHP_EOL;
dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io.
$db_reader = dba_open($name, 'r'.$lock_flag, $handler);
run_common_read_only_test($db_reader);
dba_close($db_reader);
/* TODO popen test? Old code copied from the previous general test
if (($db_file = dba_popen($db_filename, 'r'.($lock_flag==''?'':'-'), $handler))!==FALSE) {
if ($handler == 'dbm' || $handler == "tcadb") {
dba_close($db_file);
}
}
*/
}
const MODES = ['r', 'w', 'c', 'n'];
const LOCKS = ['l', 'd', '-', '' /* No lock flag is like 'd' */];
function run_creation_tests_ex(string $handler, string $file_suffix, string $pre_req): void
{
$db_name = $handler . $file_suffix;
foreach (MODES as $mode) {
foreach (LOCKS as $lock) {
eval($pre_req);
$arg = $mode.$lock;
echo 'Mode parameter is "', $arg, '":', \PHP_EOL;
$db = dba_open($db_name, $arg, $handler);
if ($db !== false) {
assert(file_exists($db_name));
$status = dba_insert("key1", "This is a test insert", $db);
if ($status) {
$fetch = dba_fetch("key1", $db);
if ($fetch === false) {
echo 'Cannot fetch insertion', \PHP_EOL;
} else {
echo $fetch, \PHP_EOL;
}
} else {
echo 'Insertion failed', \PHP_EOL;
}
dba_close($db);
} else {
echo 'Opening DB failed', \PHP_EOL;
}
cleanup_standard_db($db_name);
}
}
}
function run_creation_tests(string $handler): void
{
$extension = $handler === 'tcadb' ? 'tch' : 'db';
/* Trying to open a non-existing file */
echo '=== OPENING NON-EXISTING FILE ===', \PHP_EOL;
run_creation_tests_ex($handler, '_not_existing.'.$extension, '');
/* Trying to open an existing db file */
echo '=== OPENING EXISTING DB FILE ===', \PHP_EOL;
run_creation_tests_ex($handler, '_existing.'.$extension, 'dba_open($db_name, "n", $handler);');
/* Trying to open an existing random file */
echo '=== OPENING EXISTING RANDOM FILE ===', \PHP_EOL;
run_creation_tests_ex($handler, '_random.txt', 'file_put_contents($db_name, "Dummy contents");');
}
function clean_creation_tests(string $handler): void {
$db_name = $handler . '_not_existing.db';
cleanup_standard_db($db_name);
$db_name = $handler . '_existing.db';
cleanup_standard_db($db_name);
$db_name = $handler . '_random.txt';
cleanup_standard_db($db_name);
}
function run_standard_tests(string $handler, string $name): void {
echo '=== RUNNING WITH FILE LOCK ===', \PHP_EOL;
ob_start();
set_up_db($handler, $name, LockFlag::FileLock);
run_standard_tests_ex($handler, $name, LockFlag::FileLock);
cleanup_standard_db($name);
$run1_output = ob_get_flush();
echo '=== RUNNING WITH DB LOCK (default) ===', \PHP_EOL;
ob_start();
set_up_db($handler, $name, LockFlag::DbLock);
run_standard_tests_ex($handler, $name, LockFlag::DbLock);
cleanup_standard_db($name);
$run2_output = ob_get_clean();
if ($run1_output === $run2_output) {
echo 'SAME OUTPUT AS PREVIOUS RUN', \PHP_EOL;
} else {
echo $run2_output;
}
echo '=== RUNNING WITH NO LOCK ===', \PHP_EOL;
ob_start();
set_up_db($handler, $name, LockFlag::NoLock);
run_standard_tests_ex($handler, $name, LockFlag::NoLock);
$run3_output = ob_get_clean();
if ($run2_output === $run3_output) {
echo 'SAME OUTPUT AS PREVIOUS RUN', \PHP_EOL;
} else if ($run2_output === str_replace( // If only the fact that the lock prevented reads
'Read during write: allowed',
'Read during write: not allowed',
$run3_output
)
) {
echo 'SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)', \PHP_EOL;
} else {
echo $run3_output;
}
}
// TODO Array keys insertion
// TODO Run all lock flags
function set_up_cdb_db_and_run(string $name): void {
set_up_db('cdb', $name);
$db_file = dba_open($name, 'rl', 'cdb');
if ($db_file === false) {
die("Failed to reopen DB");
}
for ($i = 1; $i < 6; $i++) {
echo "Key $i exists? ", dba_exists("key$i", $db_file) ? 'Y' : 'N', \PHP_EOL;
}
run_common_read_only_test($db_file);
dba_close($db_file);
echo '--NO-LOCK--', \PHP_EOL;
cleanup_standard_db($name);
set_up_db('cdb', $name, LockFlag::NoLock);
$db_file = dba_open($name, 'r-', 'cdb');
if ($db_file === false) {
die("Failed to reopen DB");
}
for ($i = 1; $i < 6; $i++) {
echo "Key $i exists? ", dba_exists("key$i", $db_file) ? 'Y' : 'N', \PHP_EOL;
}
run_common_read_only_test($db_file);
}
function cleanup_standard_db(string $name): void {
@unlink($name);
@unlink($name.'.lck');
@unlink($name.'-lock');
}

View file

@ -116,7 +116,7 @@ database handler: flatfile
resource(%d) of type (dba) resource(%d) of type (dba)
=== Invalid arguments dba_open() === === Invalid arguments dba_open() ===
Warning: dba_open(): Handler "bogus" is not available in %sdba011.php on line %d Warning: dba_open(): Handler "bogus" is not available in %s on line %d
bool(false) bool(false)
dba_open(): Argument #1 ($path) cannot be empty dba_open(): Argument #1 ($path) cannot be empty
dba_open(): Argument #2 ($mode) cannot be empty dba_open(): Argument #2 ($mode) cannot be empty
@ -128,7 +128,7 @@ dba_open(): Argument #2 ($mode) cannot combine mode "-" (no lock) and "t" (test
dba_open(): Argument #5 ($map_size) must be greater than or equal to 0 dba_open(): Argument #5 ($map_size) must be greater than or equal to 0
=== Invalid arguments dba_popen() === === Invalid arguments dba_popen() ===
Warning: dba_popen(): Handler "bogus" is not available in %sdba011.php on line %d Warning: dba_popen(): Handler "bogus" is not available in %s on line %d
bool(false) bool(false)
dba_popen(): Argument #1 ($path) cannot be empty dba_popen(): Argument #1 ($path) cannot be empty
dba_popen(): Argument #2 ($mode) cannot be empty dba_popen(): Argument #2 ($mode) cannot be empty

View file

@ -5,7 +5,8 @@ dba
pgsql pgsql
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__.'/../../dba/tests/skipif.inc'); require_once dirname(__DIR__, 2) . '/dba/tests/setup/setup_dba_tests.inc';
check_skip_any();
require_once('skipif.inc'); require_once('skipif.inc');
?> ?>
--FILE-- --FILE--
@ -18,46 +19,65 @@ if (!$dbh) {
} }
pg_close($dbh); pg_close($dbh);
require_once(__DIR__.'/../../dba/tests/test.inc'); require_once dirname(__DIR__, 2) . '/dba/tests/setup/setup_dba_tests.inc';
require_once(__DIR__.'/../../dba/tests/dba_handler.inc'); $name = 'bug14383.db';
$handler = get_any_handler($name);
run_standard_tests($handler, $name);
?> ?>
--CLEAN-- --CLEAN--
<?php <?php
require_once(__DIR__.'/../../dba/tests/clean.inc'); require_once dirname(__DIR__, 2) . '/dba/tests/setup/setup_dba_tests.inc';
$name = 'bug14383.db';
cleanup_standard_db($name);
?> ?>
--EXPECTF-- --EXPECTF--
database handler: %s Using handler: "%s"
3NYNYY === RUNNING WITH FILE LOCK ===
Content String 2 Remove key 1 and 3
Content 2 replaced bool(true)
Read during write:%sallowed bool(true)
"key number 6" written Try to remove key 1 again
Failed to write "key number 6" 2nd time bool(false)
Content 2 replaced 2nd time key2: Content String 2
The 6th value key4: Another Content String
array(3) { key5: The last content string
["key number 6"]=> name9: Content String 9
string(13) "The 6th value" [key10]name10: Content String 10
["key2"]=> [key30]name30: Content String 30
string(27) "Content 2 replaced 2nd time" Total keys: 6
["key5"]=> Key 1 exists? N
string(23) "The last content string" Key 2 exists? Y
} Key 3 exists? N
--NO-LOCK-- Key 4 exists? Y
3NYNYY Key 5 exists? Y
Content String 2 Replace second key data
bool(true)
Content 2 replaced Content 2 replaced
Read during write: not allowed Read during write: not allowed
"key number 6" written Expected: Added a new data entry
Failed to write "key number 6" 2nd time Expected: Failed to insert data for already used key
Content 2 replaced 2nd time Replace second key data
The 6th value bool(true)
array(3) { Delete "key4"
bool(true)
Fetch "key2": Content 2 replaced 2nd time
Fetch "key number 6": The 6th value
array(6) {
["[key10]name10"]=>
string(17) "Content String 10"
["[key30]name30"]=>
string(17) "Content String 30"
["key number 6"]=> ["key number 6"]=>
string(13) "The 6th value" string(13) "The 6th value"
["key2"]=> ["key2"]=>
string(27) "Content 2 replaced 2nd time" string(27) "Content 2 replaced 2nd time"
["key5"]=> ["key5"]=>
string(23) "The last content string" string(23) "The last content string"
["name9"]=>
string(16) "Content String 9"
} }
=== RUNNING WITH DB LOCK (default) ===
SAME OUTPUT AS PREVIOUS RUN
=== RUNNING WITH NO LOCK ===
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)