List:Commits« Previous MessageNext Message »
From:uwendel Date:February 27 2008 2:16pm
Subject:PHP mysqlnd svn commit: r1306 - trunk/tests/ext/pdo
View as plain text  
Author: uwendel
Date: 2008-02-27 15:16:16 +0100 (Wed, 27 Feb 2008)
New Revision: 1306

Added:
   trunk/tests/ext/pdo/pdo_stmt_close_cursor.phpt
Log:
No idea how to fool it. Seems to work fine.


Added: trunk/tests/ext/pdo/pdo_stmt_close_cursor.phpt
===================================================================
--- trunk/tests/ext/pdo/pdo_stmt_close_cursor.phpt	                        (rev 0)
+++ trunk/tests/ext/pdo/pdo_stmt_close_cursor.phpt	2008-02-27 14:16:16 UTC (rev 1306)
@@ -0,0 +1,96 @@
+--TEST--
+PDO Common: PDOStatement->closeCursor()
+--SKIPIF--
+<?php # vim:ft=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(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp
VARCHAR(10))');
+$db->exec('INSERT INTO test VALUES(1, \'A\', \'Group1\')');
+$db->exec('INSERT INTO test VALUES(2, \'B\', \'Group2\')');
+
+try {
+
+	$stmt = $db->prepare('SELECT id FROM test WHERE id > ? ORDER BY id ASC');
+
+	if (true !== ($tmp = $stmt->closeCursor()))
+		printf("[001] BC: It should be possible to close a cursor prior(!) to creating a result
set, got %s\n",
+			var_export($tmp, true));
+
+	if (false !== ($tmp = $stmt->closeCursor("this is void, too many arguments")))
+		printf("[002] Expecting boolean false got %s\n", var_export($tmp, true));
+
+	if (!$stmt->bindValue(1, 0))
+		printf("[003] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(),
true));
+
+	if (!$stmt->execute())
+		printf("[004] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(),
true));
+
+	var_dump($stmt->fetch(PDO::FETCH_ASSOC));
+
+	if (true !== ($tmp = $stmt->closeCursor()))
+		printf("[006] closeCursor() failed, [%d] %s, got %s\n",
+			$stmt->errorCode(), var_export($stmt->errorInfo(), true),
+			var_export($tmp, true));
+
+	$stmt->execute();
+	var_dump($stmt->fetch(PDO::FETCH_ASSOC));
+
+	$stmt = $db->prepare('SELECT val FROM test WHERE id > ? ORDER BY id ASC');
+	$stmt->bindValue(1, 0);
+	$stmt->execute();
+	var_dump($stmt->fetch(PDO::FETCH_ASSOC));
+	if (true !== ($tmp = $stmt->closeCursor()))
+		printf("[007] closeCursor() failed, [%d] %s, got %s\n",
+			$stmt->errorCode(), var_export($stmt->errorInfo(), true),
+			var_export($tmp, true));
+
+	var_dump($db->exec('INSERT INTO test VALUES(3, \'C\', \'Group3\')'));
+
+} catch (PDOException $e) {
+	// we should never get here, we use warnings, but never trust a system...s
+	printf("[001] %s, [%s} %s\n",
+		$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
+}
+print "done!";
+?>
+--BUGFREE_EXPECTF--
+array(1) {
+  ["id"]=>
+  string(1) "1"
+}
+array(1) {
+  ["id"]=>
+  string(1) "1"
+}
+array(1) {
+  ["val"]=>
+  string(1) "A"
+}
+int(1)
+done!
+--EXPECTF--
+[002] Expecting boolean false got true
+array(1) {
+  ["id"]=>
+  string(1) "1"
+}
+array(1) {
+  ["id"]=>
+  string(1) "1"
+}
+array(1) {
+  ["val"]=>
+  string(1) "A"
+}
+int(1)
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1306 - trunk/tests/ext/pdouwendel27 Feb