@@ -24,26 +24,26 @@ public function testShouldImplementMessageConsumerInterface()
2424
2525 public function testCouldBeConstructedWithRequiredAttributes ()
2626 {
27- new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
27+ new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
2828 }
2929
3030 public function testCouldGetQueue ()
3131 {
32- $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ dest = new StompDestination ());
32+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ dest = $ this -> createDummyDestination ());
3333
3434 $ this ->assertSame ($ dest , $ consumer ->getQueue ());
3535 }
3636
3737 public function testShouldReturnDefaultAckMode ()
3838 {
39- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
39+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
4040
4141 $ this ->assertSame (StompConsumer::ACK_CLIENT_INDIVIDUAL , $ consumer ->getAckMode ());
4242 }
4343
4444 public function testCouldSetGetAckMethod ()
4545 {
46- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
46+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
4747 $ consumer ->setAckMode (StompConsumer::ACK_CLIENT );
4848
4949 $ this ->assertSame (StompConsumer::ACK_CLIENT , $ consumer ->getAckMode ());
@@ -54,20 +54,20 @@ public function testShouldThrowLogicExceptionIfAckModeIsInvalid()
5454 $ this ->expectException (\LogicException::class);
5555 $ this ->expectExceptionMessage ('Ack mode is not valid: "invalid-ack-mode" ' );
5656
57- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
57+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
5858 $ consumer ->setAckMode ('invalid-ack-mode ' );
5959 }
6060
6161 public function testShouldReturnDefaultPrefetchCount ()
6262 {
63- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
63+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
6464
6565 $ this ->assertSame (1 , $ consumer ->getPrefetchCount ());
6666 }
6767
6868 public function testCouldSetGetPrefetchCount ()
6969 {
70- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
70+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
7171 $ consumer ->setPrefetchCount (123 );
7272
7373 $ this ->assertSame (123 , $ consumer ->getPrefetchCount ());
@@ -78,7 +78,7 @@ public function testAcknowledgeShouldThrowInvalidMessageExceptionIfMessageIsWron
7878 $ this ->expectException (InvalidMessageException::class);
7979 $ this ->expectExceptionMessage ('The message must be an instance of ' );
8080
81- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
81+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
8282 $ consumer ->acknowledge ($ this ->createMock (PsrMessage::class));
8383 }
8484
@@ -106,7 +106,7 @@ public function testShouldAcknowledgeMessage()
106106 $ message = new StompMessage ();
107107 $ message ->setFrame (new Frame ());
108108
109- $ consumer = new StompConsumer ($ client , new StompDestination ());
109+ $ consumer = new StompConsumer ($ client , $ this -> createDummyDestination ());
110110 $ consumer ->acknowledge ($ message );
111111 }
112112
@@ -115,7 +115,7 @@ public function testRejectShouldThrowInvalidMessageExceptionIfMessageIsWrongType
115115 $ this ->expectException (InvalidMessageException::class);
116116 $ this ->expectExceptionMessage ('The message must be an instance of ' );
117117
118- $ consumer = new StompConsumer ($ this ->createStompClientMock (), new StompDestination ());
118+ $ consumer = new StompConsumer ($ this ->createStompClientMock (), $ this -> createDummyDestination ());
119119 $ consumer ->reject ($ this ->createMock (PsrMessage::class));
120120 }
121121
@@ -143,7 +143,7 @@ public function testShouldRejectMessage()
143143 $ message = new StompMessage ();
144144 $ message ->setFrame (new Frame ());
145145
146- $ consumer = new StompConsumer ($ client , new StompDestination ());
146+ $ consumer = new StompConsumer ($ client , $ this -> createDummyDestination ());
147147 $ consumer ->reject ($ message );
148148
149149 $ this ->assertSame (['requeue ' => 'false ' ], $ frame ->getHeaders ());
@@ -173,7 +173,7 @@ public function testShouldRejectAndRequeueMessage()
173173 $ message = new StompMessage ();
174174 $ message ->setFrame (new Frame ());
175175
176- $ consumer = new StompConsumer ($ client , new StompDestination ());
176+ $ consumer = new StompConsumer ($ client , $ this -> createDummyDestination ());
177177 $ consumer ->reject ($ message , true );
178178
179179 $ this ->assertSame (['requeue ' => 'true ' ], $ frame ->getHeaders ());
@@ -210,7 +210,7 @@ public function testShouldReceiveMessageNoWait()
210210 $ message = new StompMessage ();
211211 $ message ->setFrame (new Frame ());
212212
213- $ destination = new StompDestination ();
213+ $ destination = $ this -> createDummyDestination ();
214214 $ destination ->setType (StompDestination::TYPE_QUEUE );
215215 $ destination ->setStompName ('name ' );
216216
@@ -247,7 +247,7 @@ public function testReceiveMessageNoWaitShouldSubscribeOnlyOnce()
247247 $ message = new StompMessage ();
248248 $ message ->setFrame (new Frame ());
249249
250- $ destination = new StompDestination ();
250+ $ destination = $ this -> createDummyDestination ();
251251 $ destination ->setType (StompDestination::TYPE_QUEUE );
252252 $ destination ->setStompName ('name ' );
253253
@@ -280,7 +280,7 @@ public function testShouldAddExtraHeadersOnSubscribe()
280280 ->method ('readMessageFrame ' )
281281 ;
282282
283- $ destination = new StompDestination ();
283+ $ destination = $ this -> createDummyDestination ();
284284 $ destination ->setStompName ('name ' );
285285 $ destination ->setType (StompDestination::TYPE_QUEUE );
286286 $ destination ->setDurable (true );
@@ -340,7 +340,7 @@ public function testShouldConvertStompMessageFrameToMessage()
340340 ->willReturn ($ stompMessageFrame )
341341 ;
342342
343- $ destination = new StompDestination ();
343+ $ destination = $ this -> createDummyDestination ();
344344 $ destination ->setStompName ('name ' );
345345 $ destination ->setType (StompDestination::TYPE_QUEUE );
346346
@@ -381,7 +381,7 @@ public function testShouldThrowLogicExceptionIfFrameIsNotMessageFrame()
381381 ->willReturn ($ stompMessageFrame )
382382 ;
383383
384- $ destination = new StompDestination ();
384+ $ destination = $ this -> createDummyDestination ();
385385 $ destination ->setStompName ('name ' );
386386 $ destination ->setType (StompDestination::TYPE_QUEUE );
387387
@@ -418,7 +418,7 @@ public function testShouldReceiveWithUnlimitedTimeout()
418418 ->willReturn (new Frame ('MESSAGE ' ))
419419 ;
420420
421- $ destination = new StompDestination ();
421+ $ destination = $ this -> createDummyDestination ();
422422 $ destination ->setStompName ('name ' );
423423 $ destination ->setType (StompDestination::TYPE_QUEUE );
424424
@@ -454,7 +454,7 @@ public function testShouldReceiveWithTimeout()
454454 ->willReturn (new Frame ('MESSAGE ' ))
455455 ;
456456
457- $ destination = new StompDestination ();
457+ $ destination = $ this -> createDummyDestination ();
458458 $ destination ->setStompName ('name ' );
459459 $ destination ->setType (StompDestination::TYPE_QUEUE );
460460
@@ -480,7 +480,7 @@ public function testShouldReceiveWithoutSubscribeIfTempQueue()
480480 $ message = new StompMessage ();
481481 $ message ->setFrame (new Frame ());
482482
483- $ destination = new StompDestination ();
483+ $ destination = $ this -> createDummyDestination ();
484484 $ destination ->setType (StompDestination::TYPE_TEMP_QUEUE );
485485 $ destination ->setStompName ('name ' );
486486
@@ -503,7 +503,7 @@ public function testShouldReceiveNoWaitWithoutSubscribeIfTempQueue()
503503 $ message = new StompMessage ();
504504 $ message ->setFrame (new Frame ());
505505
506- $ destination = new StompDestination ();
506+ $ destination = $ this -> createDummyDestination ();
507507 $ destination ->setType (StompDestination::TYPE_TEMP_QUEUE );
508508 $ destination ->setStompName ('name ' );
509509
@@ -513,7 +513,7 @@ public function testShouldReceiveNoWaitWithoutSubscribeIfTempQueue()
513513
514514 public function testShouldGenerateUniqueSubscriptionIdPerConsumer ()
515515 {
516- $ destination = new StompDestination ();
516+ $ destination = $ this -> createDummyDestination ();
517517 $ destination ->setType (StompDestination::TYPE_QUEUE );
518518 $ destination ->setStompName ('name ' );
519519
@@ -530,7 +530,7 @@ public function testShouldGenerateUniqueSubscriptionIdPerConsumer()
530530
531531 public function testShouldUseTempQueueNameAsSubscriptionId ()
532532 {
533- $ destination = new StompDestination ();
533+ $ destination = $ this -> createDummyDestination ();
534534 $ destination ->setType (StompDestination::TYPE_TEMP_QUEUE );
535535 $ destination ->setStompName ('foo ' );
536536
@@ -554,4 +554,13 @@ private function createStompClientMock()
554554 {
555555 return $ this ->createMock (BufferedStompClient::class);
556556 }
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+ }
557566}
0 commit comments