File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Tests/Unit/Consumption/Extension Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 88use Doctrine \Persistence \ManagerRegistry ;
99use Interop \Queue \ConnectionFactory ;
1010use Interop \Queue \Context ;
11+ use ReflectionMethod ;
1112
1213class ManagerRegistryConnectionFactory implements ConnectionFactory
1314{
@@ -61,7 +62,10 @@ private function establishConnection(): Connection
6162 {
6263 /** @var Connection $connection */
6364 $ connection = $ this ->registry ->getConnection ($ this ->config ['connection_name ' ]);
64- if (method_exists ($ connection , 'connect ' )) {
65+ if (
66+ method_exists ($ connection , 'connect ' )
67+ && (new ReflectionMethod ($ connection , 'connect ' ))->isPublic ()
68+ ) {
6569 // DBAL < 4
6670 $ connection ->connect ();
6771 } else {
Original file line number Diff line number Diff line change 66use Doctrine \Persistence \ManagerRegistry ;
77use Enqueue \Consumption \Context \MessageReceived ;
88use Enqueue \Consumption \MessageReceivedExtensionInterface ;
9+ use ReflectionMethod ;
910
1011class DoctrinePingConnectionExtension implements MessageReceivedExtensionInterface
1112{
@@ -36,7 +37,10 @@ public function onMessageReceived(MessageReceived $context): void
3637 );
3738
3839 $ connection ->close ();
39- if (method_exists ($ connection , 'connect ' )) {
40+ if (
41+ method_exists ($ connection , 'connect ' )
42+ && (new ReflectionMethod ($ connection , 'connect ' ))->isPublic ()
43+ ) {
4044 // DBAL < 4
4145 $ connection ->connect ();
4246 } else {
Original file line number Diff line number Diff line change 1414use Interop \Queue \Processor ;
1515use PHPUnit \Framework \MockObject \MockObject ;
1616use PHPUnit \Framework \TestCase ;
17+ use ReflectionMethod ;
1718
1819class DoctrinePingConnectionExtensionTest extends TestCase
1920{
@@ -41,7 +42,10 @@ public function testShouldNotReconnectIfConnectionIsOK()
4142 ->expects ($ this ->never ())
4243 ->method ('close ' )
4344 ;
44- if (method_exists (Connection::class, 'connect ' )) {
45+ if (
46+ method_exists (Connection::class, 'connect ' )
47+ && (new ReflectionMethod (Connection::class, 'connect ' ))->isPublic ()
48+ ) {
4549 // DBAL < 4
4650 $ connection ->expects ($ this ->never ())
4751 ->method ('connect ' );
@@ -87,7 +91,10 @@ public function testShouldDoesReconnectIfConnectionFailed()
8791 ->expects ($ this ->once ())
8892 ->method ('close ' )
8993 ;
90- if (method_exists (Connection::class, 'connect ' )) {
94+ if (
95+ method_exists (Connection::class, 'connect ' )
96+ && (new ReflectionMethod (Connection::class, 'connect ' ))->isPublic ()
97+ ) {
9198 // DBAL < 4
9299 $ connection ->expects ($ this ->once ())
93100 ->method ('connect ' );
You can’t perform that action at this time.
0 commit comments