Test Failure Report for ext/pdo_pgsql/tests/is_in_transaction.phpt ('PDO PgSQL isInTransaction')
Script
1:
<?php 2: require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; 3: $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); 4: $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 5: $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); 6: 7: $db->exec('CREATE TABLE test (a integer not null primary key, b text)'); 8: 9: $db->beginTransaction(); 10: try { 11: echo "Test PDO::PGSQL_TRANSACTION_INTRANS\n"; 12: var_dump($db->inTransaction()); 13: 14: $stmt = $db->prepare("INSERT INTO test (a, b) values (?, ?)"); 15: $stmt->bindValue(1, 1); 16: $stmt->bindValue(2, "test insert"); 17: $stmt->execute(); 18: 19: $db->commit(); 20: 21: echo "Test PDO::PGSQL_TRANSACTION_IDLE\n"; 22: var_dump($db->inTransaction()); 23: 24: $db->beginTransaction(); 25: 26: try { 27: $stmt = $db->prepare("INSERT INTO test (a, b) values (?, ?)"); 28: $stmt->bindValue(1, "error"); 29: $stmt->bindValue(2, "test insert"); 30: $stmt->execute(); 31: } catch (Exception $e) { 32: /* We catch the exception because the execute will give error and we must test the PDO::PGSQL_TRANSACTION_ERROR */ 33: echo "Test PDO::PGSQL_TRANSACTION_INERROR\n"; 34: var_dump($db->inTransaction()); 35: $db->rollBack(); 36: } 37: 38: echo "Test PDO::PGSQL_TRANSACTION_IDLE\n"; 39: var_dump($db->inTransaction()); 40: 41: } catch (Exception $e) { 42: /* catch exceptions so that we can show the relative error */ 43: echo "Exception! at line ", $e->getLine(), "\n"; 44: var_dump($e->getMessage()); 45: } 46: 47: ?> 48:
Expected
Test PDO::PGSQL_TRANSACTION_INTRANS
int(2)
Test PDO::PGSQL_TRANSACTION_IDLE
int(0)
Test PDO::PGSQL_TRANSACTION_INERROR
int(3)
Test PDO::PGSQL_TRANSACTION_IDLE
int(0)
Output
Test PDO::PGSQL_TRANSACTION_INTRANS
bool(true)
Test PDO::PGSQL_TRANSACTION_IDLE
bool(false)
Test PDO::PGSQL_TRANSACTION_INERROR
bool(true)
Test PDO::PGSQL_TRANSACTION_IDLE
bool(false)
Diff
002+ bool(true)
002- int(2)
004+ bool(false)
004- int(0)
006+ bool(true)
006- int(3)
008+ bool(false)
008- int(0)
Generated at Tue, 21 May 2013 17:04:51 +0000 (15 hours ago)
|