Skip to content

Commit b5f7b5b

Browse files
committed
Test fixes.
1 parent f3f9273 commit b5f7b5b

7 files changed

Lines changed: 47 additions & 45 deletions

File tree

‎pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Enqueue\Client\MessagePriority;
1313
use Enqueue\Client\Route;
1414
use Enqueue\Client\RouteCollection;
15+
use Enqueue\Stomp\ExtensionType;
1516
use Enqueue\Stomp\StompContext;
1617
use Enqueue\Stomp\StompDestination;
1718
use Enqueue\Stomp\StompMessage;
@@ -47,7 +48,7 @@ public function testShouldBeSubClassOfStompDriver()
4748

4849
public function testShouldCreateAndReturnStompQueueInstance()
4950
{
50-
$expectedQueue = new StompDestination();
51+
$expectedQueue = new StompDestination(ExtensionType::RABBITMQ);
5152

5253
$context = $this->createContextMock();
5354
$context
@@ -185,10 +186,10 @@ public function testShouldInitDeliveryDelayIfDelayPropertyOnSendToProcessor()
185186

186187
public function shouldSendMessageToDelayExchangeIfDelaySet()
187188
{
188-
$queue = new StompDestination();
189+
$queue = new StompDestination(ExtensionType::RABBITMQ);
189190
$queue->setStompName('queueName');
190191

191-
$delayTopic = new StompDestination();
192+
$delayTopic = new StompDestination(ExtensionType::RABBITMQ);
192193
$delayTopic->setStompName('delayTopic');
193194

194195
$transportMessage = new StompMessage();
@@ -339,7 +340,7 @@ public function testShouldSetupBroker()
339340
->expects($this->any())
340341
->method('createQueue')
341342
->willReturnCallback(function (string $name) {
342-
$destination = new StompDestination();
343+
$destination = new StompDestination(ExtensionType::RABBITMQ);
343344
$destination->setType(StompDestination::TYPE_QUEUE);
344345
$destination->setStompName($name);
345346

@@ -431,7 +432,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
431432
->expects($this->any())
432433
->method('createQueue')
433434
->willReturnCallback(function (string $name) {
434-
$destination = new StompDestination();
435+
$destination = new StompDestination(ExtensionType::RABBITMQ);
435436
$destination->setType(StompDestination::TYPE_QUEUE);
436437
$destination->setStompName($name);
437438

@@ -442,7 +443,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
442443
->expects($this->any())
443444
->method('createTopic')
444445
->willReturnCallback(function (string $name) {
445-
$destination = new StompDestination();
446+
$destination = new StompDestination(ExtensionType::RABBITMQ);
446447
$destination->setType(StompDestination::TYPE_TOPIC);
447448
$destination->setStompName($name);
448449

@@ -503,7 +504,7 @@ protected function createProducerMock(): InteropProducer
503504
*/
504505
protected function createQueue(string $name): InteropQueue
505506
{
506-
$destination = new StompDestination();
507+
$destination = new StompDestination(ExtensionType::RABBITMQ);
507508
$destination->setType(StompDestination::TYPE_QUEUE);
508509
$destination->setStompName($name);
509510

@@ -515,7 +516,7 @@ protected function createQueue(string $name): InteropQueue
515516
*/
516517
protected function createTopic(string $name): InteropTopic
517518
{
518-
$destination = new StompDestination();
519+
$destination = new StompDestination(ExtensionType::RABBITMQ);
519520
$destination->setType(StompDestination::TYPE_TOPIC);
520521
$destination->setStompName($name);
521522

‎pkg/enqueue/Tests/Client/Driver/StompDriverTest.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Enqueue\Client\Message;
1010
use Enqueue\Client\MessagePriority;
1111
use Enqueue\Client\RouteCollection;
12+
use Enqueue\Stomp\ExtensionType;
1213
use Enqueue\Stomp\StompContext;
1314
use Enqueue\Stomp\StompDestination;
1415
use Enqueue\Stomp\StompMessage;
@@ -127,7 +128,7 @@ protected function createProducerMock(): InteropProducer
127128
*/
128129
protected function createQueue(string $name): InteropQueue
129130
{
130-
$destination = new StompDestination();
131+
$destination = new StompDestination(ExtensionType::RABBITMQ);
131132
$destination->setType(StompDestination::TYPE_QUEUE);
132133
$destination->setStompName($name);
133134

@@ -139,7 +140,7 @@ protected function createQueue(string $name): InteropQueue
139140
*/
140141
protected function createTopic(string $name): InteropTopic
141142
{
142-
$destination = new StompDestination();
143+
$destination = new StompDestination(ExtensionType::RABBITMQ);
143144
$destination->setType(StompDestination::TYPE_TOPIC);
144145
$destination->setStompName($name);
145146

‎pkg/stomp/StompContext.php‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class StompContext implements Context
4040

4141
/**
4242
* @param BufferedStompClient|callable $stomp
43-
* @param string $extensionType
4443
*/
4544
public function __construct($stomp, string $extensionType)
4645
{
@@ -205,10 +204,7 @@ public function getStomp(): BufferedStompClient
205204
if (false == $this->stomp) {
206205
$stomp = call_user_func($this->stompFactory);
207206
if (false == $stomp instanceof BufferedStompClient) {
208-
throw new \LogicException(sprintf(
209-
'The factory must return instance of BufferedStompClient. It returns %s',
210-
is_object($stomp) ? get_class($stomp) : gettype($stomp)
211-
));
207+
throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? get_class($stomp) : gettype($stomp)));
212208
}
213209

214210
$this->stomp = $stomp;

‎pkg/stomp/Tests/StompConsumerTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Enqueue\Stomp\Tests;
44

55
use Enqueue\Stomp\BufferedStompClient;
6+
use Enqueue\Stomp\ExtensionType;
67
use Enqueue\Stomp\StompConsumer;
78
use Enqueue\Stomp\StompDestination;
89
use Enqueue\Stomp\StompMessage;
@@ -557,7 +558,7 @@ private function createStompClientMock()
557558

558559
private function createDummyDestination(): StompDestination
559560
{
560-
$destination = new StompDestination();
561+
$destination = new StompDestination(ExtensionType::RABBITMQ);
561562
$destination->setStompName('aName');
562563
$destination->setType(StompDestination::TYPE_QUEUE);
563564

‎pkg/stomp/Tests/StompContextTest.php‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Enqueue\Stomp\Tests;
44

55
use Enqueue\Stomp\BufferedStompClient;
6+
use Enqueue\Stomp\ExtensionType;
67
use Enqueue\Stomp\StompConsumer;
78
use Enqueue\Stomp\StompContext;
89
use Enqueue\Stomp\StompDestination;
@@ -24,27 +25,27 @@ public function testShouldImplementSessionInterface()
2425

2526
public function testCouldBeCreatedWithRequiredArguments()
2627
{
27-
new StompContext($this->createStompClientMock());
28+
new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
2829
}
2930

3031
public function testCouldBeConstructedWithExtChannelCallbackFactoryAsFirstArgument()
3132
{
3233
new StompContext(function () {
3334
return $this->createStompClientMock();
34-
});
35+
}, ExtensionType::RABBITMQ);
3536
}
3637

3738
public function testThrowIfNeitherCallbackNorExtChannelAsFirstArgument()
3839
{
3940
$this->expectException(\InvalidArgumentException::class);
4041
$this->expectExceptionMessage('The stomp argument must be either BufferedStompClient or callable that return BufferedStompClient.');
4142

42-
new StompContext(new \stdClass());
43+
new StompContext(new \stdClass(), ExtensionType::RABBITMQ);
4344
}
4445

4546
public function testShouldCreateMessageInstance()
4647
{
47-
$context = new StompContext($this->createStompClientMock());
48+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
4849

4950
$message = $context->createMessage('the body', ['key' => 'value'], ['hkey' => 'hvalue']);
5051

@@ -56,7 +57,7 @@ public function testShouldCreateMessageInstance()
5657

5758
public function testShouldCreateQueueInstance()
5859
{
59-
$context = new StompContext($this->createStompClientMock());
60+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
6061

6162
$queue = $context->createQueue('the name');
6263

@@ -68,7 +69,7 @@ public function testShouldCreateQueueInstance()
6869

6970
public function testCreateQueueShouldCreateDestinationIfNameIsFullDestinationString()
7071
{
71-
$context = new StompContext($this->createStompClientMock());
72+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
7273

7374
$destination = $context->createQueue('/amq/queue/name/routing-key');
7475

@@ -81,7 +82,7 @@ public function testCreateQueueShouldCreateDestinationIfNameIsFullDestinationStr
8182

8283
public function testShouldCreateTopicInstanceWithExchangePrefix()
8384
{
84-
$context = new StompContext($this->createStompClientMock());
85+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
8586

8687
$topic = $context->createTopic('the name');
8788

@@ -93,7 +94,7 @@ public function testShouldCreateTopicInstanceWithExchangePrefix()
9394

9495
public function testShouldCreateTopicInstanceWithTopicPrefix()
9596
{
96-
$context = new StompContext($this->createStompClientMock(), false);
97+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
9798

9899
$topic = $context->createTopic('the name');
99100

@@ -105,7 +106,7 @@ public function testShouldCreateTopicInstanceWithTopicPrefix()
105106

106107
public function testCreateTopicShouldCreateDestinationIfNameIsFullDestinationString()
107108
{
108-
$context = new StompContext($this->createStompClientMock());
109+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
109110

110111
$destination = $context->createTopic('/amq/queue/name/routing-key');
111112

@@ -121,20 +122,20 @@ public function testThrowInvalidDestinationException()
121122
$this->expectException(InvalidDestinationException::class);
122123
$this->expectExceptionMessage('The destination must be an instance of');
123124

124-
$session = new StompContext($this->createStompClientMock());
125+
$session = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
125126
$session->createConsumer($this->createMock(Queue::class));
126127
}
127128

128129
public function testShouldCreateMessageConsumerInstance()
129130
{
130-
$context = new StompContext($this->createStompClientMock());
131+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
131132

132133
$this->assertInstanceOf(StompConsumer::class, $context->createConsumer($this->createDummyDestination()));
133134
}
134135

135136
public function testShouldCreateMessageProducerInstance()
136137
{
137-
$context = new StompContext($this->createStompClientMock());
138+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
138139

139140
$this->assertInstanceOf(StompProducer::class, $context->createProducer());
140141
}
@@ -147,7 +148,7 @@ public function testShouldCloseConnections()
147148
->method('disconnect')
148149
;
149150

150-
$context = new StompContext($client);
151+
$context = new StompContext($client, ExtensionType::RABBITMQ);
151152

152153
$context->createProducer();
153154
$context->createConsumer($this->createDummyDestination());
@@ -160,7 +161,7 @@ public function testCreateDestinationShouldThrowLogicExceptionIfTypeIsInvalid()
160161
$this->expectException(\LogicException::class);
161162
$this->expectExceptionMessage('Destination name is invalid, cant find type: "/invalid-type/name"');
162163

163-
$context = new StompContext($this->createStompClientMock());
164+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
164165
$context->createDestination('/invalid-type/name');
165166
}
166167

@@ -169,7 +170,7 @@ public function testCreateDestinationShouldThrowLogicExceptionIfExtraSlashFound(
169170
$this->expectException(\LogicException::class);
170171
$this->expectExceptionMessage('Destination name is invalid, found extra / char: "/queue/name/routing-key/extra');
171172

172-
$context = new StompContext($this->createStompClientMock());
173+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
173174
$context->createDestination('/queue/name/routing-key/extra');
174175
}
175176

@@ -178,7 +179,7 @@ public function testCreateDestinationShouldThrowLogicExceptionIfNameIsEmpty()
178179
$this->expectException(\LogicException::class);
179180
$this->expectExceptionMessage('Destination name is invalid, name is empty: "/queue/"');
180181

181-
$context = new StompContext($this->createStompClientMock());
182+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
182183
$context->createDestination('/queue/');
183184
}
184185

@@ -187,13 +188,13 @@ public function testCreateDestinationShouldThrowLogicExceptionIfRoutingKeyIsEmpt
187188
$this->expectException(\LogicException::class);
188189
$this->expectExceptionMessage('Destination name is invalid, routing key is empty: "/queue/name/"');
189190

190-
$context = new StompContext($this->createStompClientMock());
191+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
191192
$context->createDestination('/queue/name/');
192193
}
193194

194195
public function testCreateDestinationShouldParseStringAndCreateDestination()
195196
{
196-
$context = new StompContext($this->createStompClientMock());
197+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
197198
$destination = $context->createDestination('/amq/queue/name/routing-key');
198199

199200
$this->assertEquals('amq/queue', $destination->getType());
@@ -204,7 +205,7 @@ public function testCreateDestinationShouldParseStringAndCreateDestination()
204205

205206
public function testCreateTemporaryQueue()
206207
{
207-
$context = new StompContext($this->createStompClientMock());
208+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
208209
$tempQueue = $context->createTemporaryQueue();
209210

210211
$this->assertEquals('temp-queue', $tempQueue->getType());
@@ -215,7 +216,7 @@ public function testCreateTemporaryQueue()
215216

216217
public function testCreateTemporaryQueuesWithUniqueNames()
217218
{
218-
$context = new StompContext($this->createStompClientMock());
219+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
219220
$fooTempQueue = $context->createTemporaryQueue();
220221
$barTempQueue = $context->createTemporaryQueue();
221222

@@ -227,7 +228,7 @@ public function testCreateTemporaryQueuesWithUniqueNames()
227228

228229
public function testShouldGetBufferedStompClient()
229230
{
230-
$context = new StompContext($this->createStompClientMock());
231+
$context = new StompContext($this->createStompClientMock(), ExtensionType::RABBITMQ);
231232

232233
$this->assertInstanceOf(BufferedStompClient::class, $context->getStomp());
233234
}
@@ -242,7 +243,7 @@ private function createStompClientMock()
242243

243244
private function createDummyDestination(): StompDestination
244245
{
245-
$destination = new StompDestination();
246+
$destination = new StompDestination(ExtensionType::RABBITMQ);
246247
$destination->setStompName('aName');
247248
$destination->setType(StompDestination::TYPE_QUEUE);
248249

‎pkg/stomp/Tests/StompDestinationTest.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Enqueue\Stomp\Tests;
44

5+
use Enqueue\Stomp\ExtensionType;
56
use Enqueue\Stomp\StompDestination;
67
use Enqueue\Test\ClassExtensionTrait;
78
use Interop\Queue\Queue;
@@ -19,7 +20,7 @@ public function testShouldImplementsTopicAndQueueInterfaces()
1920

2021
public function testShouldReturnDestinationStringWithRoutingKey()
2122
{
22-
$destination = new StompDestination();
23+
$destination = new StompDestination(ExtensionType::RABBITMQ);
2324
$destination->setType(StompDestination::TYPE_AMQ_QUEUE);
2425
$destination->setStompName('name');
2526
$destination->setRoutingKey('routing-key');
@@ -32,7 +33,7 @@ public function testShouldReturnDestinationStringWithRoutingKey()
3233

3334
public function testShouldReturnDestinationStringWithoutRoutingKey()
3435
{
35-
$destination = new StompDestination();
36+
$destination = new StompDestination(ExtensionType::RABBITMQ);
3637
$destination->setType(StompDestination::TYPE_TOPIC);
3738
$destination->setStompName('name');
3839

@@ -47,7 +48,7 @@ public function testShouldThrowLogicExceptionIfNameIsNotSet()
4748
$this->expectException(\LogicException::class);
4849
$this->expectExceptionMessage('Destination name is not set');
4950

50-
$destination = new StompDestination();
51+
$destination = new StompDestination(ExtensionType::RABBITMQ);
5152
$destination->setType(StompDestination::TYPE_QUEUE);
5253
$destination->setStompName('');
5354

@@ -59,7 +60,7 @@ public function testSetTypeShouldThrowLogicExceptionIfTypeIsInvalid()
5960
$this->expectException(\LogicException::class);
6061
$this->expectExceptionMessage('Invalid destination type: "invalid-type"');
6162

62-
$destination = new StompDestination();
63+
$destination = new StompDestination(ExtensionType::RABBITMQ);
6364
$destination->setType('invalid-type');
6465
}
6566
}

0 commit comments

Comments
 (0)