File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 32
32
use PHPUnit \Framework \TestCase ;
33
33
use Psr \Cache \CacheItemInterface ;
34
34
use Psr \Cache \CacheItemPoolInterface ;
35
+ use RuntimeException ;
35
36
use stdClass ;
36
37
37
38
/** @requires extension pdo_mysql */
@@ -455,6 +456,35 @@ public function testCommitStartsTransactionInNoAutoCommitMode(): void
455
456
self ::assertTrue ($ conn ->isTransactionActive ());
456
457
}
457
458
459
+ public function testBeginTransactionFailureAfterCommitInNoAutoCommitMode (): void
460
+ {
461
+ $ driverConnectionMock = $ this ->createMock (DriverConnection::class);
462
+ $ driverConnectionMock ->expects (self ::exactly (2 ))
463
+ ->method ('beginTransaction ' )
464
+ ->willReturnOnConsecutiveCalls (
465
+ true ,
466
+ self ::throwException (new RuntimeException ()),
467
+ );
468
+
469
+ $ driverMock = $ this ->createMock (Driver::class);
470
+ $ driverMock
471
+ ->method ('connect ' )
472
+ ->willReturn (
473
+ $ driverConnectionMock ,
474
+ );
475
+ $ conn = new Connection ([], $ driverMock );
476
+
477
+ $ conn ->setAutoCommit (false );
478
+
479
+ $ conn ->connect ();
480
+ try {
481
+ $ conn ->commit ();
482
+ } catch (RuntimeException $ e ) {
483
+ }
484
+
485
+ self ::assertTrue ($ conn ->isTransactionActive ());
486
+ }
487
+
458
488
/** @dataProvider resultProvider */
459
489
public function testCommitReturn (bool $ expectedResult ): void
460
490
{
You can’t perform that action at this time.
0 commit comments