]> granicus.if.org Git - php/commitdiff
- Add tests
authorMarcus Boerger <helly@php.net>
Fri, 4 Mar 2005 01:29:27 +0000 (01:29 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 4 Mar 2005 01:29:27 +0000 (01:29 +0000)
- Fix testname
- Drop unnecessary include line (was wrong anyway)

ext/pdo/tests/pdo_016.inc [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_012.phpt
ext/pdo_mysql/tests/pdo_015.phpt
ext/pdo_mysql/tests/pdo_016.phpt [new file with mode: 0755]
ext/pdo_pgsql/tests/pdo_015.phpt
ext/pdo_pgsql/tests/pdo_016.phpt [new file with mode: 0755]
ext/pdo_sqlite/tests/pdo_015.phpt
ext/pdo_sqlite/tests/pdo_016.phpt [new file with mode: 0755]

diff --git a/ext/pdo/tests/pdo_016.inc b/ext/pdo/tests/pdo_016.inc
new file mode 100755 (executable)
index 0000000..a366a3e
--- /dev/null
@@ -0,0 +1,82 @@
+<?php # vim:ft=php
+
+require_once('pdo.inc');
+       
+set_sql('create1', 'CREATE TABLE test(idx int PRIMARY KEY, txt VARCHAR(20))');
+set_sql('insert1', 'INSERT INTO test VALUES(0, \'String0\')'); 
+set_sql('insert2', 'INSERT INTO test VALUES(1, \'String1\')'); 
+set_sql('insert3', 'INSERT INTO test VALUES(2, \'String2\')'); 
+set_sql('select1', 'SELECT COUNT(*) FROM test'); 
+set_sql('select2', 'SELECT idx, txt FROM test ORDER by idx'); 
+set_sql('select3', 'SELECT txt FROM test WHERE idx=:inp'); 
+set_sql('select4', 'SELECT idx FROM test WHERE txt=:txt'); 
+
+echo "===INIT===\n";
+
+$DB->exec($SQL['create1']);
+var_dump($DB->exec($SQL['insert1']));
+var_dump($DB->exec($SQL['insert2']));
+var_dump($DB->exec($SQL['insert3']));
+var_dump($DB->query($SQL['select1'])->fetchSingle());
+
+$cont = $DB->query($SQL['select2'])->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE);
+var_dump($cont);
+
+echo "===WHILE===\n";
+
+$stmt2 = $DB->prepare($SQL['select2']);
+$stmt2->bindColumn('idx', $idx);
+$stmt2->bindColumn('txt', $txt);
+$stmt2->execute();
+
+while($stmt2->fetch(PDO_FETCH_BOUND)) {
+       var_dump(array($idx=>$txt));
+}
+
+echo "===ALONE===\n";
+
+$stmt3 = $DB->prepare($SQL['select3']);
+$stmt3->bindParam(':inp', $idx); /* by foreign name */
+$stmt3->bindColumn('txt', $col1);
+
+$stmt4 = $DB->prepare($SQL['select4']);
+$stmt4->bindParam(':txt', $txt);  /* using same name */
+$stmt4->bindColumn('idx', $col2);
+
+foreach($cont as $idx => $txt)
+{
+       var_dump(array($idx=>$txt));
+       var_dump($stmt3->execute());
+       var_dump($stmt3->fetch(PDO_FETCH_BOUND));
+       var_dump($stmt4->execute());
+       var_dump($stmt4->fetch(PDO_FETCH_BOUND));
+       var_dump(array($col2=>$col1));
+}
+
+echo "===REBIND/SAME===\n";
+
+$stmt4->bindColumn('idx', $col1);
+
+foreach($cont as $idx => $txt)
+{
+       var_dump(array($idx=>$txt));
+       var_dump($stmt3->execute());
+       var_dump($stmt3->fetch(PDO_FETCH_BOUND));
+       var_dump($col1);
+       var_dump($stmt4->execute());
+       var_dump($stmt4->fetch(PDO_FETCH_BOUND));
+       var_dump($col1);
+}
+
+echo "===REBIND/CONFLICT===\n";
+
+$stmt2->bindColumn('idx', $col1);
+$stmt2->bindColumn('txt', $col1);
+$stmt2->execute();
+
+while($stmt2->fetch(PDO_FETCH_BOUND))
+{
+       var_dump($col1);
+}
+
+?>
index 112d2fa9dc24f47975637d0fb19c5caea6549f53..c2384757206b4789697c6757fbf815885f222c4c 100755 (executable)
@@ -1,5 +1,5 @@
 --TEST--
-PDO_MySQ: PDOStatement::setFetchMode
+PDO_MySQL: PDOStatement::setFetchMode
 --SKIPIF--
 <?php # vim:ft=php
 require_once('skipif.inc'); ?>
index 03e0ab2bc2f1a2e43b2dbb8ec362b1fcdc38b30a..a7974b51b9d40c9f5024edad1d9fc75450d08499 100755 (executable)
@@ -10,7 +10,6 @@ require_once('skipif.inc');
 require_once('connection.inc');
 require_once('prepare.inc');
 
-require_once(dirname(__FILE__).'/../../pdo/tests/pdo.inc');
 require_once($PDO_TESTS . 'pdo_015.inc');
 
 ?>
diff --git a/ext/pdo_mysql/tests/pdo_016.phpt b/ext/pdo_mysql/tests/pdo_016.phpt
new file mode 100755 (executable)
index 0000000..1be753f
--- /dev/null
@@ -0,0 +1,117 @@
+--TEST--
+PDO_MySQL: PDO_FETCH_BOUND
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_016.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===INIT===
+int(1)
+int(1)
+int(1)
+string(1) "3"
+array(3) {
+  [0]=>
+  string(7) "String0"
+  [1]=>
+  string(7) "String1"
+  [2]=>
+  string(7) "String2"
+}
+===WHILE===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+===ALONE===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+===REBIND/SAME===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+bool(true)
+bool(true)
+string(7) "String0"
+bool(true)
+bool(true)
+string(1) "0"
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+bool(true)
+bool(true)
+string(7) "String1"
+bool(true)
+bool(true)
+string(1) "1"
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+bool(true)
+bool(true)
+string(7) "String2"
+bool(true)
+bool(true)
+string(1) "2"
+===REBIND/CONFLICT===
+string(7) "String0"
+string(7) "String1"
+string(7) "String2"
+===DONE===
index 5e3868174d22db1b99d20267abd6a428f23e50ae..e8a88821fdbbd811e93de8d0a28c652c8a0e98fa 100755 (executable)
@@ -10,7 +10,6 @@ require_once('skipif.inc');
 require_once('connection.inc');
 require_once('prepare.inc');
 
-require_once(dirname(__FILE__).'/../../pdo/tests/pdo.inc');
 require_once($PDO_TESTS . 'pdo_015.inc');
 
 ?>
diff --git a/ext/pdo_pgsql/tests/pdo_016.phpt b/ext/pdo_pgsql/tests/pdo_016.phpt
new file mode 100755 (executable)
index 0000000..9c41aeb
--- /dev/null
@@ -0,0 +1,117 @@
+--TEST--
+PDO_PGSQL: PDO_FETCH_BOUND
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_016.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===INIT===
+int(1)
+int(1)
+int(1)
+string(1) "3"
+array(3) {
+  [0]=>
+  string(7) "String0"
+  [1]=>
+  string(7) "String1"
+  [2]=>
+  string(7) "String2"
+}
+===WHILE===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+===ALONE===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+===REBIND/SAME===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+bool(true)
+bool(true)
+string(7) "String0"
+bool(true)
+bool(true)
+string(1) "0"
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+bool(true)
+bool(true)
+string(7) "String1"
+bool(true)
+bool(true)
+string(1) "1"
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+bool(true)
+bool(true)
+string(7) "String2"
+bool(true)
+bool(true)
+string(1) "2"
+===REBIND/CONFLICT===
+string(7) "String0"
+string(7) "String1"
+string(7) "String2"
+===DONE===
index 38307a5cf96cb08d5db8a4a306b49de8b9a91c21..ee369910279b10908c322c0ee0f709aea66aa54e 100755 (executable)
@@ -10,7 +10,6 @@ require_once('skipif.inc');
 require_once('connection.inc');
 require_once('prepare.inc');
 
-require_once(dirname(__FILE__).'/../../pdo/tests/pdo.inc');
 require_once($PDO_TESTS . 'pdo_015.inc');
 
 ?>
diff --git a/ext/pdo_sqlite/tests/pdo_016.phpt b/ext/pdo_sqlite/tests/pdo_016.phpt
new file mode 100755 (executable)
index 0000000..f23ef08
--- /dev/null
@@ -0,0 +1,117 @@
+--TEST--
+PDO_SQLite: PDO_FETCH_BOUND
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_016.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===INIT===
+int(1)
+int(1)
+int(1)
+string(1) "3"
+array(3) {
+  [0]=>
+  string(7) "String0"
+  [1]=>
+  string(7) "String1"
+  [2]=>
+  string(7) "String2"
+}
+===WHILE===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+===ALONE===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+===REBIND/SAME===
+array(1) {
+  [0]=>
+  string(7) "String0"
+}
+bool(true)
+bool(true)
+string(7) "String0"
+bool(true)
+bool(true)
+string(1) "0"
+array(1) {
+  [1]=>
+  string(7) "String1"
+}
+bool(true)
+bool(true)
+string(7) "String1"
+bool(true)
+bool(true)
+string(1) "1"
+array(1) {
+  [2]=>
+  string(7) "String2"
+}
+bool(true)
+bool(true)
+string(7) "String2"
+bool(true)
+bool(true)
+string(1) "2"
+===REBIND/CONFLICT===
+string(7) "String0"
+string(7) "String1"
+string(7) "String2"
+===DONE===