public function TransactionLegacyAPITest::testTransactionRollBack in Transaction 5
Verify that rollbacks behave correctly.
File
- tests/
transaction_legacy.test, line 143 - Contains the test for the pressflow_transaction legacy API provided in the transaction module (formerly pressflow_transaction).
Class
- TransactionLegacyAPITest
- Implements the test cases for the pressflow_transaction legacy API.
Code
public function testTransactionRollBack() {
// Get the id from the sequence table before we start
$seq = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", db_prefix_tables(self::$sequence1)));
$count = db_result(db_query('SELECT COUNT(*) FROM ' . self::$table));
$txn1 = new pressflow_transaction();
pressflow_transaction_update(self::$table, 'id', array(
'first_name' => 'Louis',
'last_name' => 'Pasteur',
'status' => 1,
));
$txn2 = new pressflow_transaction();
pressflow_transaction_update(self::$table, 'id', array(
'first_name' => 'Frank',
'last_name' => 'Miller',
'status' => 5,
));
$txn2
->rollback_if_false(FALSE);
unset($txn2);
unset($txn1);
// The __destruct method has now been called on each transaction object,
// and a roll back should have taken place.
$seq_test = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", db_prefix_tables(self::$sequence1)));
$msg = t('Verify sequence after roll back : %s');
$this
->assertEqual($seq, $seq_test, $msg);
$count_test = db_result(db_query('SELECT COUNT(*) FROM ' . self::$table));
$msg = t('Verify table row count after roll back : %s');
$this
->assertEqual($count, $count_test, $msg);
}