List:Commits« Previous MessageNext Message »
From:uwendel Date:January 8 2008 3:25pm
Subject:PHP mysqlnd svn commit: r1194 - trunk/tests/ext/pdo_mysql
View as plain text  
Author: uwendel
Date: 2008-01-08 16:25:11 +0100 (Tue, 08 Jan 2008)
New Revision: 1194

Removed:
   trunk/tests/ext/pdo_mysql/pdo_g_begintransaction.phpt
Modified:
   trunk/tests/ext/pdo_mysql/pdo_mysql_begintransaction.phpt
Log:
Renaming file, adding check for non-transactional tables. Test fails because PDO does not
reset autocommit property.


Deleted: trunk/tests/ext/pdo_mysql/pdo_g_begintransaction.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_g_begintransaction.phpt	2008-01-08 13:36:13 UTC (rev
1193)
+++ trunk/tests/ext/pdo_mysql/pdo_g_begintransaction.phpt	2008-01-08 15:25:11 UTC (rev
1194)
@@ -1,119 +0,0 @@
---TEST--
-PDO->beginTransaction()
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('mysql_pdo_test.inc');
-$db = MySQLPDOTest::getDriver();
-if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
-	die("skip Transactional engine not found");
-?>
---FILE--
-<?php
-	require_once('mysql_pdo_test.inc');
-	$db = MySQLPDOTest::getDriver();
-	MySQLPDOTest::createTestTable($db,
MySQLPDOTest::detect_transactional_mysql_engine($db));
-
-	if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
-		printf("[001] Autocommit should be on by default\n");
-
-	if (false == $db->beginTransaction())
-		printf("[002] Cannot start a transaction, [%s] [%s]\n",
-			$db->errorCode(), $db->errorInfo());
-
-	if (1 === $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
-		printf("[003] I'm confused, how can autocommit be on? Didn't I say I want to manually
control transactions?\n");
-
-	if (0 == $db->exec('DELETE FROM test'))
-		printf("[004] No rows deleted, can't be true.\n");
-
-	/* This is the PDO way to close a connection */
-	$db = null;
-	$db = MySQLPDOTest::getDriver();
-
-	/* Autocommit was off - by definition. Commit was not issued. DELETE should have been
rolled back. */
-	if (!($stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC')))
-		printf("[005] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	$row = $stmt->fetch(PDO::FETCH_ASSOC);
-	var_dump($row);
-
-	if (!$db->beginTransaction())
-		printf("[006] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id'])))
-		printf("[007] DELETE should have indicated 1 deleted row, [%s] %s\n",
$db->errorCode(), $db->errorInfo());
-
-	if (!$db->commit())
-		printf("[008] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
-		printf("[009] Autocommit should be on after commit()\n");
-
-	if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d',
$row['id']))))
-		printf("[010] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	var_dump($stmt->fetch(PDO::FETCH_ASSOC));
-
-	if (!$db->beginTransaction())
-		printf("[011] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	$db->exec(sprintf('INSERT INTO test(id, label) VALUES (%d, "z")', $row['id']));
-
-	if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d',
$row['id']))))
-		printf("[012] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	$new_row1 = $stmt->fetch(PDO::FETCH_ASSOC);
-	var_dump($new_row1);
-
-	if (!$db->commit())
-		printf("[013] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d',
$row['id']))))
-		printf("[014] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	$new_row2 = $stmt->fetch(PDO::FETCH_ASSOC);
-	if ($new_row1 != $new_row2) {
-		printf("[015] Results must not differ!\n");
-		var_dump($new_row1);
-		var_dump($new_row2);
-	}
-
-	if (!$db->beginTransaction())
-		printf("[016] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id'])))
-		printf("[017] DELETE should have indicated 1 deleted row, [%s] %s\n",
$db->errorCode(), $db->errorInfo());
-
-	if (!$db->rollback())
-		printf("[018] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
-		printf("[019] Autocommit should be on after rollback\n");
-
-	if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d',
$row['id']))))
-		printf("[020] [%s] %s\n", $db->errorCode(), $db->errorInfo());
-
-	$new_row2 = $stmt->fetch(PDO::FETCH_ASSOC);
-	if ($new_row1 != $new_row2) {
-		printf("[021] Results must not differ!\n");
-		var_dump($new_row1);
-		var_dump($new_row2);
-	}
-
-	print "done!";
---EXPECT--
-array(2) {
-  ["id"]=>
-  string(1) "1"
-  ["label"]=>
-  string(1) "a"
-}
-bool(false)
-array(2) {
-  ["id"]=>
-  string(1) "1"
-  ["label"]=>
-  string(1) "z"
-}
-done!
\ No newline at end of file

Modified: trunk/tests/ext/pdo_mysql/pdo_mysql_begintransaction.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_begintransaction.phpt	2008-01-08 13:36:13 UTC (rev
1193)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_begintransaction.phpt	2008-01-08 15:25:11 UTC (rev
1194)
@@ -145,6 +145,40 @@
 		assert($e->getMessage() != '');
 	}
 
+	// TODO: What about an engine that does not support transactions?
+	$db = MySQLPDOTest::factory();
+	MySQLPDOTest::createTestTable($db, 'MyISAM');
+
+	if (false == $db->beginTransaction())
+		printf("[031] Cannot start a transaction, [%s] [%s]\n",
+			$db->errorCode(), implode(' ', $db->errorInfo()));
+
+	if (1 === $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
+		printf("[032] I'm confused, how can autocommit be on? Didn't I say I want to manually
control transactions?\n");
+
+	if (0 == $db->exec('DELETE FROM test'))
+		printf("[033] No rows deleted, can't be true.\n");
+
+	if (!$db->commit())
+		printf("[034] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
+
+	if (false == $db->beginTransaction())
+		printf("[035] Cannot start a transaction, [%s] [%s]\n",
+			$db->errorCode(), implode(' ', $db->errorInfo()));
+
+	if (0 == $db->exec('INSERT INTO test(id, label) VALUES (1, "a")'))
+		printf("[036] Cannot insert data, [%s] [%s]\n",
+			$db->errorCode(), implode(' ', $db->errorInfo()));
+
+	// Should cause a Server warning but no error
+	if (!$db->rollback())
+		printf("[037] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
+
+	var_dump($db->errorCode());
+
+	if (1 != $db->exec('DELETE FROM test'))
+		printf("[038] No rows deleted, can't be true.\n");
+
 	print "done!";
 --EXPECT--
 array(2) {
@@ -160,4 +194,5 @@
   ["label"]=>
   string(1) "z"
 }
+string(5) "00000"
 done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1194 - trunk/tests/ext/pdo_mysqluwendel8 Jan