File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -396,6 +396,48 @@ 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 ->createMock (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 ->createMock (DriverConnection::class),
427
+ );
428
+
429
+ $ conn = new Connection ([], $ driverMock );
430
+
431
+ $ conn ->setAutoCommit (false );
432
+
433
+ self ::assertFalse ($ conn ->isTransactionActive ());
434
+
435
+ $ conn ->transactional (static function (Connection $ connection ): void {
436
+ });
437
+
438
+ self ::assertTrue ($ conn ->isTransactionActive ());
439
+ }
440
+
399
441
public function testCommitStartsTransactionInNoAutoCommitMode (): void
400
442
{
401
443
$ driverMock = $ this ->createMock (Driver::class);
You can’t perform that action at this time.
0 commit comments