File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 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 */
@@ -413,6 +414,35 @@ public function testCommitStartsTransactionInNoAutoCommitMode(): void
413
414
self ::assertTrue ($ conn ->isTransactionActive ());
414
415
}
415
416
417
+ public function testBeginTransactionFailureAfterCommitInNoAutoCommitMode (): void
418
+ {
419
+ $ driverConnectionMock = $ this ->createMock (DriverConnection::class);
420
+ $ driverConnectionMock ->expects (self ::exactly (2 ))
421
+ ->method ('beginTransaction ' )
422
+ ->willReturnOnConsecutiveCalls (
423
+ true ,
424
+ self ::throwException (new RuntimeException ()),
425
+ );
426
+
427
+ $ driver = $ this ->createStub (Driver::class);
428
+ $ driverMock
429
+ ->method ('connect ' )
430
+ ->willReturn (
431
+ $ driverConnectionMock ,
432
+ );
433
+ $ conn = new Connection ([], $ driverMock );
434
+
435
+ $ conn ->setAutoCommit (false );
436
+
437
+ $ conn ->connect ();
438
+ try {
439
+ $ conn ->commit ();
440
+ } catch (RuntimeException $ e ) {
441
+ }
442
+
443
+ self ::assertTrue ($ conn ->isTransactionActive ());
444
+ }
445
+
416
446
/** @dataProvider resultProvider */
417
447
public function testCommitReturn (bool $ expectedResult ): void
418
448
{
You can’t perform that action at this time.
0 commit comments