summaryrefslogtreecommitdiff
path: root/ext/db
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-10-22 18:40:30 +0000
committerMarcus Boerger <helly@php.net>2002-10-22 18:40:30 +0000
commit376dcd80bb79b979c8d99c43d037e5ca5bdb9948 (patch)
tree7ac860d9ed45d3ab5f6d49b4e9afcbbddf491525 /ext/db
parentd8378f9edafbada8d74aea1183ad58a5389bafc0 (diff)
downloadphp-git-376dcd80bb79b979c8d99c43d037e5ca5bdb9948.tar.gz
Updated tests
Diffstat (limited to 'ext/db')
-rw-r--r--ext/db/tests/001.phpt13
-rw-r--r--ext/db/tests/002.phpt17
-rw-r--r--ext/db/tests/003.phpt18
-rw-r--r--ext/db/tests/004.phpt26
-rw-r--r--ext/db/tests/005.phpt32
-rw-r--r--ext/db/tests/006.phpt36
-rw-r--r--ext/db/tests/test.inc3
7 files changed, 80 insertions, 65 deletions
diff --git a/ext/db/tests/001.phpt b/ext/db/tests/001.phpt
index ea95d3d70a..a18e79a82b 100644
--- a/ext/db/tests/001.phpt
+++ b/ext/db/tests/001.phpt
@@ -2,12 +2,15 @@
DBM File Creation Test
--SKIPIF--
<?php if (!extension_loaded("db")) print "skip"; ?>
---POST--
---GET--
--FILE--
<?php
- dbmopen("./test.dbm","n");
- dbmclose("./test.dbm");
+ require_once('test.inc');
+ if (dbmopen($db_file, "n") && file_exists($db_file)) {
+ echo "database file created\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ dbmclose($db_file);
?>
--EXPECT--
-
+database file created \ No newline at end of file
diff --git a/ext/db/tests/002.phpt b/ext/db/tests/002.phpt
index d0bc710f08..3c797370c5 100644
--- a/ext/db/tests/002.phpt
+++ b/ext/db/tests/002.phpt
@@ -1,16 +1,17 @@
--TEST--
DBM Insert/Fetch Test
--SKIPIF--
-<?php if (!extension_loaded("db")) print "skip"; ?>
---POST--
---GET--
+<?php if (!extension_loaded("db")) print "skip";?>
--FILE--
<?php
- dbmopen("./test.dbm","n");
- dbminsert("./test.dbm","key1","This is a test insert");
- $a = dbmfetch("./test.dbm","key1");
- dbmclose("./test.dbm");
- echo $a
+ require_once('test.inc');
+ if (dbmopen($db_file, "n")) {
+ dbminsert($db_file, "key1", "This is a test insert");
+ echo dbmfetch($db_file, "key1");
+ dbmclose($db_file);
+ } else {
+ echo "Error creating database\n";
+ }
?>
--EXPECT--
This is a test insert
diff --git a/ext/db/tests/003.phpt b/ext/db/tests/003.phpt
index 319325c398..d2351e24a5 100644
--- a/ext/db/tests/003.phpt
+++ b/ext/db/tests/003.phpt
@@ -2,16 +2,18 @@
DBM Insert/Replace/Fetch Test
--SKIPIF--
<?php if (!extension_loaded("db")) print "skip"; ?>
---POST--
---GET--
--FILE--
<?php
- dbmopen("./test.dbm","n");
- dbminsert("./test.dbm","key1","This is a test insert");
- dbmreplace("./test.dbm","key1","This is the replacement text");
- $a = dbmfetch("./test.dbm","key1");
- dbmclose("./test.dbm");
- echo $a
+ require_once('test.inc');
+ if (dbmopen($db_file, "n")) {
+ dbminsert($db_file, "key1", "This is a test insert");
+ dbmreplace($db_file, "key1", "This is the replacement text");
+ $a = dbmfetch($db_file, "key1");
+ dbmclose($db_file);
+ echo $a;
+ } else {
+ echo "Error creating database\n";
+ }
?>
--EXPECT--
This is the replacement text
diff --git a/ext/db/tests/004.phpt b/ext/db/tests/004.phpt
index 1becfcfdcd..4c19a38fe6 100644
--- a/ext/db/tests/004.phpt
+++ b/ext/db/tests/004.phpt
@@ -2,20 +2,22 @@
DBM Multiple Insert/Fetch Test
--SKIPIF--
<?php if (!extension_loaded("db")) print "skip"; ?>
---POST--
---GET--
--FILE--
<?php
- dbmopen("./test.dbm","n");
- dbminsert("./test.dbm","key1","Content String 1");
- dbminsert("./test.dbm","key2","Content String 2");
- dbminsert("./test.dbm","key3","Third Content String");
- dbminsert("./test.dbm","key4","Another Content String");
- dbminsert("./test.dbm","key5","The last content string");
- $a = dbmfetch("./test.dbm","key4");
- $b = dbmfetch("./test.dbm","key2");
- dbmclose("./test.dbm");
- echo "$a $b";
+ require_once('test.inc');
+ if (dbmopen($db_file, "n")) {
+ dbminsert($db_file, "key1", "Content String 1");
+ dbminsert($db_file, "key2", "Content String 2");
+ dbminsert($db_file, "key3", "Third Content String");
+ dbminsert($db_file, "key4", "Another Content String");
+ dbminsert($db_file, "key5", "The last content string");
+ $a = dbmfetch($db_file, "key4");
+ $b = dbmfetch($db_file, "key2");
+ dbmclose($db_file);
+ echo "$a $b";
+ } else {
+ echo "Error creating database\n";
+ }
?>
--EXPECT--
Another Content String Content String 2
diff --git a/ext/db/tests/005.phpt b/ext/db/tests/005.phpt
index de33201883..6105f533d8 100644
--- a/ext/db/tests/005.phpt
+++ b/ext/db/tests/005.phpt
@@ -2,24 +2,26 @@
DBM FirstKey/NextKey Loop Test With 5 Items
--SKIPIF--
<?php if (!extension_loaded("db")) print "skip"; ?>
---POST--
---GET--
--FILE--
<?php
- dbmopen("./test.dbm","n");
- dbminsert("./test.dbm","key1","Content String 1");
- dbminsert("./test.dbm","key2","Content String 2");
- dbminsert("./test.dbm","key3","Third Content String");
- dbminsert("./test.dbm","key4","Another Content String");
- dbminsert("./test.dbm","key5","The last content string");
- $a = dbmfirstkey("./test.dbm");
- $i=0;
- while($a) {
- $a = dbmnextkey("./test.dbm",$a);
- $i++;
+ require_once('test.inc');
+ if (dbmopen($db_file, "n")) {
+ dbminsert($db_file, "key1", "Content String 1");
+ dbminsert($db_file, "key2", "Content String 2");
+ dbminsert($db_file, "key3", "Third Content String");
+ dbminsert($db_file, "key4", "Another Content String");
+ dbminsert($db_file, "key5", "The last content string");
+ $a = dbmfirstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dbmnextkey($db_file, $a);
+ $i++;
+ }
+ dbmclose($db_file);
+ echo $i;
+ } else {
+ echo "Error creating database\n";
}
- dbmclose("./test.dbm");
- echo $i
?>
--EXPECT--
5
diff --git a/ext/db/tests/006.phpt b/ext/db/tests/006.phpt
index 3428ce3948..c5ffd597ca 100644
--- a/ext/db/tests/006.phpt
+++ b/ext/db/tests/006.phpt
@@ -2,26 +2,28 @@
DBM FirstKey/NextKey with 2 deletes
--SKIPIF--
<?php if (!extension_loaded("db")) print "skip"; ?>
---POST--
---GET--
--FILE--
<?php
- dbmopen("./test.dbm","n");
- dbminsert("./test.dbm","key1","Content String 1");
- dbminsert("./test.dbm","key2","Content String 2");
- dbminsert("./test.dbm","key3","Third Content String");
- dbminsert("./test.dbm","key4","Another Content String");
- dbminsert("./test.dbm","key5","The last content string");
- dbmdelete("./test.dbm","key3");
- dbmdelete("./test.dbm","key1");
- $a = dbmfirstkey("./test.dbm");
- $i=0;
- while($a) {
- $a = dbmnextkey("./test.dbm",$a);
- $i++;
+ require_once('test.inc');
+ if (dbmopen($db_file, "n")) {
+ dbminsert($db_file, "key1", "Content String 1");
+ dbminsert($db_file, "key2", "Content String 2");
+ dbminsert($db_file, "key3", "Third Content String");
+ dbminsert($db_file, "key4", "Another Content String");
+ dbminsert($db_file, "key5", "The last content string");
+ dbmdelete($db_file, "key3");
+ dbmdelete($db_file, "key1");
+ $a = dbmfirstkey($db_file);
+ $i=0;
+ while($a) {
+ $a = dbmnextkey($db_file, $a);
+ $i++;
+ }
+ dbmclose($db_file);
+ echo $i;
+ } else {
+ echo "Error creating database\n";
}
- dbmclose("./test.dbm");
- echo $i
?>
--EXPECT--
3
diff --git a/ext/db/tests/test.inc b/ext/db/tests/test.inc
new file mode 100644
index 0000000000..1e384aa835
--- /dev/null
+++ b/ext/db/tests/test.inc
@@ -0,0 +1,3 @@
+<?php
+ $db_file = dirname(__FILE__).'/test.dbm';
+?>