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

index 0a3dfbf08941f544754bcf8ea90478ba900ec259..86c9ce86367673ad7e40c658dcf5a81c8fff5171 100755 (executable)
@@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_ASSOC));
 ===DONE===
 <?php exit(0); ?>
 --EXPECT--
-array(4) {
+array(3) {
   [0]=>
   array(2) {
     ["id"]=>
@@ -42,12 +42,5 @@ array(4) {
     ["val"]=>
     string(1) "C"
   }
-  [3]=>
-  array(2) {
-    ["id"]=>
-    string(1) "4"
-    ["val"]=>
-    string(1) "D"
-  }
 }
 ===DONE===
index 187085a9f6bc736157410a02a62f53b1d107a34a..227f738df76a463d258403666cb2ffa10f8ee497 100755 (executable)
@@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_NUM));
 ===DONE===
 <?php exit(0); ?>
 --EXPECT--
-array(4) {
+array(3) {
   [0]=>
   array(2) {
     [0]=>
@@ -42,12 +42,5 @@ array(4) {
     [1]=>
     string(1) "C"
   }
-  [3]=>
-  array(2) {
-    [0]=>
-    string(1) "4"
-    [1]=>
-    string(1) "D"
-  }
 }
 ===DONE===
index 82d9b37e1a392e1772bea4811e5f9e0b1506f290..e7cffae940a6f2641e2ab25ce8d0ff7e3fd76bf1 100755 (executable)
@@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_BOTH));
 ===DONE===
 <?php exit(0); ?>
 --EXPECT--
-array(4) {
+array(3) {
   [0]=>
   array(4) {
     ["id"]=>
@@ -54,16 +54,5 @@ array(4) {
     [1]=>
     string(1) "C"
   }
-  [3]=>
-  array(4) {
-    ["id"]=>
-    string(1) "4"
-    [0]=>
-    string(1) "4"
-    ["val"]=>
-    string(1) "D"
-    [1]=>
-    string(1) "D"
-  }
 }
 ===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt
new file mode 100755 (executable)
index 0000000..2e6e93d
--- /dev/null
@@ -0,0 +1,46 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_OBJ
+--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_OBJ));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(3) {
+  [0]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+}
+===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt
new file mode 100755 (executable)
index 0000000..9ea9e2b
--- /dev/null
@@ -0,0 +1,122 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_CLASS
+--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")'); 
+
+class TestBase
+{
+       public $id;
+       public $val;
+}
+
+class TestDerived extends TestBase
+{
+       protected $p1;
+       protected $p2;
+
+       public function __construct($p1, $p2)
+       {
+               $this->p1 = $p1;
+               $this->p2 = $p2;
+       }
+}
+
+var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS));
+var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestBase'));
+var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestDerived', array(1,2)));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(3) {
+  [0]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+}
+array(3) {
+  [0]=>
+  object(TestBase)#%d (2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  object(TestBase)#%d (2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  object(TestBase)#%d (2) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+}
+array(3) {
+  [0]=>
+  object(TestDerived)#%d (4) {
+    ["p1:protected"]=>
+    int(1)
+    ["p2:protected"]=>
+    int(2)
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  object(TestDerived)#%d (4) {
+    ["p1:protected"]=>
+    int(1)
+    ["p2:protected"]=>
+    int(2)
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  object(TestDerived)#%d (4) {
+    ["p1:protected"]=>
+    int(1)
+    ["p2:protected"]=>
+    int(2)
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+}
+===DONE===