function TransactionTest::testMockTransaction
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php \Drupal\KernelTests\Core\Database\TransactionTest::testMockTransaction()
Tests that mocking transactions works fine.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ TransactionTest.php, line 1284
Class
- TransactionTest
- Tests the transactions, using the explicit ::commitOrRelease method.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testMockTransaction() : void {
$connection = $this->createStub(Connection::class);
$transaction = $this->getMockBuilder(Transaction::class)
->setConstructorArgs([
$connection,
'',
'',
])
->getMock();
$transaction->expects($this->once())
->method('name')
->willReturn('foo');
$this->assertSame('foo', $transaction->name());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.