]> granicus.if.org Git - php/commitdiff
Fixed test mixup
authorIlia Alshanetsky <iliaa@php.net>
Fri, 2 Feb 2007 00:00:33 +0000 (00:00 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 2 Feb 2007 00:00:33 +0000 (00:00 +0000)
ext/pdo/tests/bug_39656.phpt
ext/pdo/tests/bug_40285.phpt [new file with mode: 0644]

index c0a56743893974e76ae61b6b0232acb07eab8c4f..e1a283ce09572640e8b816a93c7ba203095855fe 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-PDO Common: Bug #40285 (The prepare parser goes into an infinite loop on ': or ":)
+PDO Common: Bug #39656 (Crash when calling fetch() on a PDO statment object after closeCursor())
 --SKIPIF--
 <?php  
 if (!extension_loaded('pdo')) die('skip');
@@ -15,13 +15,36 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
 require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
 $db = PDOTest::factory();
 
-$db->exec('CREATE TABLE test (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32), field4 INT)');
+@$db->exec("DROP TABLE testtable");
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
-$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
-$s = $db->prepare("INSERT INTO test VALUES( ':id', 'name', 'section', 22)" );
-$s->execute();
+$db->exec("CREATE TABLE testtable (id INTEGER NOT NULL PRIMARY KEY, usr VARCHAR( 256 ) NOT NULL)");
+$db->exec("INSERT INTO testtable (id, usr) VALUES (1, 'user')");
+
+$stmt = $db->prepare("SELECT * FROM testtable WHERE id = ?");
+$stmt->bindValue(1, 1, PDO::PARAM_INT );
+$stmt->execute();
+$row = $stmt->fetch();
+var_dump( $row );
+
+$stmt->execute();
+$stmt->closeCursor();
+$row = $stmt->fetch(); // this line will crash CLI
+var_dump( $row );
 
 echo "Done\n";
 ?>
 --EXPECT--     
+array(4) {
+  ["id"]=>
+  string(1) "1"
+  [0]=>
+  string(1) "1"
+  ["usr"]=>
+  string(4) "user"
+  [1]=>
+  string(4) "user"
+}
+bool(false)
 Done
+
diff --git a/ext/pdo/tests/bug_40285.phpt b/ext/pdo/tests/bug_40285.phpt
new file mode 100644 (file)
index 0000000..c0a5674
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+PDO Common: Bug #40285 (The prepare parser goes into an infinite loop on ': or ":)
+--SKIPIF--
+<?php  
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+
+$db->exec('CREATE TABLE test (field1 VARCHAR(32), field2 VARCHAR(32), field3 VARCHAR(32), field4 INT)');
+
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+$s = $db->prepare("INSERT INTO test VALUES( ':id', 'name', 'section', 22)" );
+$s->execute();
+
+echo "Done\n";
+?>
+--EXPECT--     
+Done