@@ -24,26 +24,26 @@ public function testShouldImplementMessageConsumerInterface()
24
24
25
25
public function testCouldBeConstructedWithRequiredAttributes ()
26
26
{
27
- new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
27
+ new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
28
28
}
29
29
30
30
public function testCouldGetQueue ()
31
31
{
32
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ dest = new StompDestination ());
32
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ dest = $ this -> createDummyDestination ());
33
33
34
34
$ this ->assertSame ($ dest , $ consumer ->getQueue ());
35
35
}
36
36
37
37
public function testShouldReturnDefaultAckMode ()
38
38
{
39
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
39
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
40
40
41
41
$ this ->assertSame (StompConsumer::ACK_CLIENT_INDIVIDUAL , $ consumer ->getAckMode ());
42
42
}
43
43
44
44
public function testCouldSetGetAckMethod ()
45
45
{
46
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
46
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
47
47
$ consumer ->setAckMode (StompConsumer::ACK_CLIENT );
48
48
49
49
$ this ->assertSame (StompConsumer::ACK_CLIENT , $ consumer ->getAckMode ());
@@ -54,20 +54,20 @@ public function testShouldThrowLogicExceptionIfAckModeIsInvalid()
54
54
$ this ->expectException (\LogicException::class);
55
55
$ this ->expectExceptionMessage ('Ack mode is not valid: "invalid-ack-mode" ' );
56
56
57
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
57
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
58
58
$ consumer ->setAckMode ('invalid-ack-mode ' );
59
59
}
60
60
61
61
public function testShouldReturnDefaultPrefetchCount ()
62
62
{
63
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
63
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
64
64
65
65
$ this ->assertSame (1 , $ consumer ->getPrefetchCount ());
66
66
}
67
67
68
68
public function testCouldSetGetPrefetchCount ()
69
69
{
70
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
70
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
71
71
$ consumer ->setPrefetchCount (123 );
72
72
73
73
$ this ->assertSame (123 , $ consumer ->getPrefetchCount ());
@@ -78,7 +78,7 @@ public function testAcknowledgeShouldThrowInvalidMessageExceptionIfMessageIsWron
78
78
$ this ->expectException (InvalidMessageException::class);
79
79
$ this ->expectExceptionMessage ('The message must be an instance of ' );
80
80
81
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
81
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
82
82
$ consumer ->acknowledge ($ this ->createMock (PsrMessage::class));
83
83
}
84
84
@@ -106,7 +106,7 @@ public function testShouldAcknowledgeMessage()
106
106
$ message = new StompMessage ();
107
107
$ message ->setFrame (new Frame ());
108
108
109
- $ consumer = new StompConsumer ($ client , new StompDestination ());
109
+ $ consumer = new StompConsumer ($ client , $ this -> createDummyDestination ());
110
110
$ consumer ->acknowledge ($ message );
111
111
}
112
112
@@ -115,7 +115,7 @@ public function testRejectShouldThrowInvalidMessageExceptionIfMessageIsWrongType
115
115
$ this ->expectException (InvalidMessageException::class);
116
116
$ this ->expectExceptionMessage ('The message must be an instance of ' );
117
117
118
- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
118
+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
119
119
$ consumer ->reject ($ this ->createMock (PsrMessage::class));
120
120
}
121
121
@@ -143,7 +143,7 @@ public function testShouldRejectMessage()
143
143
$ message = new StompMessage ();
144
144
$ message ->setFrame (new Frame ());
145
145
146
- $ consumer = new StompConsumer ($ client , new StompDestination ());
146
+ $ consumer = new StompConsumer ($ client , $ this -> createDummyDestination ());
147
147
$ consumer ->reject ($ message );
148
148
149
149
$ this ->assertSame (['requeue ' => 'false ' ], $ frame ->getHeaders ());
@@ -173,7 +173,7 @@ public function testShouldRejectAndRequeueMessage()
173
173
$ message = new StompMessage ();
174
174
$ message ->setFrame (new Frame ());
175
175
176
- $ consumer = new StompConsumer ($ client , new StompDestination ());
176
+ $ consumer = new StompConsumer ($ client , $ this -> createDummyDestination ());
177
177
$ consumer ->reject ($ message , true );
178
178
179
179
$ this ->assertSame (['requeue ' => 'true ' ], $ frame ->getHeaders ());
@@ -210,7 +210,7 @@ public function testShouldReceiveMessageNoWait()
210
210
$ message = new StompMessage ();
211
211
$ message ->setFrame (new Frame ());
212
212
213
- $ destination = new StompDestination ();
213
+ $ destination = $ this -> createDummyDestination ();
214
214
$ destination ->setType (StompDestination::TYPE_QUEUE );
215
215
$ destination ->setStompName ('name ' );
216
216
@@ -247,7 +247,7 @@ public function testReceiveMessageNoWaitShouldSubscribeOnlyOnce()
247
247
$ message = new StompMessage ();
248
248
$ message ->setFrame (new Frame ());
249
249
250
- $ destination = new StompDestination ();
250
+ $ destination = $ this -> createDummyDestination ();
251
251
$ destination ->setType (StompDestination::TYPE_QUEUE );
252
252
$ destination ->setStompName ('name ' );
253
253
@@ -280,7 +280,7 @@ public function testShouldAddExtraHeadersOnSubscribe()
280
280
->method ('readMessageFrame ' )
281
281
;
282
282
283
- $ destination = new StompDestination ();
283
+ $ destination = $ this -> createDummyDestination ();
284
284
$ destination ->setStompName ('name ' );
285
285
$ destination ->setType (StompDestination::TYPE_QUEUE );
286
286
$ destination ->setDurable (true );
@@ -340,7 +340,7 @@ public function testShouldConvertStompMessageFrameToMessage()
340
340
->willReturn ($ stompMessageFrame )
341
341
;
342
342
343
- $ destination = new StompDestination ();
343
+ $ destination = $ this -> createDummyDestination ();
344
344
$ destination ->setStompName ('name ' );
345
345
$ destination ->setType (StompDestination::TYPE_QUEUE );
346
346
@@ -381,7 +381,7 @@ public function testShouldThrowLogicExceptionIfFrameIsNotMessageFrame()
381
381
->willReturn ($ stompMessageFrame )
382
382
;
383
383
384
- $ destination = new StompDestination ();
384
+ $ destination = $ this -> createDummyDestination ();
385
385
$ destination ->setStompName ('name ' );
386
386
$ destination ->setType (StompDestination::TYPE_QUEUE );
387
387
@@ -418,7 +418,7 @@ public function testShouldReceiveWithUnlimitedTimeout()
418
418
->willReturn (new Frame ('MESSAGE ' ))
419
419
;
420
420
421
- $ destination = new StompDestination ();
421
+ $ destination = $ this -> createDummyDestination ();
422
422
$ destination ->setStompName ('name ' );
423
423
$ destination ->setType (StompDestination::TYPE_QUEUE );
424
424
@@ -454,7 +454,7 @@ public function testShouldReceiveWithTimeout()
454
454
->willReturn (new Frame ('MESSAGE ' ))
455
455
;
456
456
457
- $ destination = new StompDestination ();
457
+ $ destination = $ this -> createDummyDestination ();
458
458
$ destination ->setStompName ('name ' );
459
459
$ destination ->setType (StompDestination::TYPE_QUEUE );
460
460
@@ -480,7 +480,7 @@ public function testShouldReceiveWithoutSubscribeIfTempQueue()
480
480
$ message = new StompMessage ();
481
481
$ message ->setFrame (new Frame ());
482
482
483
- $ destination = new StompDestination ();
483
+ $ destination = $ this -> createDummyDestination ();
484
484
$ destination ->setType (StompDestination::TYPE_TEMP_QUEUE );
485
485
$ destination ->setStompName ('name ' );
486
486
@@ -503,7 +503,7 @@ public function testShouldReceiveNoWaitWithoutSubscribeIfTempQueue()
503
503
$ message = new StompMessage ();
504
504
$ message ->setFrame (new Frame ());
505
505
506
- $ destination = new StompDestination ();
506
+ $ destination = $ this -> createDummyDestination ();
507
507
$ destination ->setType (StompDestination::TYPE_TEMP_QUEUE );
508
508
$ destination ->setStompName ('name ' );
509
509
@@ -513,7 +513,7 @@ public function testShouldReceiveNoWaitWithoutSubscribeIfTempQueue()
513
513
514
514
public function testShouldGenerateUniqueSubscriptionIdPerConsumer ()
515
515
{
516
- $ destination = new StompDestination ();
516
+ $ destination = $ this -> createDummyDestination ();
517
517
$ destination ->setType (StompDestination::TYPE_QUEUE );
518
518
$ destination ->setStompName ('name ' );
519
519
@@ -530,7 +530,7 @@ public function testShouldGenerateUniqueSubscriptionIdPerConsumer()
530
530
531
531
public function testShouldUseTempQueueNameAsSubscriptionId ()
532
532
{
533
- $ destination = new StompDestination ();
533
+ $ destination = $ this -> createDummyDestination ();
534
534
$ destination ->setType (StompDestination::TYPE_TEMP_QUEUE );
535
535
$ destination ->setStompName ('foo ' );
536
536
@@ -554,4 +554,13 @@ private function createStompClientMock()
554
554
{
555
555
return $ this ->createMock (BufferedStompClient::class);
556
556
}
557
+
558
+ private function createDummyDestination (): StompDestination
559
+ {
560
+ $ destination = new StompDestination ();
561
+ $ destination ->setStompName ('aName ' );
562
+ $ destination ->setType (StompDestination::TYPE_QUEUE );
563
+
564
+ return $ destination ;
565
+ }
557
566
}
0 commit comments