]> granicus.if.org Git - php/commitdiff
- Add first tests
authorMarcus Boerger <helly@php.net>
Sat, 19 Feb 2005 19:52:41 +0000 (19:52 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 19 Feb 2005 19:52:41 +0000 (19:52 +0000)
ext/pdo_sqlite/tests/pdo_sqlite_001.phpt [new file with mode: 0755]
ext/pdo_sqlite/tests/pdo_sqlite_002.phpt [new file with mode: 0755]
ext/pdo_sqlite/tests/pdo_sqlite_003.phpt [new file with mode: 0755]

diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt
new file mode 100755 (executable)
index 0000000..0a3dfbf
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_ASSOC
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+--FILE--
+<?php
+
+$db =new pdo('sqlite::memory:');
+
+$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))');
+$db->exec('INSERT INTO test VALUES(1, "A")'); 
+$db->exec('INSERT INTO test VALUES(2, "B")'); 
+$db->exec('INSERT INTO test VALUES(3, "C")'); 
+
+$stmt = $db->query('SELECT * FROM test');
+
+var_dump($stmt->fetchAll(PDO_FETCH_ASSOC));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(4) {
+  [0]=>
+  array(2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(2) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+  [3]=>
+  array(2) {
+    ["id"]=>
+    string(1) "4"
+    ["val"]=>
+    string(1) "D"
+  }
+}
+===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt
new file mode 100755 (executable)
index 0000000..187085a
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_NUM
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+--FILE--
+<?php
+
+$db =new pdo('sqlite::memory:');
+
+$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))');
+$db->exec('INSERT INTO test VALUES(1, "A")'); 
+$db->exec('INSERT INTO test VALUES(2, "B")'); 
+$db->exec('INSERT INTO test VALUES(3, "C")'); 
+
+$stmt = $db->query('SELECT * FROM test');
+
+var_dump($stmt->fetchAll(PDO_FETCH_NUM));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(4) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(1) "1"
+    [1]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(1) "2"
+    [1]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(2) {
+    [0]=>
+    string(1) "3"
+    [1]=>
+    string(1) "C"
+  }
+  [3]=>
+  array(2) {
+    [0]=>
+    string(1) "4"
+    [1]=>
+    string(1) "D"
+  }
+}
+===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt
new file mode 100755 (executable)
index 0000000..82d9b37
--- /dev/null
@@ -0,0 +1,69 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_BOTH
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+--FILE--
+<?php
+
+$db =new pdo('sqlite::memory:');
+
+$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))');
+$db->exec('INSERT INTO test VALUES(1, "A")'); 
+$db->exec('INSERT INTO test VALUES(2, "B")'); 
+$db->exec('INSERT INTO test VALUES(3, "C")'); 
+
+$stmt = $db->query('SELECT * FROM test');
+
+var_dump($stmt->fetchAll(PDO_FETCH_BOTH));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(4) {
+  [0]=>
+  array(4) {
+    ["id"]=>
+    string(1) "1"
+    [0]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+    [1]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(4) {
+    ["id"]=>
+    string(1) "2"
+    [0]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+    [1]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(4) {
+    ["id"]=>
+    string(1) "3"
+    [0]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+    [1]=>
+    string(1) "C"
+  }
+  [3]=>
+  array(4) {
+    ["id"]=>
+    string(1) "4"
+    [0]=>
+    string(1) "4"
+    ["val"]=>
+    string(1) "D"
+    [1]=>
+    string(1) "D"
+  }
+}
+===DONE===