55use Enqueue \Client \Config ;
66use Enqueue \Client \DriverInterface ;
77use Enqueue \Client \DriverPreSend ;
8+ use Enqueue \Client \DriverSendResult ;
89use Enqueue \Client \ExtensionInterface ;
910use Enqueue \Client \Message ;
1011use Enqueue \Client \MessagePriority ;
1516use Enqueue \Rpc \RpcFactory ;
1617use Enqueue \Test \ClassExtensionTrait ;
1718use Enqueue \Tests \Mocks \CustomPrepareBodyClientExtension ;
19+ use Interop \Queue \Destination ;
20+ use Interop \Queue \Message as TransportMessage ;
1821use PHPUnit \Framework \TestCase ;
1922
2023class ProducerSendCommandTest extends TestCase
@@ -30,6 +33,7 @@ public function testShouldSendCommandToProcessor()
3033 ->expects ($ this ->once ())
3134 ->method ('sendToProcessor ' )
3235 ->with (self ::identicalTo ($ message ))
36+ ->willReturn ($ this ->createDriverSendResult ())
3337 ;
3438 $ driver
3539 ->expects ($ this ->never ())
@@ -55,6 +59,7 @@ public function testShouldSendCommandWithReply()
5559 ->expects ($ this ->once ())
5660 ->method ('sendToProcessor ' )
5761 ->with (self ::identicalTo ($ message ))
62+ ->willReturn ($ this ->createDriverSendResult ())
5863 ;
5964 $ driver
6065 ->expects ($ this ->never ())
@@ -100,6 +105,7 @@ public function testShouldSendCommandWithReplyAndCustomReplyQueueAndCorrelationI
100105 ->expects ($ this ->once ())
101106 ->method ('sendToProcessor ' )
102107 ->with (self ::identicalTo ($ message ))
108+ ->willReturn ($ this ->createDriverSendResult ())
103109 ;
104110 $ driver
105111 ->expects ($ this ->never ())
@@ -140,6 +146,11 @@ public function testShouldOverwriteExpectedMessageProperties()
140146 $ message ->setScope ('scopeShouldBeOverwritten ' );
141147
142148 $ driver = $ this ->createDriverStub ();
149+ $ driver
150+ ->expects ($ this ->once ())
151+ ->method ('sendToProcessor ' )
152+ ->willReturn ($ this ->createDriverSendResult ())
153+ ;
143154
144155 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
145156 $ producer ->sendCommand ('expectedCommand ' , $ message );
@@ -161,6 +172,7 @@ public function testShouldSendCommandWithoutPriorityByDefault()
161172 ->expects ($ this ->once ())
162173 ->method ('sendToProcessor ' )
163174 ->with (self ::identicalTo ($ message ))
175+ ->willReturn ($ this ->createDriverSendResult ())
164176 ;
165177
166178 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
@@ -179,6 +191,7 @@ public function testShouldSendCommandWithCustomPriority()
179191 ->expects ($ this ->once ())
180192 ->method ('sendToProcessor ' )
181193 ->with (self ::identicalTo ($ message ))
194+ ->willReturn ($ this ->createDriverSendResult ())
182195 ;
183196
184197 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
@@ -196,6 +209,7 @@ public function testShouldSendCommandWithGeneratedMessageId()
196209 ->expects ($ this ->once ())
197210 ->method ('sendToProcessor ' )
198211 ->with (self ::identicalTo ($ message ))
212+ ->willReturn ($ this ->createDriverSendResult ())
199213 ;
200214
201215 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
@@ -214,6 +228,7 @@ public function testShouldSendCommandWithCustomMessageId()
214228 ->expects ($ this ->once ())
215229 ->method ('sendToProcessor ' )
216230 ->with (self ::identicalTo ($ message ))
231+ ->willReturn ($ this ->createDriverSendResult ())
217232 ;
218233
219234 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
@@ -231,6 +246,7 @@ public function testShouldSendCommandWithGeneratedTimestamp()
231246 ->expects ($ this ->once ())
232247 ->method ('sendToProcessor ' )
233248 ->with (self ::identicalTo ($ message ))
249+ ->willReturn ($ this ->createDriverSendResult ())
234250 ;
235251
236252 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
@@ -249,6 +265,7 @@ public function testShouldSendCommandWithCustomTimestamp()
249265 ->expects ($ this ->once ())
250266 ->method ('sendToProcessor ' )
251267 ->with (self ::identicalTo ($ message ))
268+ ->willReturn ($ this ->createDriverSendResult ())
252269 ;
253270
254271 $ producer = new Producer ($ driver , $ this ->createRpcFactoryMock ());
@@ -265,6 +282,8 @@ public function testShouldSerializeMessageToJsonByDefault()
265282 ->method ('sendToProcessor ' )
266283 ->willReturnCallback (function (Message $ message ) {
267284 $ this ->assertSame ('{"foo":"fooVal"} ' , $ message ->getBody ());
285+
286+ return $ this ->createDriverSendResult ();
268287 })
269288 ;
270289
@@ -280,6 +299,8 @@ public function testShouldSerializeMessageByCustomExtension()
280299 ->method ('sendToProcessor ' )
281300 ->willReturnCallback (function (Message $ message ) {
282301 $ this ->assertSame ('theCommandBodySerializedByCustomExtension ' , $ message ->getBody ());
302+
303+ return $ this ->createDriverSendResult ();
283304 })
284305 ;
285306
@@ -301,6 +322,8 @@ public function testShouldSendCommandToApplicationRouter()
301322 self ::assertSame ('aBody ' , $ message ->getBody ());
302323 self ::assertNull ($ message ->getProperty (Config::PROCESSOR ));
303324 self ::assertSame ('command ' , $ message ->getProperty (Config::COMMAND ));
325+
326+ return $ this ->createDriverSendResult ();
304327 })
305328 ;
306329
@@ -338,6 +361,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToBus()
338361 $ driver
339362 ->expects ($ this ->once ())
340363 ->method ('sendToProcessor ' )
364+ ->willReturn ($ this ->createDriverSendResult ())
341365 ;
342366
343367 $ extension = $ this ->createMock (ExtensionInterface::class);
@@ -375,6 +399,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToApplication
375399 $ driver
376400 ->expects ($ this ->once ())
377401 ->method ('sendToProcessor ' )
402+ ->willReturn ($ this ->createDriverSendResult ())
378403 ;
379404
380405 $ extension = $ this ->createMock (ExtensionInterface::class);
@@ -412,6 +437,7 @@ public function testShouldCallPreDriverSendExtensionMethod()
412437 $ driver
413438 ->expects ($ this ->once ())
414439 ->method ('sendToProcessor ' )
440+ ->willReturn ($ this ->createDriverSendResult ())
415441 ;
416442
417443 $ extension = $ this ->createMock (ExtensionInterface::class);
@@ -443,6 +469,7 @@ public function testShouldCallPostSendExtensionMethod()
443469 $ driver
444470 ->expects ($ this ->once ())
445471 ->method ('sendToProcessor ' )
472+ ->willReturn ($ this ->createDriverSendResult ())
446473 ;
447474
448475 $ extension = $ this ->createMock (ExtensionInterface::class);
@@ -495,4 +522,12 @@ private function createDriverStub(): DriverInterface
495522
496523 return $ driverMock ;
497524 }
525+
526+ private function createDriverSendResult (): DriverSendResult
527+ {
528+ return new DriverSendResult (
529+ $ this ->createMock (Destination::class),
530+ $ this ->createMock (TransportMessage::class)
531+ );
532+ }
498533}
0 commit comments