Skip to content

Commit

Permalink
Merge pull request #61 from php-enqueue/client-hardcode-queue-name
Browse files Browse the repository at this point in the history
[client] Add ability to hardcode queue name. It is used as is and not adjusted or modified in any way
  • Loading branch information
makasim authored Apr 26, 2017
2 parents cafd642 + 061faf7 commit 2eec036
Show file tree
Hide file tree
Showing 93 changed files with 972 additions and 443 deletions.
2 changes: 1 addition & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

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

for REMOTE in origin psr-queue stomp amqp-ext fs redis dbal enqueue enqueue-bundle job-queue test
for REMOTE in origin psr-queue stomp amqp-ext fs redis dbal null enqueue enqueue-bundle job-queue test
do
TMP_DIR="/tmp/enqueue-repo"
REMOTE_URL=`git remote get-url $REMOTE`
Expand Down
2 changes: 2 additions & 0 deletions bin/subtree-split
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ remote amqp-ext [email protected]:php-enqueue/amqp-ext.git
remote fs [email protected]:php-enqueue/fs.git
remote redis [email protected]:php-enqueue/redis.git
remote dbal [email protected]:php-enqueue/dbal.git
remote null [email protected]:php-enqueue/null.git
remote enqueue-bundle [email protected]:php-enqueue/enqueue-bundle.git
remote job-queue [email protected]:php-enqueue/job-queue.git
remote test [email protected]:php-enqueue/test.git
Expand All @@ -61,6 +62,7 @@ split 'pkg/amqp-ext' amqp-ext
split 'pkg/fs' fs
split 'pkg/redis' redis
split 'pkg/dbal' dbal
split 'pkg/null' null
split 'pkg/enqueue-bundle' enqueue-bundle
split 'pkg/job-queue' job-queue
split 'pkg/test' test
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"enqueue/amqp-ext": "*@dev",
"enqueue/redis": "*@dev",
"enqueue/fs": "*@dev",
"enqueue/null": "*@dev",
"enqueue/dbal": "*@dev",
"enqueue/enqueue-bundle": "*@dev",
"enqueue/job-queue": "*@dev",
Expand Down Expand Up @@ -64,6 +65,10 @@
"type": "path",
"url": "pkg/fs"
},
{
"type": "path",
"url": "pkg/null"
},
{
"type": "path",
"url": "pkg/dbal"
Expand Down
4 changes: 2 additions & 2 deletions docs/transport/null.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Useful in tests for example.
## Installation

```bash
$ composer require enqueue/enqueue
$ composer require enqueue/null
```

## Create context

```php
<?php
use Enqueue\Transport\Null\NullConnectionFactory;
use Enqueue\Null\NullConnectionFactory;

$connectionFactory = new NullConnectionFactory();

Expand Down
8 changes: 6 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<directory>pkg/enqueue/Tests</directory>
</testsuite>

<testsuite name="stomp">
<testsuite name="stomp transport">
<directory>pkg/stomp/Tests</directory>
</testsuite>

<testsuite name="amqp-ext">
<testsuite name="amqp-ext transport">
<directory>pkg/amqp-ext/Tests</directory>
</testsuite>

Expand All @@ -41,6 +41,10 @@
<directory>pkg/dbal/Tests</directory>
</testsuite>

<testsuite name="null transport">
<directory>pkg/null/Tests</directory>
</testsuite>

<testsuite name="enqueue-bundle">
<directory>pkg/enqueue-bundle/Tests</directory>
</testsuite>
Expand Down
4 changes: 3 additions & 1 deletion pkg/amqp-ext/Client/AmqpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public function setupBroker(LoggerInterface $logger = null)
*/
public function createQueue($queueName)
{
$queue = $this->context->createQueue($this->config->createTransportQueueName($queueName));
$transportName = $this->queueMetaRegistry->getQueueMeta($queueName)->getTransportName();

$queue = $this->context->createQueue($transportName);
$queue->addFlag(AMQP_DURABLE);

return $queue;
Expand Down
27 changes: 15 additions & 12 deletions pkg/amqp-ext/Tests/AmqpContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Enqueue\Psr\PsrContext;
use Enqueue\Psr\InvalidDestinationException;
use Enqueue\Test\ClassExtensionTrait;
use Enqueue\Transport\Null\NullQueue;
use Enqueue\Transport\Null\NullTopic;
use Enqueue\Null\NullQueue;
use Enqueue\Null\NullTopic;
use PHPUnit\Framework\TestCase;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Expand All @@ -326,6 +326,9 @@ private function createExtChannelMock()
*/
private function createExtConnectionMock()
{
return $this->createMock(\AMQPConnection::class);
return $this->getMockBuilder(\AMQPConnection::class)
->setMethods(['isPersistent', 'isConnected', 'pdisconnect', 'disconnect'])
->getMock()
;
}
}
Loading

0 comments on commit 2eec036

Please sign in to comment.