diff options
-rw-r--r-- | ext/sqlite/tests/001.phpt | 39 | ||||
-rw-r--r-- | ext/sqlite/tests/blankdb.inc | 9 |
2 files changed, 31 insertions, 17 deletions
diff --git a/ext/sqlite/tests/001.phpt b/ext/sqlite/tests/001.phpt index ad723b8076..7ebb8ce465 100644 --- a/ext/sqlite/tests/001.phpt +++ b/ext/sqlite/tests/001.phpt @@ -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 index 0000000000..45d9753ba8 --- /dev/null +++ b/ext/sqlite/tests/blankdb.inc @@ -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); +?> |