1717use Doctrine \DBAL \Platforms \MySQLPlatform ;
1818use PHPUnit \Framework \MockObject \MockObject ;
1919use PHPUnit \Framework \TestCase ;
20+ use Symfony \Component \Config \Definition \Exception \Exception ;
2021use Symfony \Component \Messenger \Bridge \Doctrine \Transport \Connection ;
2122
2223class ConnectionTest extends TestCase
@@ -31,6 +32,8 @@ public function testTableNotFoundExceptionWithEnabledAutoSetup()
3132
3233 $ transportConnection ->expects ($ this ->once ())
3334 ->method ('setup ' );
35+ $ this ->expectExceptionMessage ('Transaction started ' );
36+
3437 $ transportConnection ->get ();
3538 }
3639
@@ -41,8 +44,11 @@ public function testTableNotFoundExceptionWithDisabledAutoSetup()
4144 ->setConstructorArgs ([['auto_setup ' => false ], $ dbalConnection ])
4245 ->onlyMethods (['setup ' ])
4346 ->getMock ();
47+
4448 $ transportConnection ->expects ($ this ->never ())
4549 ->method ('setup ' );
50+ $ this ->expectExceptionMessage ('Transaction started ' );
51+
4652 $ transportConnection ->get ();
4753 }
4854
@@ -53,8 +59,11 @@ public function testDriverException()
5359 ->setConstructorArgs ([['auto_setup ' => false ], $ dbalConnection ])
5460 ->onlyMethods (['setup ' ])
5561 ->getMock ();
62+
5663 $ transportConnection ->expects ($ this ->never ())
5764 ->method ('setup ' );
65+ $ this ->expectExceptionMessage ('Transaction started ' );
66+
5867 $ transportConnection ->get ();
5968 }
6069
@@ -65,6 +74,8 @@ private function getDbalConnectionMock(string $exceptionClass): MockObject
6574 $ exception = $ this ->createMock ($ exceptionClass );
6675 $ dbalConnection ->method ('delete ' )->willThrowException ($ exception );
6776
77+ $ dbalConnection ->method ('beginTransaction ' )->willThrowException (new Exception ('Transaction started ' ));
78+
6879 $ platform = $ this ->createMock (MySQLPlatform::class);
6980 $ dbalConnection ->method ('getDatabasePlatform ' )->willReturn ($ platform );
7081
0 commit comments