diff options
| author | Christopher Jones <sixd@php.net> | 2010-03-05 00:23:26 +0000 |
|---|---|---|
| committer | Christopher Jones <sixd@php.net> | 2010-03-05 00:23:26 +0000 |
| commit | 7b329d5afccd36a66100b9940a750d2ca9297027 (patch) | |
| tree | 38d34f64844bfc5c8e2d682fd10bf3fb7441dcca | |
| parent | 4db5175f54d4f7a47fef067a285fd867ab495315 (diff) | |
| download | php-git-7b329d5afccd36a66100b9940a750d2ca9297027.tar.gz | |
DBA tests: cleanup and sycn. Add new Berkeley DB 4 tests
40 files changed, 962 insertions, 51 deletions
diff --git a/ext/dba/tests/bug36436.phpt b/ext/dba/tests/bug36436.phpt index 4e8daa8600..19254df3c7 100755 --- a/ext/dba/tests/bug36436.phpt +++ b/ext/dba/tests/bug36436.phpt @@ -3,13 +3,13 @@ Bug #36436 (DBA problem with Berkeley DB4) --SKIPIF-- <?php $handler = 'db4'; - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); ?> --FILE-- <?php $handler = 'db4'; -require_once dirname(__FILE__) .'/test.inc'; +require_once(dirname(__FILE__) .'/test.inc'); $db = dba_popen($db_filename, 'c', 'db4'); @@ -22,10 +22,13 @@ var_dump(dba_firstkey($db)); var_dump(dba_nextkey($db)); dba_close($db); -unlink($db_filename); ?> ===DONE=== +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- resource(%d) of type (dba persistent) string(3) "XYZ" diff --git a/ext/dba/tests/bug38698.phpt b/ext/dba/tests/bug38698.phpt new file mode 100755 index 0000000000..56dde85268 --- /dev/null +++ b/ext/dba/tests/bug38698.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #38698 (Bug #38698 for some keys cdbmake creates corrupted db and cdb can't read valid db) +--SKIPIF-- +<?php + $handler = 'cdb_make'; + require_once(dirname(__FILE__) .'/skipif.inc'); +?> +--FILE-- +<?php + +$db_file = dirname(__FILE__) .'/129php.cdb'; + +if (($db_make=dba_open($db_file, "n", 'cdb_make'))!==FALSE) { + dba_insert(pack('i',129), "Booo!", $db_make); + dba_close($db_make); + // write md5 checksum of generated database file + var_dump(md5_file($db_file)); + @unlink($db_file); +} else { + echo "Error creating database\n"; +} +?> +===DONE=== +--EXPECT-- +string(32) "1f34b74bde3744265acfc21e0f30af95" +===DONE=== diff --git a/ext/dba/tests/bug48240.phpt b/ext/dba/tests/bug48240.phpt index 27f8d95e6e..5a72073f36 100644 --- a/ext/dba/tests/bug48240.phpt +++ b/ext/dba/tests/bug48240.phpt @@ -3,23 +3,26 @@ Bug #48240 (DBA Segmentation fault dba_nextkey) --SKIPIF-- <?php $handler = 'db4'; - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); ?> --FILE-- <?php $handler = 'db4'; -require_once dirname(__FILE__) .'/test.inc'; +require_once(dirname(__FILE__) .'/test.inc'); $db = dba_open($db_filename, 'c', 'db4'); var_dump(dba_nextkey($db)); dba_close($db); -unlink($db_filename); ?> ===DONE=== +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECT-- bool(false) ===DONE=== diff --git a/ext/dba/tests/bug49125.phpt b/ext/dba/tests/bug49125.phpt index 3724b89c93..e06495a109 100644 --- a/ext/dba/tests/bug49125.phpt +++ b/ext/dba/tests/bug49125.phpt @@ -3,7 +3,7 @@ Bug #49125 (Error in dba_exists C code) --SKIPIF-- <?php $handler = 'db4'; - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); ?> --FILE-- <?php @@ -11,7 +11,7 @@ Bug #49125 (Error in dba_exists C code) error_reporting(E_ALL); $handler = 'db4'; -require_once dirname(__FILE__) .'/test.inc'; +require_once(dirname(__FILE__) .'/test.inc'); $db = dba_popen($db_filename, 'c', 'db4'); @@ -21,7 +21,10 @@ var_dump(dba_exists('foo', $db)); dba_close($db); -unlink($db_filename); - +?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECT-- bool(true) diff --git a/ext/dba/tests/dba001.phpt b/ext/dba/tests/dba001.phpt index 00aec69697..b63829abbf 100644 --- a/ext/dba/tests/dba001.phpt +++ b/ext/dba/tests/dba001.phpt @@ -2,12 +2,12 @@ DBA File Creation Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { echo "database file created\n"; @@ -16,6 +16,10 @@ DBA File Creation Test echo "$db_file does not exist\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s database file created diff --git a/ext/dba/tests/dba002.phpt b/ext/dba/tests/dba002.phpt index 974b09fab8..e60e733603 100644 --- a/ext/dba/tests/dba002.phpt +++ b/ext/dba/tests/dba002.phpt @@ -2,12 +2,12 @@ DBA Insert/Fetch Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { dba_insert("key1", "This is a test insert", $db_file); @@ -17,6 +17,10 @@ DBA Insert/Fetch Test echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s This is a test insert diff --git a/ext/dba/tests/dba003.phpt b/ext/dba/tests/dba003.phpt index 832c7a0dc9..a027b5356e 100644 --- a/ext/dba/tests/dba003.phpt +++ b/ext/dba/tests/dba003.phpt @@ -2,12 +2,12 @@ DBA Insert/Replace/Fetch Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { dba_insert("key1", "This is a test insert", $db_file); @@ -19,6 +19,10 @@ DBA Insert/Replace/Fetch Test echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s This is the replacement text diff --git a/ext/dba/tests/dba004.phpt b/ext/dba/tests/dba004.phpt index 42da1c64b9..6e7180cf66 100644 --- a/ext/dba/tests/dba004.phpt +++ b/ext/dba/tests/dba004.phpt @@ -2,12 +2,12 @@ DBA Multiple Insert/Fetch Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { dba_insert("key1", "Content String 1", $db_file); @@ -23,6 +23,10 @@ DBA Multiple Insert/Fetch Test echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s Another Content String Content String 2 diff --git a/ext/dba/tests/dba005.phpt b/ext/dba/tests/dba005.phpt index 3e7e58086e..68ad600220 100644 --- a/ext/dba/tests/dba005.phpt +++ b/ext/dba/tests/dba005.phpt @@ -2,12 +2,12 @@ DBA FirstKey/NextKey Loop Test With 5 Items --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { dba_insert("key1", "Content String 1", $db_file); @@ -30,6 +30,10 @@ DBA FirstKey/NextKey Loop Test With 5 Items echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s 5YYYYY diff --git a/ext/dba/tests/dba006.phpt b/ext/dba/tests/dba006.phpt index f6177b0b9c..a3fc738fac 100644 --- a/ext/dba/tests/dba006.phpt +++ b/ext/dba/tests/dba006.phpt @@ -2,12 +2,12 @@ DBA FirstKey/NextKey with 2 deletes --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { dba_insert("key1", "Content String 1", $db_file); @@ -32,6 +32,10 @@ DBA FirstKey/NextKey with 2 deletes echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s 3NYNYY diff --git a/ext/dba/tests/dba007.phpt b/ext/dba/tests/dba007.phpt index 0f30932fc4..2519fdc597 100644 --- a/ext/dba/tests/dba007.phpt +++ b/ext/dba/tests/dba007.phpt @@ -2,16 +2,16 @@ DBA Multiple File Creation Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); if (!function_exists('dba_list')) die('skip dba_list() not available'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; - $db_file1 = dirname(__FILE__).'/test1.dbm'; - $db_file2 = dirname(__FILE__).'/test2.dbm'; + $db_file1 = $db_filename1 = dirname(__FILE__).'/test1.dbm'; + $db_file2 = $db_filename2 = dirname(__FILE__).'/test2.dbm'; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { echo "database file created\n"; } else { @@ -29,6 +29,13 @@ DBA Multiple File Creation Test } var_dump(dba_list()); dba_close($db_file); + + @unlink($db_filename1); + @unlink($db_filename2); +?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); ?> --EXPECTF-- database handler: %s diff --git a/ext/dba/tests/dba008.phpt b/ext/dba/tests/dba008.phpt index 8fde8ff3f0..f7015d921f 100644 --- a/ext/dba/tests/dba008.phpt +++ b/ext/dba/tests/dba008.phpt @@ -2,12 +2,13 @@ DBA magic_quotes_runtime Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + die('skip, magic_quotes removed'); + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { ini_set('magic_quotes_runtime', 0); @@ -24,6 +25,10 @@ DBA magic_quotes_runtime Test echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s string(1) """ diff --git a/ext/dba/tests/dba009.phpt b/ext/dba/tests/dba009.phpt index b4d8308e89..698657b2a3 100755 --- a/ext/dba/tests/dba009.phpt +++ b/ext/dba/tests/dba009.phpt @@ -2,12 +2,12 @@ DBA dba_popen Test --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); print("info $HND handler used"); ?> --FILE-- <?php - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; if (($db=dba_popen($db_file, "n", $handler))!==FALSE) { echo "Opened\n"; @@ -24,6 +24,10 @@ DBA dba_popen Test echo dba_fetch("a", $db)."\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: %s Opened diff --git a/ext/dba/tests/dba010.phpt b/ext/dba/tests/dba010.phpt index 0a6e545ba7..c818373f1f 100644 --- a/ext/dba/tests/dba010.phpt +++ b/ext/dba/tests/dba010.phpt @@ -2,7 +2,7 @@ DBA with array keys --SKIPIF-- <?php - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die("info $HND handler used"); ?> --FILE-- @@ -28,14 +28,17 @@ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { 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"; } -require_once(dirname(__FILE__) .'/clean.inc'); - +?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); ?> --EXPECTF-- database handler: %s -6YYYYYY
\ No newline at end of file +6YYYYYY diff --git a/ext/dba/tests/dba_cdb.phpt b/ext/dba/tests/dba_cdb.phpt index 0b75596487..b9ef68f2be 100644 --- a/ext/dba/tests/dba_cdb.phpt +++ b/ext/dba/tests/dba_cdb.phpt @@ -3,16 +3,20 @@ DBA CDB handler test --SKIPIF-- <?php $handler = 'cdb'; - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die('info CDB does not support replace or delete'); ?> --FILE-- <?php $handler = 'cdb'; - require_once dirname(__FILE__) .'/test.inc'; - require_once dirname(__FILE__) .'/dba_handler.inc'; + require_once(dirname(__FILE__) .'/test.inc'); + require_once(dirname(__FILE__) .'/dba_handler.inc'); ?> ===DONE=== +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECT-- database handler: cdb 5YYYYY diff --git a/ext/dba/tests/dba_cdb_make.phpt b/ext/dba/tests/dba_cdb_make.phpt index 6691d0a286..c1d0a01886 100644 --- a/ext/dba/tests/dba_cdb_make.phpt +++ b/ext/dba/tests/dba_cdb_make.phpt @@ -5,13 +5,13 @@ magic_quotes_runtime=1 --SKIPIF-- <?php $handler = 'cdb_make'; - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); die('info CDB_MAKE does not support reading'); ?> --FILE-- <?php $handler = 'cdb_make'; - require_once dirname(__FILE__) .'/test.inc'; + require_once(dirname(__FILE__) .'/test.inc'); echo "database handler: $handler\n"; // print md5 checksum of test.cdb which is generated by cdb_make program var_dump(md5_file(dirname(__FILE__).'/test.cdb')); @@ -32,6 +32,10 @@ magic_quotes_runtime=1 echo "Error creating database\n"; } ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECT-- Warning: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0 database handler: cdb_make diff --git a/ext/dba/tests/dba_db4.phpt b/ext/dba/tests/dba_db4_000.phpt index 2c2a7a6945..bbbc52c9f1 100644 --- a/ext/dba/tests/dba_db4.phpt +++ b/ext/dba/tests/dba_db4_000.phpt @@ -2,16 +2,20 @@ DBA DB4 handler test --SKIPIF-- <?php - $handler = 'db4'; - require_once dirname(__FILE__) .'/skipif.inc'; +$handler = 'db4'; +require_once(dirname(__FILE__) .'/skipif.inc'); ?> --FILE-- <?php - $handler = 'db4'; - require_once dirname(__FILE__) .'/test.inc'; - require_once dirname(__FILE__) .'/dba_handler.inc'; +$handler = 'db4'; +require_once(dirname(__FILE__) .'/test.inc'); +require_once(dirname(__FILE__) .'/dba_handler.inc'); ?> ===DONE=== +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECT-- database handler: db4 3NYNYY diff --git a/ext/dba/tests/dba_db4_001.phpt b/ext/dba/tests/dba_db4_001.phpt new file mode 100644 index 0000000000..ecc8389cb1 --- /dev/null +++ b/ext/dba/tests/dba_db4_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +DBA DB4 New File Creation open("c") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) { + echo "database file created\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +This is a test insert diff --git a/ext/dba/tests/dba_db4_002.phpt b/ext/dba/tests/dba_db4_002.phpt new file mode 100644 index 0000000000..18ac0ec461 --- /dev/null +++ b/ext/dba/tests/dba_db4_002.phpt @@ -0,0 +1,32 @@ +--TEST-- +DBA DB4 New File Creation open("n") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file = dba_open($db_filename, "n", $handler)) !== FALSE) { + echo "database file created\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +This is a test insert diff --git a/ext/dba/tests/dba_db4_003.phpt b/ext/dba/tests/dba_db4_003.phpt new file mode 100644 index 0000000000..084bff8d87 --- /dev/null +++ b/ext/dba/tests/dba_db4_003.phpt @@ -0,0 +1,41 @@ +--TEST-- +DBA DB4 File Creation open("c") with existing file +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +var_dump(file_put_contents($db_filename, "Dummy contents")); + +if (($db_file = dba_open($db_filename, "c", $handler)) !== FALSE) { + if (file_exists($db_filename)) { + echo "database file created\n"; + dba_close($db_file); + } else { + echo "File did not get created\n"; + } +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +int(14) + +Notice: dba_open(): %stest0.dbm: unexpected file type or format in %sdba_db4_003.php on line %d + +Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_003.php on line %d +Error creating %stest0.dbm diff --git a/ext/dba/tests/dba_db4_004.phpt b/ext/dba/tests/dba_db4_004.phpt new file mode 100644 index 0000000000..ca876f82d7 --- /dev/null +++ b/ext/dba/tests/dba_db4_004.phpt @@ -0,0 +1,40 @@ +--TEST-- +DBA DB4 Truncate Existing File open("n") +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +var_dump(file_put_contents($db_filename, "Dummy contents")); + +if (($db_file = dba_open($db_filename, "n", $handler)) !== FALSE) { + if (file_exists($db_filename)) { + echo "database file created\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); + } else { + echo "File did not get created\n"; + } +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +int(14) +database file created +This is a test insert diff --git a/ext/dba/tests/dba_db4_005.phpt b/ext/dba/tests/dba_db4_005.phpt new file mode 100644 index 0000000000..54bb475e9e --- /dev/null +++ b/ext/dba/tests/dba_db4_005.phpt @@ -0,0 +1,32 @@ +--TEST-- +DBA DB4 New File Creation popen("c") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) { + echo "database file created\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +This is a test insert diff --git a/ext/dba/tests/dba_db4_006.phpt b/ext/dba/tests/dba_db4_006.phpt new file mode 100644 index 0000000000..7d95385fe3 --- /dev/null +++ b/ext/dba/tests/dba_db4_006.phpt @@ -0,0 +1,32 @@ +--TEST-- +DBA DB4 New File Creation popen("n") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file = dba_popen($db_filename, "n", $handler)) !== FALSE) { + echo "database file created\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +This is a test insert diff --git a/ext/dba/tests/dba_db4_007.phpt b/ext/dba/tests/dba_db4_007.phpt new file mode 100644 index 0000000000..bd95e0bec7 --- /dev/null +++ b/ext/dba/tests/dba_db4_007.phpt @@ -0,0 +1,41 @@ +--TEST-- +DBA DB4 File Creation popen("c") with existing invalid file +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +var_dump(file_put_contents($db_filename, "Dummy contents")); + +if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) { + if (file_exists($db_filename)) { + echo "database file created\n"; + dba_close($db_file); + } else { + echo "File did not get created\n"; + } +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +int(14) + +Notice: dba_popen(): %stest0.dbm: unexpected file type or format in %sdba_db4_007.php on line %d + +Warning: dba_popen(%stest0.dbm,c): Driver initialization failed for handler: db4: Invalid argument in %sdba_db4_007.php on line %d +Error creating %stest0.dbm diff --git a/ext/dba/tests/dba_db4_008.phpt b/ext/dba/tests/dba_db4_008.phpt new file mode 100644 index 0000000000..80f62eab5b --- /dev/null +++ b/ext/dba/tests/dba_db4_008.phpt @@ -0,0 +1,40 @@ +--TEST-- +DBA DB4 Truncate Existing File popen("n") +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +var_dump(file_put_contents($db_filename, "Dummy contents")); + +if (($db_file = dba_popen($db_filename, "n", $handler)) !== FALSE) { + if (file_exists($db_filename)) { + echo "database file created\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); + } else { + echo "File did not get created\n"; + } +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +int(14) +database file created +This is a test insert diff --git a/ext/dba/tests/dba_db4_009.phpt b/ext/dba/tests/dba_db4_009.phpt new file mode 100644 index 0000000000..5a870c90ed --- /dev/null +++ b/ext/dba/tests/dba_db4_009.phpt @@ -0,0 +1,53 @@ +--TEST-- +DBA DB4 Multiple File Creation Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +$db_file1 = $db_filename1 = dirname(__FILE__).'/test1.dbm'; +$db_file2 = $db_filename2 = dirname(__FILE__).'/test2.dbm'; +if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + echo "database file created\n"; +} else { + echo "$db_file does not exist\n"; +} +if (($db_file1=dba_open($db_file1, "n", $handler))!==FALSE) { + echo "database file created\n"; +} else { + echo "$db_file does not exist\n"; +} +if (($db_file2=dba_open($db_file2, "n", $handler))!==FALSE) { + echo "database file created\n"; +} else { + echo "$db_file does not exist\n"; +} +var_dump(dba_list()); +dba_close($db_file); + +@unlink($db_filename1); +@unlink($db_filename2); +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +database file created +database file created +array(3) { + [%d]=> + string(%d) "%stest0.dbm" + [%d]=> + string(%d) "%stest1.dbm" + [%d]=> + string(%d) "%stest2.dbm" +} diff --git a/ext/dba/tests/dba_db4_010.phpt b/ext/dba/tests/dba_db4_010.phpt new file mode 100644 index 0000000000..fb31f05835 --- /dev/null +++ b/ext/dba/tests/dba_db4_010.phpt @@ -0,0 +1,38 @@ +--TEST-- +DBA DB4 magic_quotes_runtime Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + ini_set('magic_quotes_runtime', 0); + dba_insert("key1", '"', $db_file); + var_dump(dba_fetch("key1", $db_file)); + ini_set('magic_quotes_runtime', 1); + var_dump(dba_fetch("key1", $db_file)); + dba_replace("key1", '\"', $db_file); + var_dump(dba_fetch("key1", $db_file)); + ini_set('magic_quotes_runtime', 0); + var_dump(dba_fetch("key1", $db_file)); + dba_close($db_file); +} else { + echo "Error creating database\n"; +} +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +string(1) """ +string(2) "\"" +string(2) "\"" +string(1) """ diff --git a/ext/dba/tests/dba_db4_011.phpt b/ext/dba/tests/dba_db4_011.phpt new file mode 100644 index 0000000000..ce9be2770b --- /dev/null +++ b/ext/dba/tests/dba_db4_011.phpt @@ -0,0 +1,36 @@ +--TEST-- +DBA DB4 with repeated key +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file=dba_open($db_filename, "c", $handler))!==FALSE) { + var_dump(dba_insert("key1", "Content String 1", $db_file)); + var_dump(dba_insert("key2", "Content String 2", $db_file)); + var_dump(dba_insert("key2", "Same key", $db_file)); + echo dba_fetch("key1", $db_file), "\n"; + echo dba_fetch("key2", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating database\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +bool(true) +bool(true) +bool(false) +Content String 1 +Content String 2 diff --git a/ext/dba/tests/dba_db4_012.phpt b/ext/dba/tests/dba_db4_012.phpt new file mode 100644 index 0000000000..2caa43c84f --- /dev/null +++ b/ext/dba/tests/dba_db4_012.phpt @@ -0,0 +1,31 @@ +--TEST-- +DBA DB4 New File Creation open("rl") +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file = dba_open($db_filename, "rl", $handler)) !== FALSE) { + echo "database file created\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 + +Warning: dba_open(%stest0.dbm,rl): Driver initialization failed for handler: db4: No such file or directory in %sdba_db4_012.php on line %d +Error creating %stest0.dbm diff --git a/ext/dba/tests/dba_db4_013.phpt b/ext/dba/tests/dba_db4_013.phpt new file mode 100644 index 0000000000..ba2d171dcf --- /dev/null +++ b/ext/dba/tests/dba_db4_013.phpt @@ -0,0 +1,40 @@ +--TEST-- +DBA DB4 File open("rl") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) { + echo "database file created\n"; + dba_close($db_file); +} + +if (($db_file = dba_popen($db_filename, "rl", $handler)) !== FALSE) { + echo "database file opened\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +database file opened + +Warning: dba_insert(): You cannot perform a modification to a database without proper access in %sdba_db4_013.php on line %d diff --git a/ext/dba/tests/dba_db4_014.phpt b/ext/dba/tests/dba_db4_014.phpt new file mode 100644 index 0000000000..6fb22f87b3 --- /dev/null +++ b/ext/dba/tests/dba_db4_014.phpt @@ -0,0 +1,32 @@ +--TEST-- +DBA DB4 File open("wl") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +if (($db_file = dba_open($db_filename, "wl", $handler)) !== FALSE) { + echo "database file opened\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 + +Warning: dba_open(%stest0.dbm,wl): Driver initialization failed for handler: db4: No such file or directory in %sdba_db4_014.php on line %d +Error creating %stest0.dbm diff --git a/ext/dba/tests/dba_db4_015.phpt b/ext/dba/tests/dba_db4_015.phpt new file mode 100644 index 0000000000..a1535675b8 --- /dev/null +++ b/ext/dba/tests/dba_db4_015.phpt @@ -0,0 +1,39 @@ +--TEST-- +DBA DB4 File open("wl") & Insert Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) { + echo "database file created\n"; + dba_close($db_file); +} + +if (($db_file = dba_popen($db_filename, "wl", $handler)) !== FALSE) { + echo "database file opened\n"; + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +database file opened +This is a test insert diff --git a/ext/dba/tests/dba_db4_016.phpt b/ext/dba/tests/dba_db4_016.phpt new file mode 100644 index 0000000000..b79cc71f82 --- /dev/null +++ b/ext/dba/tests/dba_db4_016.phpt @@ -0,0 +1,59 @@ +--TEST-- +DBA DB4 File Creation popen("c") with existing valid file +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php + +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) { + if (file_exists($db_filename)) { + echo "database file created\n"; + var_dump(dba_insert("key1", "This is a test insert", $db_file)); + echo dba_fetch("key1", $db_file), "\n"; + dba_close($db_file); + } else { + echo "File did not get created\n"; + } +} else { + echo "Error creating $db_filename\n"; +} + +// Now test reopening it +if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) { + if (file_exists($db_filename)) { + echo "database file created\n"; + var_dump(dba_insert("key1", "second open test", $db_file)); + var_dump(dba_insert("key2", "second open test row 2", $db_file)); + echo dba_fetch("key1", $db_file), "\n"; + echo dba_fetch("key2", $db_file), "\n"; + dba_close($db_file); + } else { + echo "File did not get created\n"; + } +} else { + echo "Error creating $db_filename\n"; +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +database file created +bool(true) +This is a test insert +database file created +bool(false) +bool(true) +This is a test insert +second open test row 2 diff --git a/ext/dba/tests/dba_db4_handlers.phpt b/ext/dba/tests/dba_db4_handlers.phpt new file mode 100644 index 0000000000..f755a9807a --- /dev/null +++ b/ext/dba/tests/dba_db4_handlers.phpt @@ -0,0 +1,50 @@ +--TEST-- +DBA DB4 Handler Test +--SKIPIF-- +<?php +$handler="db4"; +require(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler="db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +function check($h) +{ + if (!$h) { + return; + } + + foreach ($h as $key) { + if ($key === "db4") { + echo "Success: db4 enabled\n"; + } + } +} + +echo "Test 1\n"; + +check(dba_handlers()); + +echo "Test 2 - full info\n"; +$h = dba_handlers(1); +foreach ($h as $key => $val) { + if ($key === "db4") { + echo "$val\n"; + } +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +Test 1 +Success: db4 enabled +Test 2 - full info +Berkeley DB 4.%s diff --git a/ext/dba/tests/dba_db4_optimize.phpt b/ext/dba/tests/dba_db4_optimize.phpt new file mode 100644 index 0000000000..de27dd8df4 --- /dev/null +++ b/ext/dba/tests/dba_db4_optimize.phpt @@ -0,0 +1,38 @@ +--TEST-- +DBA DB4 Optimize Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) { + dba_insert("key1", "Content String 1", $db_file); + dba_insert("key2", "Content String 2", $db_file); + for ($i=1; $i<3; $i++) { + echo dba_exists("key$i", $db_file) ? "Y" : "N"; + } + echo "\n"; + var_dump(dba_optimize($db_file)); + dba_close($db_file); +} else { + echo "Error creating database\n"; +} + +?> +===DONE=== +<?php exit(0); ?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +YY +bool(true) +===DONE=== diff --git a/ext/dba/tests/dba_db4_sync.phpt b/ext/dba/tests/dba_db4_sync.phpt new file mode 100644 index 0000000000..8c4e248bc8 --- /dev/null +++ b/ext/dba/tests/dba_db4_sync.phpt @@ -0,0 +1,38 @@ +--TEST-- +DBA DB4 Sync Test +--SKIPIF-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler = "db4"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; +if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) { + dba_insert("key1", "Content String 1", $db_file); + dba_insert("key2", "Content String 2", $db_file); + for ($i=1; $i<3; $i++) { + echo dba_exists("key$i", $db_file) ? "Y" : "N"; + } + echo "\n"; + var_dump(dba_sync($db_file)); + dba_close($db_file); +} else { + echo "Error creating database\n"; +} + +?> +===DONE=== +<?php exit(0); ?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: db4 +YY +bool(true) +===DONE=== diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt index a85472bbeb..8e1ca6a933 100644 --- a/ext/dba/tests/dba_flatfile.phpt +++ b/ext/dba/tests/dba_flatfile.phpt @@ -3,15 +3,19 @@ DBA FlatFile handler test --SKIPIF-- <?php $handler = 'flatfile'; - require_once dirname(__FILE__) .'/skipif.inc'; + require_once(dirname(__FILE__) .'/skipif.inc'); ?> --FILE-- <?php $handler = 'flatfile'; - require_once dirname(__FILE__) .'/test.inc'; - require_once dirname(__FILE__) .'/dba_handler.inc'; + require_once(dirname(__FILE__) .'/test.inc'); + require_once(dirname(__FILE__) .'/dba_handler.inc'); ?> ===DONE=== +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECT-- database handler: flatfile 3NYNYY diff --git a/ext/dba/tests/dba_handlers.phpt b/ext/dba/tests/dba_handlers.phpt new file mode 100644 index 0000000000..9f66a79f27 --- /dev/null +++ b/ext/dba/tests/dba_handlers.phpt @@ -0,0 +1,69 @@ +--TEST-- +DBA Handler Test +--SKIPIF-- +<?php +$handler="flatfile"; +require(dirname(__FILE__) .'/skipif.inc'); +die("info $HND handler used"); +?> +--FILE-- +<?php +$handler="flatfile"; +require_once(dirname(__FILE__) .'/test.inc'); +echo "database handler: $handler\n"; + +function check($h) +{ + if (!$h) { + return; + } + + foreach ($h as $key) { + if ($key === "flatfile") { + echo "Success: flatfile enabled\n"; + } + } +} + +echo "Test 1\n"; + +check(dba_handlers()); + +echo "Test 2\n"; + +check(dba_handlers(null)); + +echo "Test 3\n"; + +check(dba_handlers(1, 2)); + +echo "Test 4\n"; + +check(dba_handlers(0)); + +echo "Test 5 - full info\n"; +$h = dba_handlers(1); +foreach ($h as $key => $val) { + if ($key === "flatfile") { + echo "Success: flatfile enabled\n"; + } +} + +?> +--CLEAN-- +<?php +require(dirname(__FILE__) .'/clean.inc'); +?> +--EXPECTF-- +database handler: flatfile +Test 1 +Success: flatfile enabled +Test 2 +Success: flatfile enabled +Test 3 + +Warning: dba_handlers() expects at most 1 parameter, 2 given in %sdba_handlers.php on line %d +Test 4 +Success: flatfile enabled +Test 5 - full info +Success: flatfile enabled diff --git a/ext/dba/tests/dba_optimize.phpt b/ext/dba/tests/dba_optimize.phpt index cbbf135620..794d7e8f79 100644 --- a/ext/dba/tests/dba_optimize.phpt +++ b/ext/dba/tests/dba_optimize.phpt @@ -31,11 +31,13 @@ if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) { echo "Error creating database\n"; } -require_once(dirname(__FILE__) .'/clean.inc'); - ?> ===DONE=== <?php exit(0); ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: flatfile 2YY diff --git a/ext/dba/tests/dba_sync.phpt b/ext/dba/tests/dba_sync.phpt index 2234b3d520..e0906eeeef 100644 --- a/ext/dba/tests/dba_sync.phpt +++ b/ext/dba/tests/dba_sync.phpt @@ -31,11 +31,13 @@ if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) { echo "Error creating database\n"; } -require_once(dirname(__FILE__) .'/clean.inc'); - ?> ===DONE=== <?php exit(0); ?> +--CLEAN-- +<?php + require(dirname(__FILE__) .'/clean.inc'); +?> --EXPECTF-- database handler: flatfile 2YY |
