List:Commits« Previous MessageNext Message »
From:uwendel Date:December 14 2007 2:44pm
Subject:PHP mysqlnd svn commit: r1169 - trunk/tests/ext/pdo
View as plain text  
Author: uwendel
Date: 2007-12-14 15:44:46 +0100 (Fri, 14 Dec 2007)
New Revision: 1169

Added:
   trunk/tests/ext/pdo/pdo_rollback.phpt
Log:
Should pass. However, another bug found while writing this test:

 ...
 $stmt = $db->query('SELECT ... FROM test')
 var_dump($stmt->fetchAll(PDO::FETCH_BOTH))
 $db->rollBack() (let it throw an exception, have no beginTransaction() anywhere!)
 $db->errorInfo() -> unknown table 'classtypes' ( = error info not cleaned up)



Added: trunk/tests/ext/pdo/pdo_rollback.phpt
===================================================================
--- trunk/tests/ext/pdo/pdo_rollback.phpt	                        (rev 0)
+++ trunk/tests/ext/pdo/pdo_rollback.phpt	2007-12-14 14:44:46 UTC (rev 1169)
@@ -0,0 +1,49 @@
+--TEST--
+PDO Common: PDO->rollBack() — Rolls back a transaction
+
+--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();
+
+try {
+
+	try {
+		@$db->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
+	} catch (PDOException $e) {
+		// ignore - some drivers do not support auto commit
+	}
+
+	$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\')');
+
+	try {
+		$db->rollBack();
+	} catch (PDOException $e) {
+		// TODO errorInfo() gives bogus (12.12.2007, oci + MySQL) -
+		// how do I test for the type of the exception?
+		if ('There is no active transaction' != $e->getMessage())
+			printf("[002] There is no proper way to test if PDO has thrown the correct Exception,
but it seems wrong. Check manually. Exception: %s\n", $e->getMessage());
+	}
+
+	$db->beginTransaction();
+	$db->rollBack();
+
+} catch (PDOException $e) {
+	// we should never get here, we use warnings, but never trust a system...
+	printf("[001] %s, [%s] %s\n",
+		$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
+}
+print "done!";
+?>
+--EXPECTF--
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1169 - trunk/tests/ext/pdouwendel14 Dec