mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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:
parent
b948f8048b
commit
eddab74021
77 changed files with 2887 additions and 1663 deletions
|
@ -1,2 +0,0 @@
|
|||
# Many of these tests work on the same database file
|
||||
dba
|
|
@ -4,21 +4,17 @@ Bug #36436 (DBA problem with Berkeley DB4)
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'db4';
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('db4');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'bug36436.db';
|
||||
|
||||
$handler = 'db4';
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
$db = set_up_db_ex('db4', $db_name, LockFlag::DbLock, persistent: true);
|
||||
|
||||
$db = dba_popen($db_filename, 'c', 'db4');
|
||||
|
||||
dba_insert('X', 'XYZ', $db);
|
||||
dba_insert('Y', '123', $db);
|
||||
|
||||
var_dump($db, dba_fetch('X', $db));
|
||||
var_dump($db, dba_fetch('key1', $db));
|
||||
|
||||
var_dump(dba_firstkey($db));
|
||||
var_dump(dba_nextkey($db));
|
||||
|
@ -28,10 +24,12 @@ dba_close($db);
|
|||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'bug36436.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (dba persistent)
|
||||
string(3) "XYZ"
|
||||
string(1) "X"
|
||||
string(1) "Y"
|
||||
string(16) "Content String 1"
|
||||
string(13) "[key10]name10"
|
||||
string(13) "[key30]name30"
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -4,16 +4,15 @@ Bug #65708 (dba functions cast $key param to string in-place, bypassing copy on
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip_any();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$name = 'bug65708.db';
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
|
||||
$db = dba_popen($db_filename, 'c');
|
||||
$db = get_any_db($name);
|
||||
|
||||
$key = 1;
|
||||
$copy = $key;
|
||||
|
@ -31,9 +30,12 @@ dba_close($db);
|
|||
?>
|
||||
--CLEAN--
|
||||
<?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
|
||||
|
|
|
@ -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"
|
|
@ -4,15 +4,16 @@ Bug #78808 ([LMDB] MDB_MAP_FULL: Environment mapsize limit reached)
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'lmdb';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('lmdb');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = 'lmdb';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'bug78808.db';
|
||||
|
||||
$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++) {
|
||||
dba_insert('key' . $i, $value, $lmdb_h);
|
||||
}
|
||||
|
@ -23,5 +24,7 @@ echo "done\n";
|
|||
done
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/clean.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'bug78808.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -8,6 +8,8 @@ dba
|
|||
if (!function_exists('dba_list')) die('skip dba_list() not available');
|
||||
die("info $HND handler used");
|
||||
?>
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
|
|
|
@ -7,6 +7,8 @@ dba
|
|||
require_once(__DIR__ .'/skipif.inc');
|
||||
print("info $HND handler used");
|
||||
?>
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -8,6 +8,8 @@ $handler = "flatfile";
|
|||
require_once(__DIR__ .'/skipif.inc');
|
||||
die("info $HND handler used");
|
||||
?>
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
|
@ -4,34 +4,35 @@ DBA check behaviour of array keys
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
die("info $HND handler used");
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip_any();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
$db_file = dba_open($db_file, "n", $handler);
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$name = 'array_keys_basic.db';
|
||||
|
||||
if ($db_file === false) {
|
||||
die('Error creating database');
|
||||
}
|
||||
$db = get_any_db($name);
|
||||
|
||||
var_dump(dba_insert(['group', 'name'], 'Normal group', $db_file));
|
||||
var_dump(dba_insert(['group', ''], 'Empty name', $db_file));
|
||||
var_dump(dba_insert(['', 'name'], 'Empty group', $db_file));
|
||||
var_dump(dba_insert(['', ''], 'Empty keys', $db_file));
|
||||
var_dump(dba_fetch(['group', 'name'], $db_file));
|
||||
var_dump(dba_fetch(['group', ''], $db_file));
|
||||
var_dump(dba_fetch(['', 'name'], $db_file));
|
||||
var_dump(dba_fetch(['', ''], $db_file));
|
||||
dba_close($db_file);
|
||||
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(__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)
|
||||
|
|
55
ext/dba/tests/dba_array_keys_errors.phpt
Normal file
55
ext/dba/tests/dba_array_keys_errors.phpt
Normal 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
|
42
ext/dba/tests/dba_array_keys_inifile.phpt
Normal file
42
ext/dba/tests/dba_array_keys_inifile.phpt
Normal 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)
|
|
@ -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
|
|
@ -4,34 +4,35 @@ DBA check behaviour of key as an array with non string elements
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
die("info $HND handler used");
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip_any();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
$db_file = dba_open($db_file, "n", $handler);
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$name = 'array_keys_non_string.db';
|
||||
|
||||
if ($db_file === false) {
|
||||
die('Error creating database');
|
||||
}
|
||||
$db = get_any_db($name);
|
||||
|
||||
$key = [5, 5.21];
|
||||
|
||||
var_dump($key);
|
||||
var_dump(dba_insert($key, 'Test', $db_file));
|
||||
var_dump(dba_insert($key, 'Test', $db));
|
||||
var_dump($key);
|
||||
var_dump(dba_fetch($key, $db_file));
|
||||
var_dump(dba_fetch($key, $db));
|
||||
var_dump($key);
|
||||
|
||||
dba_close($db_file);
|
||||
dba_close($db);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?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) {
|
||||
[0]=>
|
||||
int(5)
|
||||
|
|
|
@ -4,25 +4,34 @@ DBA CDB handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'cdb';
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
die('info CDB does not support replace or delete');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('cdb');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = 'cdb';
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
require_once(__DIR__ .'/dba_handler.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_cdb.db';
|
||||
|
||||
set_up_cdb_db_and_run($db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_cdb.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: cdb
|
||||
5YYYYY
|
||||
Content String 2
|
||||
array(5) {
|
||||
Key 1 exists? Y
|
||||
Key 2 exists? Y
|
||||
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"]=>
|
||||
string(16) "Content String 1"
|
||||
["key2"]=>
|
||||
|
@ -33,11 +42,20 @@ array(5) {
|
|||
string(22) "Another Content String"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
["name9"]=>
|
||||
string(16) "Content String 9"
|
||||
}
|
||||
--NO-LOCK--
|
||||
5YYYYY
|
||||
Content String 2
|
||||
array(5) {
|
||||
Key 1 exists? Y
|
||||
Key 2 exists? Y
|
||||
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"]=>
|
||||
string(16) "Content String 1"
|
||||
["key2"]=>
|
||||
|
@ -48,4 +66,6 @@ array(5) {
|
|||
string(22) "Another Content String"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
["name9"]=>
|
||||
string(16) "Content String 9"
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ $handler = 'cdb';
|
|||
require_once(__DIR__ .'/skipif.inc');
|
||||
die('info CDB does not support replace or delete');
|
||||
?>
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
195
ext/dba/tests/dba_cdb_creation_matrix.phpt
Normal file
195
ext/dba/tests/dba_cdb_creation_matrix.phpt
Normal 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
|
|
@ -4,14 +4,15 @@ DBA CDB_MAKE handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'cdb_make';
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
die('info CDB_MAKE does not support reading');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('cdb_make');
|
||||
?>
|
||||
--CONFLICTS--
|
||||
test.cdb
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = 'cdb_make';
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
$db_file = 'recreate_testcdb.cdb';
|
||||
echo "database handler: $handler\n";
|
||||
// print md5 checksum of test.cdb which is generated by cdb_make program
|
||||
var_dump(md5_file(__DIR__.'/test.cdb'));
|
||||
|
@ -34,7 +35,9 @@ dba
|
|||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'recreate_testcdb.cdb';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: cdb_make
|
||||
|
|
|
@ -4,9 +4,11 @@ DBA CDB handler test (read only)
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'cdb_make';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('cdb_make');
|
||||
?>
|
||||
--CONFLICTS--
|
||||
test.cdb
|
||||
--FILE--
|
||||
<?php
|
||||
echo "database handler: cdb\n";
|
||||
|
|
|
@ -4,47 +4,70 @@ DBA DB1 handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'db1';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('db1');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db1.db';
|
||||
|
||||
$handler = 'db1';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db1.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: db1
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
Remove key 1 and 3
|
||||
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
|
||||
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"]=>
|
||||
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) {
|
||||
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 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)
|
||||
|
|
|
@ -4,47 +4,70 @@ DBA DB2 handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'db2';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('db2');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db2.db';
|
||||
|
||||
$handler = 'db2';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db2.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: db2
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
Remove key 1 and 3
|
||||
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
|
||||
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"]=>
|
||||
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) {
|
||||
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 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)
|
||||
|
|
|
@ -4,47 +4,70 @@ DBA DB3 handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'db3';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('db3');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db3.db';
|
||||
|
||||
$handler = 'db3';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db3.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: db3
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
Remove key 1 and 3
|
||||
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
|
||||
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"]=>
|
||||
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) {
|
||||
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 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)
|
||||
|
|
|
@ -4,51 +4,71 @@ DBA DB4 handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'db4';
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('db4');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db4.db';
|
||||
|
||||
$handler = 'db4';
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
require_once(__DIR__ .'/dba_handler.inc');
|
||||
set_up_db($handler, $db_name);
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_db4.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: db4
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
Remove key 1 and 3
|
||||
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
|
||||
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"]=>
|
||||
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) {
|
||||
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 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)
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -4,50 +4,32 @@ DBA DB4 Multiple File Creation Test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = "db4";
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
die("info $HND handler used");
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('db4');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = "db4";
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
echo "database handler: $handler\n";
|
||||
$db_file1 = $db_filename1 = __DIR__.'/test1.dbm';
|
||||
$db_file2 = $db_filename2 = __DIR__.'/test2.dbm';
|
||||
if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
|
||||
echo "database file created\n";
|
||||
} else {
|
||||
echo "$db_file does not exist\n";
|
||||
}
|
||||
if (($db_file1=dba_open($db_file1, "n", $handler))!==FALSE) {
|
||||
echo "database file created\n";
|
||||
} else {
|
||||
echo "$db_file does not exist\n";
|
||||
}
|
||||
if (($db_file2=dba_open($db_file2, "n", $handler))!==FALSE) {
|
||||
echo "database file created\n";
|
||||
} else {
|
||||
echo "$db_file does not exist\n";
|
||||
}
|
||||
$db_file1 = __DIR__.'/test1.dbm';
|
||||
$db_file2 = __DIR__.'/test2.dbm';
|
||||
$db_file1 = dba_open($db_file1, "n", $handler);
|
||||
$db_file2 = dba_open($db_file2, "n", $handler);
|
||||
var_dump(dba_list());
|
||||
dba_close($db_file);
|
||||
dba_close($db_file1);
|
||||
dba_close($db_file2);
|
||||
|
||||
@unlink($db_filename1);
|
||||
@unlink($db_filename2);
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
$db_filename1 = __DIR__.'/test1.dbm';
|
||||
$db_filename2 = __DIR__.'/test2.dbm';
|
||||
@unlink($db_filename1);
|
||||
@unlink($db_filename2);
|
||||
?>
|
||||
--EXPECTF--
|
||||
database handler: db4
|
||||
database file created
|
||||
database file created
|
||||
database file created
|
||||
array(3) {
|
||||
[%d]=>
|
||||
string(%d) "%stest0.dbm"
|
||||
array(2) {
|
||||
[%d]=>
|
||||
string(%d) "%stest1.dbm"
|
||||
[%d]=>
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -2,6 +2,8 @@
|
|||
DBA DB4 with persistent connections
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = "db4";
|
||||
|
|
171
ext/dba/tests/dba_db4_creation_matrix.phpt
Normal file
171
ext/dba/tests/dba_db4_creation_matrix.phpt
Normal 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
|
|
@ -2,6 +2,8 @@
|
|||
DBA DB4 Handler Test
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler="db4";
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
DBA DB4 Optimize Test
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = "db4";
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
DBA DB4 Sync Test
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = "db4";
|
||||
|
|
|
@ -4,46 +4,42 @@ DBA DBM handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'dbm';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('dbm');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_dbm.db';
|
||||
|
||||
$handler = 'dbm';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
set_up_db($handler, $db_name, false /* Locking done by the library */);
|
||||
run_standard_tests($handler, $db_name, false /* Locking done by the library */);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_dbm.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: dbm
|
||||
3NYNYY
|
||||
Content String 2
|
||||
key4: Another Content String
|
||||
key2: 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
|
||||
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"]=>
|
||||
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
|
||||
Expected: Added a new data entry
|
||||
Expected: Failed to insert data for already used key
|
||||
Delete "key4"
|
||||
Fetch "key2": Content 2 replaced 2nd time
|
||||
Fetch "key number 6": The 6th value
|
||||
array(3) {
|
||||
["key number 6"]=>
|
||||
string(13) "The 6th value"
|
||||
|
|
|
@ -4,27 +4,28 @@ dba_fetch() legacy signature
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
die("info $HND handler used");
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip_any();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
$db_file = dba_open($db_file, "n", $handler);
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$name = 'legacy_fetch_signature.db';
|
||||
|
||||
if ($db_file === false) {
|
||||
die('Error creating database');
|
||||
}
|
||||
$db = get_any_db($name);
|
||||
|
||||
dba_insert("key1", "This is a test insert", $db_file);
|
||||
echo dba_fetch("key1", 0, $db_file), \PHP_EOL, dba_fetch("key1", $db_file, 0);
|
||||
dba_close($db_file);
|
||||
dba_insert("key1", "This is a test insert", $db);
|
||||
echo dba_fetch("key1", 0, $db), \PHP_EOL, dba_fetch("key1", $db, 0);
|
||||
dba_close($db);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?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
|
||||
|
|
|
@ -4,51 +4,70 @@ DBA FlatFile handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'flatfile';
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('flatfile');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_flatfile.db';
|
||||
|
||||
$handler = 'flatfile';
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
require_once(__DIR__ .'/dba_handler.inc');
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_flatfile.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: flatfile
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
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
|
||||
"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"]=>
|
||||
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) {
|
||||
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 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)
|
||||
|
|
155
ext/dba/tests/dba_flatfile_creation_matrix.phpt
Normal file
155
ext/dba/tests/dba_flatfile_creation_matrix.phpt
Normal 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
|
|
@ -4,33 +4,122 @@ DBA GDBM handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'gdbm';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('gdbm');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = 'gdbm';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
$lock_flag = ''; // lock in library
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_gdbm.db';
|
||||
|
||||
// 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--
|
||||
database handler: gdbm
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
|
||||
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
|
||||
Read during write:%sallowed
|
||||
"key number 6" written
|
||||
Failed to write "key number 6" 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
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
|
||||
|
||||
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"]=>
|
||||
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 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
|
||||
|
|
207
ext/dba/tests/dba_gdbm_creation_matrix.phpt
Normal file
207
ext/dba/tests/dba_gdbm_creation_matrix.phpt
Normal 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
|
|
@ -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);
|
||||
|
||||
?>
|
|
@ -4,51 +4,77 @@ DBA INIFILE handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'inifile';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('inifile');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_inifile.db';
|
||||
|
||||
$handler = 'inifile';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?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--
|
||||
database handler: inifile
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
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]:
|
||||
[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
|
||||
Read during write: not allowed
|
||||
"key number 6" written
|
||||
"key number 6" written 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
["key number 6"]=>
|
||||
string(13) "The 6th value"
|
||||
["key2"]=>
|
||||
string(27) "Content 2 replaced 2nd time"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
}
|
||||
--NO-LOCK--
|
||||
3NYNYY
|
||||
Content String 2
|
||||
Content 2 replaced
|
||||
Read during write: not allowed
|
||||
"key number 6" written
|
||||
"key number 6" written 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
Expected: Added a new data entry
|
||||
Unexpected: Wrote data to 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(8) {
|
||||
["[key10]"]=>
|
||||
string(0) ""
|
||||
["[key10]name10"]=>
|
||||
string(17) "Content String 10"
|
||||
["[key30]"]=>
|
||||
string(0) ""
|
||||
["[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 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)
|
||||
|
|
155
ext/dba/tests/dba_inifile_creation_matrix.phpt
Normal file
155
ext/dba/tests/dba_inifile_creation_matrix.phpt
Normal 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
|
|
@ -4,35 +4,126 @@ DBA LMDB handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'lmdb';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('lmdb');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_lmdb.db';
|
||||
|
||||
$handler = 'lmdb';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
$lock_flag = ''; // lock in library
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?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--
|
||||
database handler: lmdb
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
|
||||
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
|
||||
Read during write:%sallowed
|
||||
"key number 6" written
|
||||
Failed to write "key number 6" 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
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
|
||||
|
||||
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"]=>
|
||||
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 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
|
||||
|
|
207
ext/dba/tests/dba_lmdb_creation_matrix.phpt
Normal file
207
ext/dba/tests/dba_lmdb_creation_matrix.phpt
Normal 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
|
|
@ -4,47 +4,123 @@ DBA NDBM handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'ndbm';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('ndbm');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_ndbm.db';
|
||||
|
||||
$handler = 'ndbm';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
set_up_db($handler, $db_name, false /* Locking done by the library */);
|
||||
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--
|
||||
database handler: ndbm
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
|
||||
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
|
||||
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) {
|
||||
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
|
||||
|
||||
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"]=>
|
||||
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"
|
||||
}
|
||||
--NO-LOCK--
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== 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
|
||||
"key number 6" written
|
||||
Failed to write "key number 6" 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
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 ndbm in /home/girgias/Dev/php-src/ext/dba/tests/setup/setup_dba_tests.inc on line 40
|
||||
Failed to create DB
|
||||
|
|
|
@ -4,35 +4,122 @@ DBA QDBM handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'qdbm';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('qdbm');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_qdbm.db';
|
||||
|
||||
$handler = 'qdbm';
|
||||
require_once __DIR__ .'/test.inc';
|
||||
$lock_flag = ''; // lock in library
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require(__DIR__ .'/clean.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_qdbm.db';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECTF--
|
||||
database handler: qdbm
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
|
||||
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
|
||||
Read during write:%sallowed
|
||||
"key number 6" written
|
||||
Failed to write "key number 6" 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
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
|
||||
|
||||
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"]=>
|
||||
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 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
|
||||
|
|
207
ext/dba/tests/dba_qdbm_creation_matrix.phpt
Normal file
207
ext/dba/tests/dba_qdbm_creation_matrix.phpt
Normal 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
|
|
@ -2,11 +2,6 @@
|
|||
DBA Split Test
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
die("info $HND handler used");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(dba_key_split(null));
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
DBA Sync Test
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--CONFLICTS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
|
|
|
@ -4,56 +4,71 @@ DBA TCADB handler test
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'tcadb';
|
||||
require_once __DIR__ .'/skipif.inc';
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('tcadb');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_tcadb.tch';
|
||||
|
||||
$handler = 'tcadb';
|
||||
$lock_flag = 'l';
|
||||
$db_filename = $db_file = __DIR__ .'/test0.tch';
|
||||
@unlink($db_filename);
|
||||
@unlink($db_filename.'.lck');
|
||||
require_once __DIR__ .'/dba_handler.inc';
|
||||
set_up_db($handler, $db_name);
|
||||
run_standard_tests($handler, $db_name);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$db_filename = $db_file = __DIR__ .'/test0.tch';
|
||||
@unlink($db_filename);
|
||||
@unlink($db_filename.'.lck');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
$db_name = 'dba_tcadb.tch';
|
||||
cleanup_standard_db($db_name);
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: tcadb
|
||||
3NYNYY
|
||||
Content String 2
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
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
|
||||
"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"]=>
|
||||
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) {
|
||||
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 DB LOCK (default) ===
|
||||
SAME OUTPUT AS PREVIOUS RUN
|
||||
=== RUNNING WITH NO LOCK ===
|
||||
SAME OUTPUT AS PREVIOUS RUN
|
||||
|
|
179
ext/dba/tests/dba_tcadb_creation_matrix.phpt
Normal file
179
ext/dba/tests/dba_tcadb_creation_matrix.phpt
Normal 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
|
|
@ -4,15 +4,15 @@ DBA dba.default_handler tests
|
|||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = "flatfile";
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
require_once __DIR__ . '/setup/setup_dba_tests.inc';
|
||||
check_skip('flatfile');
|
||||
?>
|
||||
--INI--
|
||||
dba.default_handler=flatfile
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = "flatfile";
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
$db_filename = 'ini_test_default_handler.db';
|
||||
echo "database handler: $handler\n";
|
||||
|
||||
echo "Test 1\n";
|
||||
|
@ -30,15 +30,17 @@ var_dump(dba_open($db_filename, 'n'));
|
|||
?>
|
||||
--CLEAN--
|
||||
<?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--
|
||||
database handler: flatfile
|
||||
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)
|
||||
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)
|
297
ext/dba/tests/setup/setup_dba_tests.inc
Normal file
297
ext/dba/tests/setup/setup_dba_tests.inc
Normal 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');
|
||||
}
|
|
@ -116,7 +116,7 @@ database handler: flatfile
|
|||
resource(%d) of type (dba)
|
||||
=== 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)
|
||||
dba_open(): Argument #1 ($path) 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
|
||||
=== 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)
|
||||
dba_popen(): Argument #1 ($path) cannot be empty
|
||||
dba_popen(): Argument #2 ($mode) cannot be empty
|
|
@ -5,7 +5,8 @@ dba
|
|||
pgsql
|
||||
--SKIPIF--
|
||||
<?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');
|
||||
?>
|
||||
--FILE--
|
||||
|
@ -18,46 +19,65 @@ if (!$dbh) {
|
|||
}
|
||||
pg_close($dbh);
|
||||
|
||||
require_once(__DIR__.'/../../dba/tests/test.inc');
|
||||
require_once(__DIR__.'/../../dba/tests/dba_handler.inc');
|
||||
require_once dirname(__DIR__, 2) . '/dba/tests/setup/setup_dba_tests.inc';
|
||||
$name = 'bug14383.db';
|
||||
|
||||
$handler = get_any_handler($name);
|
||||
run_standard_tests($handler, $name);
|
||||
?>
|
||||
--CLEAN--
|
||||
<?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--
|
||||
database handler: %s
|
||||
3NYNYY
|
||||
Content String 2
|
||||
Content 2 replaced
|
||||
Read during write:%sallowed
|
||||
"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"]=>
|
||||
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
|
||||
Using handler: "%s"
|
||||
=== RUNNING WITH FILE LOCK ===
|
||||
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
|
||||
"key number 6" written
|
||||
Failed to write "key number 6" 2nd time
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
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 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue