Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeprecatedConfigTest.php
Go to the documentation of this file.
1 <?php
7 
9 
15 class DeprecatedConfigTest extends \PHPUnit\Framework\TestCase
16 {
20  private $objectManager;
21 
22  protected function setUp()
23  {
25  }
26 
27  public function testGetTopology()
28  {
30  $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Topology\ConfigInterface::class);
31  $topology = $config->getExchange('deprecatedExchange', 'db');
32  $this->assertEquals('deprecatedExchange', $topology->getName());
33  $this->assertEquals('topic', $topology->getType());
34  $this->assertEquals('db', $topology->getConnection());
35  $this->assertEquals(true, $topology->isDurable());
36  $this->assertEquals(false, $topology->isAutoDelete());
37  $this->assertEquals(false, $topology->isInternal());
38 
39  $arguments = $topology->getArguments();
40  $this->assertInternalType('array', $arguments);
41  $this->assertCount(0, $arguments);
42 
43  // Verify bindings
44  $bindings = $topology->getBindings();
45  $this->assertInstanceOf(BindingIterator::class, $bindings);
46  $this->assertCount(1, $bindings);
47 
48  $bindingId = 'queue--deprecated.config.queue.2--deprecated.config.async.bool.topic';
49  $this->assertArrayHasKey($bindingId, $bindings);
50  $binding = $bindings[$bindingId];
51 
52  $this->assertEquals('queue', $binding->getDestinationType());
53  $this->assertEquals('deprecated.config.queue.2', $binding->getDestination());
54  $this->assertEquals(false, $binding->isDisabled());
55  $this->assertEquals('deprecated.config.async.bool.topic', $binding->getTopic());
56  $arguments = $binding->getArguments();
57  $this->assertInternalType('array', $arguments);
58  $this->assertCount(0, $arguments);
59  }
60 
61  public function testGetTopologyOverlapWithQueueConfig()
62  {
64  $config = $this->objectManager->create(\Magento\Framework\MessageQueue\Topology\ConfigInterface::class);
65  $topology = $config->getExchange('overlappingDeprecatedExchange', 'amqp');
66  $this->assertEquals('overlappingDeprecatedExchange', $topology->getName());
67  $this->assertEquals('topic', $topology->getType());
68  $this->assertEquals('amqp', $topology->getConnection());
69  $this->assertEquals(true, $topology->isDurable());
70  $this->assertEquals(false, $topology->isAutoDelete());
71  $this->assertEquals(false, $topology->isInternal());
72 
73  $arguments = $topology->getArguments();
74  $this->assertInternalType('array', $arguments);
75  $this->assertCount(0, $arguments);
76 
77  // Verify bindings
78  $bindings = $topology->getBindings();
79  $this->assertInstanceOf(BindingIterator::class, $bindings);
80  $this->assertCount(3, $bindings);
81 
82  // Note that connection was changed for this binding during merge with topology config
83  // since we do not support exchanges with the same names on different connections
84  $bindingId = 'queue--consumer.config.queue--overlapping.topic.declaration';
85  $this->assertArrayHasKey($bindingId, $bindings);
86  $binding = $bindings[$bindingId];
87  $this->assertEquals('queue', $binding->getDestinationType());
88  $this->assertEquals('consumer.config.queue', $binding->getDestination());
89  $this->assertEquals(false, $binding->isDisabled());
90  $this->assertEquals('overlapping.topic.declaration', $binding->getTopic());
91  $arguments = $binding->getArguments();
92  $this->assertInternalType('array', $arguments);
93  $this->assertCount(0, $arguments);
94 
95  $bindingId = 'binding1';
96  $this->assertArrayHasKey($bindingId, $bindings);
97  $binding = $bindings[$bindingId];
98  $this->assertEquals('queue', $binding->getDestinationType());
99  $this->assertEquals('topology.config.queue', $binding->getDestination());
100  $this->assertEquals(false, $binding->isDisabled());
101  $this->assertEquals('overlapping.topic.declaration', $binding->getTopic());
102  $arguments = $binding->getArguments();
103  $this->assertInternalType('array', $arguments);
104  $this->assertCount(0, $arguments);
105 
106  $bindingId = 'binding2';
107  $this->assertArrayHasKey($bindingId, $bindings);
108  $binding = $bindings[$bindingId];
109  $this->assertEquals('queue', $binding->getDestinationType());
110  $this->assertEquals('topology.config.queue', $binding->getDestination());
111  $this->assertEquals(false, $binding->isDisabled());
112  $this->assertEquals('deprecated.config.async.string.topic', $binding->getTopic());
113  $arguments = $binding->getArguments();
114  $this->assertInternalType('array', $arguments);
115  $this->assertCount(0, $arguments);
116  }
117 }
$config
Definition: fraud_order.php:17
$arguments