@@ -38,7 +38,7 @@ protected function prepareAMQPChannel()
38
38
*
39
39
* @dataProvider processMessageProvider
40
40
*/
41
- public function testProcessMessage ($ processFlag , $ expectedMethod , $ expectedRequeue = null )
41
+ public function testProcessMessage ($ processFlag , $ expectedMethod = null , $ expectedRequeue = null )
42
42
{
43
43
$ amqpConnection = $ this ->prepareAMQPConnection ();
44
44
$ amqpChannel = $ this ->prepareAMQPChannel ();
@@ -52,18 +52,24 @@ public function testProcessMessage($processFlag, $expectedMethod, $expectedReque
52
52
$ amqpMessage ->delivery_info ['channel ' ] = $ amqpChannel ;
53
53
$ amqpMessage ->delivery_info ['delivery_tag ' ] = 0 ;
54
54
55
- $ amqpChannel ->expects ($ this ->any ())
56
- ->method ('basic_reject ' )
57
- ->will ($ this ->returnCallback (function ($ delivery_tag , $ requeue ) use ($ expectedMethod , $ expectedRequeue ) {
58
- \PHPUnit_Framework_Assert::assertSame ($ expectedMethod , 'basic_reject ' ); // Check if this function should be called.
59
- \PHPUnit_Framework_Assert::assertSame ($ requeue , $ expectedRequeue ); // Check if the message should be requeued.
60
- }));
61
-
62
- $ amqpChannel ->expects ($ this ->any ())
63
- ->method ('basic_ack ' )
64
- ->will ($ this ->returnCallback (function ($ delivery_tag ) use ($ expectedMethod ) {
65
- \PHPUnit_Framework_Assert::assertSame ($ expectedMethod , 'basic_ack ' ); // Check if this function should be called.
66
- }));
55
+ if ($ expectedMethod ) {
56
+ $ amqpChannel ->expects ($ this ->any ())
57
+ ->method ('basic_reject ' )
58
+ ->will ($ this ->returnCallback (function ($ delivery_tag , $ requeue ) use ($ expectedMethod , $ expectedRequeue ) {
59
+ \PHPUnit_Framework_Assert::assertSame ($ expectedMethod , 'basic_reject ' ); // Check if this function should be called.
60
+ \PHPUnit_Framework_Assert::assertSame ($ requeue , $ expectedRequeue ); // Check if the message should be requeued.
61
+ }));
62
+
63
+ $ amqpChannel ->expects ($ this ->any ())
64
+ ->method ('basic_ack ' )
65
+ ->will ($ this ->returnCallback (function ($ delivery_tag ) use ($ expectedMethod ) {
66
+ \PHPUnit_Framework_Assert::assertSame ($ expectedMethod , 'basic_ack ' ); // Check if this function should be called.
67
+ }));
68
+ } else {
69
+ $ amqpChannel ->expects ($ this ->never ())->method ('basic_reject ' );
70
+ $ amqpChannel ->expects ($ this ->never ())->method ('basic_ack ' );
71
+ $ amqpChannel ->expects ($ this ->never ())->method ('basic_nack ' );
72
+ }
67
73
$ eventDispatcher = $ this ->getMockBuilder ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' )
68
74
->getMock ();
69
75
$ consumer ->setEventDispatcher ($ eventDispatcher );
@@ -87,6 +93,7 @@ public function processMessageProvider()
87
93
array (ConsumerInterface::MSG_ACK , 'basic_ack ' ), // Remove message from queue only if callback return not false
88
94
array (ConsumerInterface::MSG_REJECT_REQUEUE , 'basic_reject ' , true ), // Reject and requeue message to RabbitMQ
89
95
array (ConsumerInterface::MSG_REJECT , 'basic_reject ' , false ), // Reject and drop
96
+ array (ConsumerInterface::MSG_ACK_SENT ), // ack not sent by the consumer but should be sent by the implementer of ConsumerInterface
90
97
);
91
98
}
92
99
0 commit comments