@@ -144,6 +144,37 @@ public function testSendOneDeadAndRecoveryWithinRetryPeriod()
144
144
$ this ->assertTransports ($ t , 1 , []);
145
145
}
146
146
147
+ public function testExceptionHandlerReceivesExceptions ()
148
+ {
149
+ $ t1 = $ this ->createMock (TransportInterface::class);
150
+ $ t1 ->expects ($ this ->exactly (2 ))->method ('send ' );
151
+
152
+ $ t2 = $ this ->createMock (TransportInterface::class);
153
+ $ t2 ->expects ($ this ->exactly (1 ))
154
+ ->method ('send ' )
155
+ ->willReturnCallback (function () {
156
+ throw new TransportException ();
157
+ });
158
+
159
+ $ eh = $ this
160
+ ->getMockBuilder (\stdClass::class)
161
+ ->addMethods (['__invoke ' ])
162
+ ->getMock ();
163
+ $ eh ->expects ($ this ->exactly (1 ))
164
+ ->method ('__invoke ' )
165
+ ->willReturnCallback (function (TransportExceptionInterface $ e ) {
166
+ $ this ->assertInstanceOf (TransportException::class, $ e );
167
+ });
168
+
169
+ $ t = new RoundRobinTransport ([$ t1 , $ t2 ], exceptionHandler: $ eh );
170
+ $ p = new \ReflectionProperty ($ t , 'cursor ' );
171
+ $ p ->setValue ($ t , 0 );
172
+ $ t ->send (new RawMessage ('' ));
173
+ $ this ->assertTransports ($ t , 1 , []);
174
+ $ t ->send (new RawMessage ('' ));
175
+ $ this ->assertTransports ($ t , 1 , [$ t2 ]);
176
+ }
177
+
147
178
public function testFailureDebugInformation ()
148
179
{
149
180
$ t1 = $ this ->createMock (TransportInterface::class);
0 commit comments