function DatabaseTransactionTestCase::testTransactionRollBackNotSupported in SimpleTest 7
Test transaction rollback on a database that does not support transactions.
If the active driver supports transactions, this test does nothing.
File
- tests/database_test.test, line 2851 
Class
- DatabaseTransactionTestCase
- Test transaction support, particularly nesting.
Code
function testTransactionRollBackNotSupported() {
  // This test won't work right if transactions are supported.
  if (Database::getConnection()
    ->supportsTransactions()) {
    return;
  }
  try {
    // Create two nested transactions. Attempt to roll back from the inner one.
    $this
      ->transactionOuterLayer('B', TRUE);
    // Because our current database claims to not support transactions,
    // the inserted rows should be present despite the attempt to roll back.
    $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(
      ':name' => 'DavidB',
    ))
      ->fetchField();
    $this
      ->assertIdentical($saved_age, '24', t('DavidB not rolled back, since transactions are not supported.'));
    $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(
      ':name' => 'DanielB',
    ))
      ->fetchField();
    $this
      ->assertIdentical($saved_age, '19', t('DanielB not rolled back, since transactions are not supported.'));
  } catch (Exception $e) {
    $this
      ->fail($e
      ->getMessage());
  }
}