Skip to content

Commit

Permalink
Merge pull request #197 from php-enqueue/bundle-topic-subscriber-with…
Browse files Browse the repository at this point in the history
…out-processor-name

[bundle] add tests for the case where topic subscriber does not def p…
  • Loading branch information
makasim authored Sep 13, 2017
2 parents fdb6392 + 3f95717 commit 3772554
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameCommandSubscriber;
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber;
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\QueueNameTopicSubscriber;
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\WithoutProcessorNameTopicSubscriber;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand Down Expand Up @@ -213,6 +214,30 @@ public function testShouldBuildRouteFromSubscriberIfQueueNameSpecified()
$this->assertEquals($expectedRoutes, $router->getArgument(1));
}

public function testShouldBuildRouteFromWithoutProcessorNameTopicSubscriber()
{
$container = $this->createContainerBuilder();

$processor = new Definition(WithoutProcessorNameTopicSubscriber::class);
$processor->addTag('enqueue.client.processor');
$container->setDefinition('processor-service-id', $processor);

$router = new Definition();
$router->setArguments([null, null, null]);
$container->setDefinition('enqueue.client.router_processor', $router);

$pass = new BuildClientRoutingPass();
$pass->process($container);

$expectedRoutes = [
'without-processor-name' => [
['processor-service-id', 'a_queue_name'],
],
];

$this->assertEquals($expectedRoutes, $router->getArgument(1));
}

public function testShouldThrowExceptionWhenTopicSubscriberConfigurationIsInvalid()
{
$container = $this->createContainerBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\OnlyTopicNameTopicSubscriber;
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameCommandSubscriber;
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber;
use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\WithoutProcessorNameTopicSubscriber;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand Down Expand Up @@ -132,6 +133,28 @@ public function testShouldBuildRouteFromSubscriberIfOnlyTopicNameSpecified()
$this->assertEquals($expectedValue, $processorRegistry->getArgument(0));
}

public function testShouldBuildRouteFromWithoutProcessorNameTopicSubscriber()
{
$container = $this->createContainerBuilder();

$processor = new Definition(WithoutProcessorNameTopicSubscriber::class);
$processor->addTag('enqueue.client.processor');
$container->setDefinition('processor-id', $processor);

$processorRegistry = new Definition();
$processorRegistry->setArguments([]);
$container->setDefinition('enqueue.client.processor_registry', $processorRegistry);

$pass = new BuildProcessorRegistryPass();
$pass->process($container);

$expectedValue = [
'processor-id' => 'processor-id',
];

$this->assertEquals($expectedValue, $processorRegistry->getArgument(0));
}

public function testShouldBuildRouteFromSubscriberIfProcessorNameSpecified()
{
$container = $this->createContainerBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock;

use Enqueue\Client\TopicSubscriberInterface;

class WithoutProcessorNameTopicSubscriber implements TopicSubscriberInterface
{
public static function getSubscribedTopics()
{
return [
'without-processor-name' => [
'queueName' => 'a_queue_name',
'queueNameHardcoded' => true,
],
];
}
}

0 comments on commit 3772554

Please sign in to comment.