DeprecatedConfigTest.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\MessageQueue\Publisher;
  7. use Magento\Framework\MessageQueue\Publisher\Config\PublisherConnectionInterface;
  8. /**
  9. * Test access to publisher configuration declared in deprecated queue.xml configs using Publisher\ConfigInterface.
  10. *
  11. * @magentoCache config disabled
  12. */
  13. class DeprecatedConfigTest extends \PHPUnit\Framework\TestCase
  14. {
  15. /**
  16. * @var \Magento\Framework\ObjectManagerInterface
  17. */
  18. private $objectManager;
  19. protected function setUp()
  20. {
  21. $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  22. }
  23. public function testGetPublisher()
  24. {
  25. /** @var \Magento\Framework\MessageQueue\Publisher\ConfigInterface $config */
  26. $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Publisher\ConfigInterface::class);
  27. $publisher = $config->getPublisher('deprecated.config.async.string.topic');
  28. $this->assertEquals('deprecated.config.async.string.topic', $publisher->getTopic());
  29. $this->assertEquals(false, $publisher->isDisabled());
  30. $connection = $publisher->getConnection();
  31. $this->assertEquals('amqp', $connection->getName());
  32. $this->assertEquals('magento', $connection->getExchange());
  33. $this->assertEquals(false, $connection->isDisabled());
  34. }
  35. public function testGetPublisherCustomConnection()
  36. {
  37. /** @var \Magento\Framework\MessageQueue\Publisher\ConfigInterface $config */
  38. $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Publisher\ConfigInterface::class);
  39. $publisher = $config->getPublisher('deprecated.config.sync.bool.topic');
  40. $this->assertEquals('deprecated.config.sync.bool.topic', $publisher->getTopic());
  41. $this->assertEquals(false, $publisher->isDisabled());
  42. $connection = $publisher->getConnection();
  43. $this->assertEquals('amqp', $connection->getName());
  44. $this->assertEquals('customExchange', $connection->getExchange());
  45. $this->assertEquals(false, $connection->isDisabled());
  46. }
  47. public function testGetOverlapWithQueueConfig()
  48. {
  49. /** @var \Magento\Framework\MessageQueue\Publisher\ConfigInterface $config */
  50. $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Publisher\ConfigInterface::class);
  51. $publisher = $config->getPublisher('overlapping.topic.declaration');
  52. $this->assertEquals('overlapping.topic.declaration', $publisher->getTopic());
  53. $this->assertEquals(false, $publisher->isDisabled());
  54. $connection = $publisher->getConnection();
  55. $this->assertEquals('amqp', $connection->getName());
  56. $this->assertEquals('magento', $connection->getExchange());
  57. $this->assertEquals(false, $connection->isDisabled());
  58. }
  59. }