Skip to content

Commit 2eec036

Browse files
authored
Merge pull request #61 from php-enqueue/client-hardcode-queue-name
[client] Add ability to hardcode queue name. It is used as is and not adjusted or modified in any way
2 parents cafd642 + 061faf7 commit 2eec036

File tree

93 files changed

+972
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+972
-443
lines changed

Diff for: bin/release

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fi
1313

1414
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
1515

16-
for REMOTE in origin psr-queue stomp amqp-ext fs redis dbal enqueue enqueue-bundle job-queue test
16+
for REMOTE in origin psr-queue stomp amqp-ext fs redis dbal null enqueue enqueue-bundle job-queue test
1717
do
1818
TMP_DIR="/tmp/enqueue-repo"
1919
REMOTE_URL=`git remote get-url $REMOTE`

Diff for: bin/subtree-split

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ remote amqp-ext [email protected]:php-enqueue/amqp-ext.git
5050
remote fs [email protected]:php-enqueue/fs.git
5151
remote redis [email protected]:php-enqueue/redis.git
5252
remote dbal [email protected]:php-enqueue/dbal.git
53+
remote null [email protected]:php-enqueue/null.git
5354
remote enqueue-bundle [email protected]:php-enqueue/enqueue-bundle.git
5455
remote job-queue [email protected]:php-enqueue/job-queue.git
5556
remote test [email protected]:php-enqueue/test.git
@@ -61,6 +62,7 @@ split 'pkg/amqp-ext' amqp-ext
6162
split 'pkg/fs' fs
6263
split 'pkg/redis' redis
6364
split 'pkg/dbal' dbal
65+
split 'pkg/null' null
6466
split 'pkg/enqueue-bundle' enqueue-bundle
6567
split 'pkg/job-queue' job-queue
6668
split 'pkg/test' test

Diff for: composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"enqueue/amqp-ext": "*@dev",
1111
"enqueue/redis": "*@dev",
1212
"enqueue/fs": "*@dev",
13+
"enqueue/null": "*@dev",
1314
"enqueue/dbal": "*@dev",
1415
"enqueue/enqueue-bundle": "*@dev",
1516
"enqueue/job-queue": "*@dev",
@@ -64,6 +65,10 @@
6465
"type": "path",
6566
"url": "pkg/fs"
6667
},
68+
{
69+
"type": "path",
70+
"url": "pkg/null"
71+
},
6772
{
6873
"type": "path",
6974
"url": "pkg/dbal"

Diff for: docs/transport/null.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Useful in tests for example.
1010
## Installation
1111

1212
```bash
13-
$ composer require enqueue/enqueue
13+
$ composer require enqueue/null
1414
```
1515

1616
## Create context
1717

1818
```php
1919
<?php
20-
use Enqueue\Transport\Null\NullConnectionFactory;
20+
use Enqueue\Null\NullConnectionFactory;
2121

2222
$connectionFactory = new NullConnectionFactory();
2323

Diff for: phpunit.xml.dist

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
<directory>pkg/enqueue/Tests</directory>
2222
</testsuite>
2323

24-
<testsuite name="stomp">
24+
<testsuite name="stomp transport">
2525
<directory>pkg/stomp/Tests</directory>
2626
</testsuite>
2727

28-
<testsuite name="amqp-ext">
28+
<testsuite name="amqp-ext transport">
2929
<directory>pkg/amqp-ext/Tests</directory>
3030
</testsuite>
3131

@@ -41,6 +41,10 @@
4141
<directory>pkg/dbal/Tests</directory>
4242
</testsuite>
4343

44+
<testsuite name="null transport">
45+
<directory>pkg/null/Tests</directory>
46+
</testsuite>
47+
4448
<testsuite name="enqueue-bundle">
4549
<directory>pkg/enqueue-bundle/Tests</directory>
4650
</testsuite>

Diff for: pkg/amqp-ext/Client/AmqpDriver.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ public function setupBroker(LoggerInterface $logger = null)
115115
*/
116116
public function createQueue($queueName)
117117
{
118-
$queue = $this->context->createQueue($this->config->createTransportQueueName($queueName));
118+
$transportName = $this->queueMetaRegistry->getQueueMeta($queueName)->getTransportName();
119+
120+
$queue = $this->context->createQueue($transportName);
119121
$queue->addFlag(AMQP_DURABLE);
120122

121123
return $queue;

Diff for: pkg/amqp-ext/Tests/AmqpContextTest.php

+15-12
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use Enqueue\Psr\PsrContext;
1313
use Enqueue\Psr\InvalidDestinationException;
1414
use Enqueue\Test\ClassExtensionTrait;
15-
use Enqueue\Transport\Null\NullQueue;
16-
use Enqueue\Transport\Null\NullTopic;
15+
use Enqueue\Null\NullQueue;
16+
use Enqueue\Null\NullTopic;
1717
use PHPUnit\Framework\TestCase;
1818

1919
class AmqpContextTest extends TestCase
@@ -96,7 +96,7 @@ public function testShouldThrowIfNotAmqpTopicGivenOnDeleteTopicCall()
9696
$context = new AmqpContext($this->createExtChannelMock());
9797

9898
$this->expectException(InvalidDestinationException::class);
99-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Transport\Null\NullTopic.');
99+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Null\NullTopic.');
100100
$context->deleteTopic(new NullTopic('aName'));
101101
}
102102

@@ -105,7 +105,7 @@ public function testShouldThrowIfNotAmqpTopicGivenOnDeclareTopicCall()
105105
$context = new AmqpContext($this->createExtChannelMock());
106106

107107
$this->expectException(InvalidDestinationException::class);
108-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Transport\Null\NullTopic.');
108+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Null\NullTopic.');
109109
$context->declareTopic(new NullTopic('aName'));
110110
}
111111

@@ -128,7 +128,7 @@ public function testShouldThrowIfNotAmqpQueueGivenOnDeleteQueueCall()
128128
$context = new AmqpContext($this->createExtChannelMock());
129129

130130
$this->expectException(InvalidDestinationException::class);
131-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Transport\Null\NullQueue.');
131+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Null\NullQueue.');
132132
$context->deleteQueue(new NullQueue('aName'));
133133
}
134134

@@ -137,7 +137,7 @@ public function testShouldThrowIfNotAmqpQueueGivenOnDeclareQueueCall()
137137
$context = new AmqpContext($this->createExtChannelMock());
138138

139139
$this->expectException(InvalidDestinationException::class);
140-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Transport\Null\NullQueue.');
140+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Null\NullQueue.');
141141
$context->declareQueue(new NullQueue('aName'));
142142
}
143143

@@ -172,7 +172,7 @@ public function testShouldThrowIfNotAmqpQueueGivenOnCreateConsumerCall()
172172
$context = new AmqpContext($this->createExtChannelMock());
173173

174174
$this->expectException(InvalidDestinationException::class);
175-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Transport\Null\NullQueue.');
175+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Null\NullQueue.');
176176
$context->createConsumer(new NullQueue('aName'));
177177
}
178178

@@ -181,7 +181,7 @@ public function testShouldThrowIfNotAmqpTopicGivenOnCreateConsumerCall()
181181
$context = new AmqpContext($this->createExtChannelMock());
182182

183183
$this->expectException(InvalidDestinationException::class);
184-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Transport\Null\NullTopic.');
184+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Null\NullTopic.');
185185
$context->createConsumer(new NullTopic('aName'));
186186
}
187187

@@ -291,7 +291,7 @@ public function testShouldThrowIfSourceNotAmqpTopicOnBindCall()
291291
$context = new AmqpContext($this->createExtChannelMock());
292292

293293
$this->expectException(InvalidDestinationException::class);
294-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Transport\Null\NullTopic.');
294+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpTopic but got Enqueue\Null\NullTopic.');
295295
$context->bind(new NullTopic('aName'), new AmqpQueue('aName'));
296296
}
297297

@@ -300,7 +300,7 @@ public function testShouldThrowIfTargetNotAmqpQueueOnBindCall()
300300
$context = new AmqpContext($this->createExtChannelMock());
301301

302302
$this->expectException(InvalidDestinationException::class);
303-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Transport\Null\NullQueue.');
303+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Null\NullQueue.');
304304
$context->bind(new AmqpTopic('aName'), new NullQueue('aName'));
305305
}
306306

@@ -309,7 +309,7 @@ public function testShouldThrowIfGivenQueueNotAmqpQueueOnPurge()
309309
$context = new AmqpContext($this->createExtChannelMock());
310310

311311
$this->expectException(InvalidDestinationException::class);
312-
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Transport\Null\NullQueue.');
312+
$this->expectExceptionMessage('The destination must be an instance of Enqueue\AmqpExt\AmqpQueue but got Enqueue\Null\NullQueue.');
313313
$context->purge(new NullQueue('aName'));
314314
}
315315

@@ -326,6 +326,9 @@ private function createExtChannelMock()
326326
*/
327327
private function createExtConnectionMock()
328328
{
329-
return $this->createMock(\AMQPConnection::class);
329+
return $this->getMockBuilder(\AMQPConnection::class)
330+
->setMethods(['isPersistent', 'isConnected', 'pdisconnect', 'disconnect'])
331+
->getMock()
332+
;
330333
}
331334
}

0 commit comments

Comments
 (0)