]> granicus.if.org Git - php/commitdiff
Add more tests
authorMarcus Boerger <helly@php.net>
Sun, 27 Apr 2003 11:29:39 +0000 (11:29 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 27 Apr 2003 11:29:39 +0000 (11:29 +0000)
ext/sqlite/tests/sqlite_007.phpt [new file with mode: 0755]
ext/sqlite/tests/sqlite_008.phpt [new file with mode: 0755]
ext/sqlite/tests/sqlite_009.phpt [new file with mode: 0755]

diff --git a/ext/sqlite/tests/sqlite_007.phpt b/ext/sqlite/tests/sqlite_007.phpt
new file mode 100755 (executable)
index 0000000..b6174db
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+sqlite: Simple insert/select (unbuffered)
+--SKIPIF--
+<?php
+if (!extension_loaded("sqlite")) print "skip"; ?>
+--FILE--
+<?php 
+include "blankdb.inc";
+
+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_unbuffered_query("SELECT * from foo", $db);
+var_dump(sqlite_fetch_array($r, SQLITE_BOTH));
+$r = sqlite_unbuffered_query("SELECT * from foo", $db);
+var_dump(sqlite_fetch_array($r, SQLITE_NUM));
+$r = sqlite_unbuffered_query("SELECT * from foo", $db);
+var_dump(sqlite_fetch_array($r, SQLITE_ASSOC));
+?>
+--EXPECT--
+array(6) {
+  [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
+}
+array(3) {
+  [0]=>
+  string(10) "2002-01-02"
+  [1]=>
+  string(8) "12:49:00"
+  [2]=>
+  NULL
+}
+array(3) {
+  ["c1"]=>
+  string(10) "2002-01-02"
+  ["c2"]=>
+  string(8) "12:49:00"
+  ["c3"]=>
+  NULL
+}
diff --git a/ext/sqlite/tests/sqlite_008.phpt b/ext/sqlite/tests/sqlite_008.phpt
new file mode 100755 (executable)
index 0000000..3d6b459
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+sqlite: fetch all
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("sqlite")) print "skip"; ?>
+--FILE--
+<?php 
+include "blankdb.inc";
+
+$data = array(
+       "one",
+       "two",
+       "three"
+       );
+
+sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
+
+foreach ($data as $str) {
+       sqlite_query("INSERT INTO strings VALUES('$str')", $db);
+}
+
+$r = sqlite_query("SELECT a from strings", $db);
+while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
+       var_dump($row);
+}
+echo "DONE!\n";
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(3) "one"
+}
+array(1) {
+  [0]=>
+  string(3) "two"
+}
+array(1) {
+  [0]=>
+  string(5) "three"
+}
+DONE!
diff --git a/ext/sqlite/tests/sqlite_009.phpt b/ext/sqlite/tests/sqlite_009.phpt
new file mode 100755 (executable)
index 0000000..b0f3d2f
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+sqlite: fetch all (unbuffered)
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("sqlite")) print "skip"; ?>
+--FILE--
+<?php 
+include "blankdb.inc";
+
+$data = array(
+       "one",
+       "two",
+       "three"
+       );
+
+sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
+
+foreach ($data as $str) {
+       sqlite_query("INSERT INTO strings VALUES('$str')", $db);
+}
+
+$r = sqlite_unbuffered_query("SELECT a from strings", $db);
+while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
+       var_dump($row);
+}
+echo "DONE!\n";
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(3) "one"
+}
+array(1) {
+  [0]=>
+  string(3) "two"
+}
+array(1) {
+  [0]=>
+  string(5) "three"
+}
+DONE!