DeprecatedConfigTest.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\MessageQueue\Topology;
  7. use Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItem\Binding\Iterator as BindingIterator;
  8. /**
  9. * Test access to topology configuration declared in deprecated queue.xml configs using Topology\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 testGetTopology()
  24. {
  25. /** @var \Magento\Framework\MessageQueue\Topology\ConfigInterface $config */
  26. $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Topology\ConfigInterface::class);
  27. $topology = $config->getExchange('deprecatedExchange', 'db');
  28. $this->assertEquals('deprecatedExchange', $topology->getName());
  29. $this->assertEquals('topic', $topology->getType());
  30. $this->assertEquals('db', $topology->getConnection());
  31. $this->assertEquals(true, $topology->isDurable());
  32. $this->assertEquals(false, $topology->isAutoDelete());
  33. $this->assertEquals(false, $topology->isInternal());
  34. $arguments = $topology->getArguments();
  35. $this->assertInternalType('array', $arguments);
  36. $this->assertCount(0, $arguments);
  37. // Verify bindings
  38. $bindings = $topology->getBindings();
  39. $this->assertInstanceOf(BindingIterator::class, $bindings);
  40. $this->assertCount(1, $bindings);
  41. $bindingId = 'queue--deprecated.config.queue.2--deprecated.config.async.bool.topic';
  42. $this->assertArrayHasKey($bindingId, $bindings);
  43. $binding = $bindings[$bindingId];
  44. $this->assertEquals('queue', $binding->getDestinationType());
  45. $this->assertEquals('deprecated.config.queue.2', $binding->getDestination());
  46. $this->assertEquals(false, $binding->isDisabled());
  47. $this->assertEquals('deprecated.config.async.bool.topic', $binding->getTopic());
  48. $arguments = $binding->getArguments();
  49. $this->assertInternalType('array', $arguments);
  50. $this->assertCount(0, $arguments);
  51. }
  52. public function testGetTopologyOverlapWithQueueConfig()
  53. {
  54. /** @var \Magento\Framework\MessageQueue\Topology\ConfigInterface $config */
  55. $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Topology\ConfigInterface::class);
  56. $topology = $config->getExchange('overlappingDeprecatedExchange', 'amqp');
  57. $this->assertEquals('overlappingDeprecatedExchange', $topology->getName());
  58. $this->assertEquals('topic', $topology->getType());
  59. $this->assertEquals('amqp', $topology->getConnection());
  60. $this->assertEquals(true, $topology->isDurable());
  61. $this->assertEquals(false, $topology->isAutoDelete());
  62. $this->assertEquals(false, $topology->isInternal());
  63. $arguments = $topology->getArguments();
  64. $this->assertInternalType('array', $arguments);
  65. $this->assertCount(0, $arguments);
  66. // Verify bindings
  67. $bindings = $topology->getBindings();
  68. $this->assertInstanceOf(BindingIterator::class, $bindings);
  69. $this->assertCount(3, $bindings);
  70. // Note that connection was changed for this binding during merge with topology config
  71. // since we do not support exchanges with the same names on different connections
  72. $bindingId = 'queue--consumer.config.queue--overlapping.topic.declaration';
  73. $this->assertArrayHasKey($bindingId, $bindings);
  74. $binding = $bindings[$bindingId];
  75. $this->assertEquals('queue', $binding->getDestinationType());
  76. $this->assertEquals('consumer.config.queue', $binding->getDestination());
  77. $this->assertEquals(false, $binding->isDisabled());
  78. $this->assertEquals('overlapping.topic.declaration', $binding->getTopic());
  79. $arguments = $binding->getArguments();
  80. $this->assertInternalType('array', $arguments);
  81. $this->assertCount(0, $arguments);
  82. $bindingId = 'binding1';
  83. $this->assertArrayHasKey($bindingId, $bindings);
  84. $binding = $bindings[$bindingId];
  85. $this->assertEquals('queue', $binding->getDestinationType());
  86. $this->assertEquals('topology.config.queue', $binding->getDestination());
  87. $this->assertEquals(false, $binding->isDisabled());
  88. $this->assertEquals('overlapping.topic.declaration', $binding->getTopic());
  89. $arguments = $binding->getArguments();
  90. $this->assertInternalType('array', $arguments);
  91. $this->assertCount(0, $arguments);
  92. $bindingId = 'binding2';
  93. $this->assertArrayHasKey($bindingId, $bindings);
  94. $binding = $bindings[$bindingId];
  95. $this->assertEquals('queue', $binding->getDestinationType());
  96. $this->assertEquals('topology.config.queue', $binding->getDestination());
  97. $this->assertEquals(false, $binding->isDisabled());
  98. $this->assertEquals('deprecated.config.async.string.topic', $binding->getTopic());
  99. $arguments = $binding->getArguments();
  100. $this->assertInternalType('array', $arguments);
  101. $this->assertCount(0, $arguments);
  102. }
  103. }