function TransactionTest::testTransactionRollBackNotSupported in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/TransactionTest.php \Drupal\system\Tests\Database\TransactionTest::testTransactionRollBackNotSupported()
Tests transaction rollback on a database that doesn't support transactions.
If the active driver supports transactions, this test does nothing.
File
- core/
modules/ system/ src/ Tests/ Database/ TransactionTest.php, line 180 - Contains \Drupal\system\Tests\Database\TransactionTest.
Class
- TransactionTest
- Tests the transaction abstraction system.
Namespace
Drupal\system\Tests\DatabaseCode
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', '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', 'DanielB not rolled back, since transactions are not supported.');
} catch (\Exception $e) {
$this
->fail($e
->getMessage());
}
}