diff options
| author | Marcus Boerger <helly@php.net> | 2002-10-25 09:42:29 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2002-10-25 09:42:29 +0000 |
| commit | a707e77a1b9d57fdd8bce556aeba7e8fadfa543a (patch) | |
| tree | e2bb252696ddac0cb92ad56fda5753449ea40975 /ext/dba/tests | |
| parent | 36447ebe050ac0891d90d3ebff099b8c960094ac (diff) | |
| download | php-git-a707e77a1b9d57fdd8bce556aeba7e8fadfa543a.tar.gz | |
Added some tests for dba extension
Diffstat (limited to 'ext/dba/tests')
| -rw-r--r-- | ext/dba/tests/001.phpt | 18 | ||||
| -rw-r--r-- | ext/dba/tests/002.phpt | 19 | ||||
| -rw-r--r-- | ext/dba/tests/003.phpt | 21 | ||||
| -rw-r--r-- | ext/dba/tests/004.phpt | 25 | ||||
| -rw-r--r-- | ext/dba/tests/005.phpt | 32 | ||||
| -rw-r--r-- | ext/dba/tests/006.phpt | 34 | ||||
| -rw-r--r-- | ext/dba/tests/skipif.inc | 5 | ||||
| -rw-r--r-- | ext/dba/tests/test.inc | 5 |
8 files changed, 159 insertions, 0 deletions
diff --git a/ext/dba/tests/001.phpt b/ext/dba/tests/001.phpt new file mode 100644 index 0000000000..909f78214d --- /dev/null +++ b/ext/dba/tests/001.phpt @@ -0,0 +1,18 @@ +--TEST-- +DBA File Creation Test +--SKIPIF-- +<?php + require_once('skipif.inc'); +?> +--FILE-- +<?php + require_once('test.inc'); + if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + echo "database file created with $handler.\n"; + } else { + echo "$db_file does not exist\n"; + } + dba_close($db_file); +?> +--EXPECTF-- +database file created with %s.
\ No newline at end of file diff --git a/ext/dba/tests/002.phpt b/ext/dba/tests/002.phpt new file mode 100644 index 0000000000..d2fd7d012c --- /dev/null +++ b/ext/dba/tests/002.phpt @@ -0,0 +1,19 @@ +--TEST-- +DBA Insert/Fetch Test +--SKIPIF-- +<?php + require_once('skipif.inc'); +?> +--FILE-- +<?php + require_once('test.inc'); + if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + dba_insert("key1", "This is a test insert", $db_file); + echo dba_fetch("key1", $db_file); + dba_close($db_file); + } else { + echo "Error creating database\n"; + } +?> +--EXPECT-- +This is a test insert diff --git a/ext/dba/tests/003.phpt b/ext/dba/tests/003.phpt new file mode 100644 index 0000000000..64225a8329 --- /dev/null +++ b/ext/dba/tests/003.phpt @@ -0,0 +1,21 @@ +--TEST-- +DBA Insert/Replace/Fetch Test +--SKIPIF-- +<?php + require_once('skipif.inc'); +?> +--FILE-- +<?php + require_once('test.inc'); + if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + dba_insert("key1", "This is a test insert", $db_file); + dba_replace("key1", "This is the replacement text", $db_file); + $a = dba_fetch("key1", $db_file); + dba_close($db_file); + echo $a; + } else { + echo "Error creating database\n"; + } +?> +--EXPECT-- +This is the replacement text diff --git a/ext/dba/tests/004.phpt b/ext/dba/tests/004.phpt new file mode 100644 index 0000000000..9259a78d57 --- /dev/null +++ b/ext/dba/tests/004.phpt @@ -0,0 +1,25 @@ +--TEST-- +DBA Multiple Insert/Fetch Test +--SKIPIF-- +<?php + require_once('skipif.inc'); +?> +--FILE-- +<?php + require_once('test.inc'); + if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + dba_insert("key1", "Content String 1", $db_file); + dba_insert("key2", "Content String 2", $db_file); + dba_insert("key3", "Third Content String", $db_file); + dba_insert("key4", "Another Content String", $db_file); + dba_insert("key5", "The last content string", $db_file); + $a = dba_fetch("key4", $db_file); + $b = dba_fetch("key2", $db_file); + dba_close($db_file); + echo "$a $b"; + } else { + echo "Error creating database\n"; + } +?> +--EXPECT-- +Another Content String Content String 2 diff --git a/ext/dba/tests/005.phpt b/ext/dba/tests/005.phpt new file mode 100644 index 0000000000..98b1d9e7e9 --- /dev/null +++ b/ext/dba/tests/005.phpt @@ -0,0 +1,32 @@ +--TEST-- +DBA FirstKey/NextKey Loop Test With 5 Items +--SKIPIF-- +<?php + require_once('skipif.inc'); +?> +--FILE-- +<?php + require_once('test.inc'); + if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + dba_insert("key1", "Content String 1", $db_file); + dba_insert("key2", "Content String 2", $db_file); + dba_insert("key3", "Third Content String", $db_file); + dba_insert("key4", "Another Content String", $db_file); + dba_insert("key5", "The last content string", $db_file); + $a = dba_firstkey($db_file); + $i=0; + while($a) { + $a = dba_nextkey($db_file); + $i++; + } + echo $i; + for ($i=1; $i<6; $i++) { + echo dba_exists("key$i", $db_file) ? "Y" : "N"; + } + dba_close($db_file); + } else { + echo "Error creating database\n"; + } +?> +--EXPECT-- +5YYYYY diff --git a/ext/dba/tests/006.phpt b/ext/dba/tests/006.phpt new file mode 100644 index 0000000000..5d9882a1b0 --- /dev/null +++ b/ext/dba/tests/006.phpt @@ -0,0 +1,34 @@ +--TEST-- +DBA FirstKey/NextKey with 2 deletes +--SKIPIF-- +<?php + require_once('skipif.inc'); +?> +--FILE-- +<?php + require_once('test.inc'); + if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) { + dba_insert("key1", "Content String 1", $db_file); + dba_insert("key2", "Content String 2", $db_file); + dba_insert("key3", "Third Content String", $db_file); + dba_insert("key4", "Another Content String", $db_file); + dba_insert("key5", "The last content string", $db_file); + dba_delete("key3", $db_file); + dba_delete("key1", $db_file); + $a = dba_firstkey($db_file); + $i=0; + while($a) { + $a = dba_nextkey($db_file); + $i++; + } + echo $i; + for ($i=1; $i<6; $i++) { + echo dba_exists("key$i", $db_file) ? "Y" : "N"; + } + dba_close($db_file); + } else { + echo "Error creating database\n"; + } +?> +--EXPECT-- +3NYNYY
\ No newline at end of file diff --git a/ext/dba/tests/skipif.inc b/ext/dba/tests/skipif.inc new file mode 100644 index 0000000000..9a35e1e06b --- /dev/null +++ b/ext/dba/tests/skipif.inc @@ -0,0 +1,5 @@ +<?php + if (!extension_loaded('dba')) die('skip dba extension not available'); + if (!function_exists('dba_handlers')) die ('skip dba_handlers() not available'); + if (!sizeof(dba_handlers())) die('skip no handlers installed'); +?> diff --git a/ext/dba/tests/test.inc b/ext/dba/tests/test.inc new file mode 100644 index 0000000000..30bc0c3a76 --- /dev/null +++ b/ext/dba/tests/test.inc @@ -0,0 +1,5 @@ +<?php + $db_file = dirname(__FILE__).'/test.dbm'; + $handler = dba_handlers(); + $handler = $handler[0]; +?> |
