summaryrefslogtreecommitdiff
path: root/ext/dbase/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dbase/tests')
-rw-r--r--ext/dbase/tests/001.phpt61
-rw-r--r--ext/dbase/tests/002.phpt54
2 files changed, 115 insertions, 0 deletions
diff --git a/ext/dbase/tests/001.phpt b/ext/dbase/tests/001.phpt
new file mode 100644
index 000000000..51a448870
--- /dev/null
+++ b/ext/dbase/tests/001.phpt
@@ -0,0 +1,61 @@
+--TEST--
+dbase_create() tests
+--SKIPIF--
+<?php if (!extension_loaded("dbase")) print "skip"; ?>
+--FILE--
+<?php
+
+$fields_arr = Array(
+ Array(
+ array('date','D'),
+ ),
+ Array(
+ array('error', 'E'),
+ ),
+ Array(
+ array('error', -1),
+ ),
+ Array(
+ array(-1, 'N', 3, 0),
+ ),
+ Array(
+ array(),
+ ),
+ Array(
+ ),
+);
+
+$file = dirname(__FILE__).'/001.dbf';
+
+foreach ($fields_arr as $fields) {
+ var_dump(dbase_create($file, $fields));
+ @unlink($file);
+}
+
+var_dump(dbase_create($file, -1));
+@unlink($file);
+
+var_dump(dbase_create("", ""));
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(%d)
+
+Warning: dbase_create(): unknown field type 'E' in %s on line %d
+bool(false)
+
+Warning: dbase_create(): unknown field type '-' in %s on line %d
+bool(false)
+int(%d)
+
+Warning: dbase_create(): expected field name as first element of list in field 0 in %s on line %d
+bool(false)
+int(%d)
+
+Warning: dbase_create(): Expected array as second parameter in %s on line %d
+bool(false)
+
+Warning: dbase_create(): Expected array as second parameter in %s on line %d
+bool(false)
+Done
diff --git a/ext/dbase/tests/002.phpt b/ext/dbase/tests/002.phpt
new file mode 100644
index 000000000..5c866443f
--- /dev/null
+++ b/ext/dbase/tests/002.phpt
@@ -0,0 +1,54 @@
+--TEST--
+dbase_open() tests
+--SKIPIF--
+<?php if (!extension_loaded("dbase")) print "skip"; ?>
+--FILE--
+<?php
+
+$file = dirname(__FILE__)."/002.dbf";
+@unlink($file);
+
+$fp = fopen($file, "w");
+fclose($fp);
+
+var_dump(dbase_open($file, -1));
+var_dump(dbase_open($file, 1000));
+var_dump(dbase_open($file, 0));
+var_dump(dbase_open($file."nonex", 0));
+var_dump(dbase_open("", 0));
+
+@unlink($file);
+
+$def = array(
+ array("date", "D"),
+ array("name", "C", 50),
+ array("age", "N", 3, 0),
+ array("email", "C", 128),
+ array("ismember", "L")
+);
+
+var_dump(dbase_create($file, $def));
+var_dump(dbase_open($file, 0));
+
+@unlink($file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: dbase_open(): Invalid access mode -1 in %s on line %d
+bool(false)
+
+Warning: dbase_open(): unable to open database %s in %s on line %d
+bool(false)
+
+Warning: dbase_open(): unable to open database %s in %s on line %d
+bool(false)
+
+Warning: dbase_open(): unable to open database %s in %s on line %d
+bool(false)
+
+Warning: dbase_open(): unable to open database in %s on line %d
+bool(false)
+int(%d)
+int(%d)
+Done