Skip to content

Commit

Permalink
Add alias to registries
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhukV committed Aug 31, 2023
1 parent 6f92c9c commit 91e093e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?php

use FiveLab\Bundle\AmqpBundle\Connection\Registry\ConnectionFactoryRegistry;
use FiveLab\Bundle\AmqpBundle\Connection\Registry\ConnectionFactoryRegistryInterface;
use FiveLab\Component\Amqp\Command\InitializeExchangesCommand;
use FiveLab\Component\Amqp\Command\InitializeQueuesCommand;
use FiveLab\Component\Amqp\Command\ListConsumersCommand;
use FiveLab\Component\Amqp\Command\RunConsumerCommand;
use FiveLab\Component\Amqp\Consumer\Registry\ConsumerRegistryInterface;
use FiveLab\Component\Amqp\Consumer\Registry\ContainerConsumerRegistry;
use FiveLab\Component\Amqp\Exchange\Registry\ExchangeFactoryRegistry;
use FiveLab\Component\Amqp\Exchange\Registry\ExchangeFactoryRegistryInterface;
use FiveLab\Component\Amqp\Publisher\Registry\PublisherRegistry;
use FiveLab\Component\Amqp\Publisher\Registry\PublisherRegistryInterface;
use FiveLab\Component\Amqp\Queue\Registry\QueueFactoryRegistry;
use FiveLab\Component\Amqp\Queue\Registry\QueueFactoryRegistryInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\abstract_arg;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
Expand Down Expand Up @@ -61,4 +66,12 @@

->set('fivelab.amqp.publisher_registry', PublisherRegistry::class)
->public();

// Aliases
$container->services()
->alias(ConsumerRegistryInterface::class, 'fivelab.amqp.consumer_registry')
->alias(ExchangeFactoryRegistryInterface::class, 'fivelab.amqp.queue_factory_registry')
->alias(QueueFactoryRegistryInterface::class, 'fivelab.amqp.queue_factory_registry')
->alias(ConnectionFactoryRegistryInterface::class, 'fivelab.amqp.connection_factory_registry')
->alias(PublisherRegistryInterface::class, 'fivelab.amqp.publisher_registry');
};
18 changes: 18 additions & 0 deletions tests/DependencyInjection/AmqpExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

namespace FiveLab\Bundle\AmqpBundle\Tests\DependencyInjection;

use FiveLab\Bundle\AmqpBundle\Connection\Registry\ConnectionFactoryRegistryInterface;
use FiveLab\Component\Amqp\Consumer\Registry\ConsumerRegistryInterface;
use FiveLab\Component\Amqp\Exchange\Registry\ExchangeFactoryRegistryInterface;
use FiveLab\Component\Amqp\Publisher\Registry\PublisherRegistryInterface;
use FiveLab\Component\Amqp\Queue\Registry\QueueFactoryRegistryInterface;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestWith;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -116,4 +121,17 @@ public function shouldRegistriesIsPublic(string $registry): void
$registry
));
}

#[Test]
#[TestWith([ConsumerRegistryInterface::class, 'fivelab.amqp.consumer_registry'])]
#[TestWith([ExchangeFactoryRegistryInterface::class, 'fivelab.amqp.queue_factory_registry'])]
#[TestWith([QueueFactoryRegistryInterface::class, 'fivelab.amqp.queue_factory_registry'])]
#[TestWith([ConnectionFactoryRegistryInterface::class, 'fivelab.amqp.connection_factory_registry'])]
#[TestWith([PublisherRegistryInterface::class, 'fivelab.amqp.publisher_registry'])]
public function shouldRegistriesHasAlias(string $alias, string $reference): void
{
$this->load([]);

$this->assertContainerBuilderHasAlias($alias, $reference);
}
}

0 comments on commit 91e093e

Please sign in to comment.