@@ -396,13 +396,53 @@ public function testConnectStartsTransactionInNoAutoCommitMode(): void
396
396
self ::assertTrue ($ conn ->isTransactionActive ());
397
397
}
398
398
399
+ public function testTransactionIsNotActiveAfterTransactionalInAutoCommitMode (): void
400
+ {
401
+ $ driverMock = $ this ->createStub (Driver::class);
402
+ $ driverMock
403
+ ->method ('connect ' )
404
+ ->willReturn (
405
+ $ this ->createStub (DriverConnection::class),
406
+ );
407
+
408
+ $ conn = new Connection ([], $ driverMock );
409
+
410
+ $ conn ->setAutoCommit (true );
411
+
412
+ self ::assertFalse ($ conn ->isTransactionActive ());
413
+
414
+ $ conn ->transactional (static function (Connection $ connection ): void {
415
+ });
416
+
417
+ self ::assertFalse ($ conn ->isTransactionActive ());
418
+ }
419
+
420
+ public function testTransactionIsActiveAfterTransactionalInNoAutoCommitMode (): void
421
+ {
422
+ $ driverMock = $ this ->createMock (Driver::class);
423
+ $ driverMock
424
+ ->method ('connect ' )
425
+ ->willReturn (
426
+ $ this ->createStub (DriverConnection::class),
427
+ );
428
+
429
+ $ conn = new Connection ([], $ driverMock );
430
+
431
+ $ conn ->setAutoCommit (false );
432
+
433
+ $ conn ->transactional (static function (Connection $ connection ): void {
434
+ });
435
+
436
+ self ::assertTrue ($ conn ->isTransactionActive ());
437
+ }
438
+
399
439
public function testCommitStartsTransactionInNoAutoCommitMode (): void
400
440
{
401
441
$ driverMock = $ this ->createMock (Driver::class);
402
442
$ driverMock
403
443
->method ('connect ' )
404
444
->willReturn (
405
- $ this ->createMock (DriverConnection::class),
445
+ $ this ->createStub (DriverConnection::class),
406
446
);
407
447
$ conn = new Connection ([], $ driverMock );
408
448
0 commit comments