]> granicus.if.org Git - php/commitdiff
First "real" test.
authorWez Furlong <wez@php.net>
Fri, 18 Apr 2003 19:22:49 +0000 (19:22 +0000)
committerWez Furlong <wez@php.net>
Fri, 18 Apr 2003 19:22:49 +0000 (19:22 +0000)
If anyone is motivated to write more tests, please do so.

ext/sqlite/tests/001.phpt
ext/sqlite/tests/blankdb.inc [new file with mode: 0644]

index ad723b8076667a6c4b2943cff0656438d5ffd7ad..7ebb8ce46564dbc5eaa8ffb40983332d7b751a27 100644 (file)
@@ -1,24 +1,29 @@
 --TEST--
-Check for sqlite presence
+sqlite: Simple insert/select
 --SKIPIF--
-<?php if (!extension_loaded("sqlite")) print "skip"; ?>
---POST--
---GET--
---INI--
+<?php # vim:ft=php
+if (!extension_loaded("sqlite")) print "skip"; ?>
 --FILE--
 <?php 
-echo "sqlite extension is available";
-/*
-       you can add regression tests for your extension here
+include "blankdb.inc";
 
-  the output of your test code has to be equal to the
-  text in the --EXPECT-- section below for the tests
-  to pass, differences between the output and the
-  expected text are interpreted as failure
-
-       see php4/README.TESTING for further information on
-  writing regression tests
-*/
+sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
+sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
+$r = sqlite_query("SELECT * from foo", $db);
+var_dump(sqlite_fetch_array($r));
 ?>
 --EXPECT--
-sqlite extension is available
+array(4) {
+  [0]=>
+  string(10) "2002-01-02"
+  ["c1"]=>
+  string(10) "2002-01-02"
+  [1]=>
+  string(8) "12:49:00"
+  ["c2"]=>
+  string(8) "12:49:00"
+  [2]=>
+  NULL
+  ["c3"]=>
+  NULL
+}
diff --git a/ext/sqlite/tests/blankdb.inc b/ext/sqlite/tests/blankdb.inc
new file mode 100644 (file)
index 0000000..45d9753
--- /dev/null
@@ -0,0 +1,9 @@
+<?php #vim:ft=php
+$dbname = tempnam("/tmp", "phpsql");
+function cleanup() {
+       sqlite_close($GLOBALS['db']);
+       unlink($GLOBALS['dbname']);
+}
+register_shutdown_function("cleanup");
+$db = sqlite_open($dbname);
+?>