function ConnectionTest::testTransactionsOptionDeprecation

Tests the deprecation of the 'transactions' connection option.

@group legacy

File

core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php, line 126

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testTransactionsOptionDeprecation() {
    $this->expectDeprecation('Passing a \'transactions\' connection option to Drupal\\Core\\Database\\Connection::__construct is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745');
    $this->expectDeprecation('Drupal\\Core\\Database\\Connection::supportsTransactions is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745');
    $connection_info = Database::getConnectionInfo('default');
    $connection_info['default']['transactions'] = FALSE;
    Database::addConnectionInfo('default', 'foo', $connection_info['default']);
    $foo_connection = Database::getConnection('foo', 'default');
    $this->assertInstanceOf(Connection::class, $foo_connection);
    $this->assertTrue($foo_connection->supportsTransactions());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.