You are here

function DatabaseTransactionTestCase::testTransactionsSupported in SimpleTest 7

Test that a database that claims to support transactions will return a transaction object.

If the active connection does not support transactions, this test does nothing.

File

tests/database_test.test, line 2782

Class

DatabaseTransactionTestCase
Test transaction support, particularly nesting.

Code

function testTransactionsSupported() {
  try {
    $connection = Database::getConnection();
    if ($connection
      ->supportsTransactions()) {

      // Start a "required" transaction. This should fail if we do
      // this on a database that does not actually support transactions.
      $txn = db_transaction(TRUE);
    }
    $this
      ->pass('Transaction started successfully.');
  } catch (TransactionsNotSupportedException $e) {
    $this
      ->fail("Exception thrown when it shouldn't have been.");
  }
}