Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TopologyTest.php
Go to the documentation of this file.
1 <?php
7 
12 class TopologyTest extends \PHPUnit\Framework\TestCase
13 {
19  private $declaredExchanges;
20 
24  private $helper;
25 
26  protected function setUp()
27  {
28  $this->helper = new \Magento\TestFramework\Helper\Amqp();
29  $this->declaredExchanges = $this->helper->getExchanges();
30  }
31 
37  public function testTopologyInstallation(array $expectedConfig, array $bindingConfig)
38  {
39  $name = $expectedConfig['name'];
40  $this->assertArrayHasKey($name, $this->declaredExchanges);
41  unset($this->declaredExchanges[$name]['message_stats']);
42  $this->assertEquals(
43  $expectedConfig,
44  $this->declaredExchanges[$name],
45  'Invalid exchange configuration: ' . $name
46  );
47 
48  $bindings = $this->helper->getExchangeBindings($name);
49  $bindings = array_map(function ($value) {
50  unset($value['properties_key']);
51  return $value;
52  }, $bindings);
53  $this->assertEquals(
54  $bindingConfig,
55  $bindings,
56  'Invalid exchange bindings configuration: ' . $name
57  );
58  }
59 
64  public function exchangeDataProvider()
65  {
66  return [
67  'magento-topic-based-exchange1' => [
68  'exchangeConfig' => [
69  'name' => 'magento-topic-based-exchange1',
70  'vhost' => '/',
71  'type' => 'topic',
72  'durable' => true,
73  'auto_delete' => false,
74  'internal' => false,
75  'arguments' => [
76  'alternate-exchange' => 'magento-log-exchange'
77  ],
78  ],
79  'bindingConfig' => [
80  [
81  'source' => 'magento-topic-based-exchange1',
82  'vhost' => '/',
83  'destination' => 'topic-queue1',
84  'destination_type' => 'queue',
85  'routing_key' => 'anotherTopic1',
86  'arguments' => [
87  'argument1' => 'value'
88  ],
89  ],
90  ]
91  ],
92  'magento-topic-based-exchange2' => [
93  'exchangeConfig' => [
94  'name' => 'magento-topic-based-exchange2',
95  'vhost' => '/',
96  'type' => 'topic',
97  'durable' => true,
98  'auto_delete' => false,
99  'internal' => false,
100  'arguments' => [
101  'alternate-exchange' => 'magento-log-exchange',
102  'arrayValue' => ['10', '20']
103  ],
104  ],
105  'bindingConfig' => [
106  [
107  'source' => 'magento-topic-based-exchange2',
108  'vhost' => '/',
109  'destination' => 'topic-queue2',
110  'destination_type' => 'queue',
111  'routing_key' => 'anotherTopic2',
112  'arguments' => [
113  'argument1' => 'value',
114  'argument2' => true,
115  'argument3' => '150',
116  ],
117  ],
118  ]
119  ],
120  'magento-topic-based-exchange3' => [
121  'exchangeConfig' => [
122  'name' => 'magento-topic-based-exchange3',
123  'vhost' => '/',
124  'type' => 'topic',
125  'durable' => false,
126  'auto_delete' => true,
127  'internal' => true,
128  'arguments' => [],
129  ],
130  'bindingConfig' => [],
131  ],
132  'magento-topic-based-exchange4' => [
133  'exchangeConfig' => [
134  'name' => 'magento-topic-based-exchange4',
135  'vhost' => '/',
136  'type' => 'topic',
137  'durable' => true,
138  'auto_delete' => false,
139  'internal' => false,
140  'arguments' => [],
141  ],
142  'bindingConfig' => [
143  [
144  'source' => 'magento-topic-based-exchange4',
145  'vhost' => '/',
146  'destination' => 'topic-queue1',
147  'destination_type' => 'queue',
148  'routing_key' => '#',
149  'arguments' => [
150  'test' => 'one'
151  ],
152  ],
153  [
154  'source' => 'magento-topic-based-exchange4',
155  'vhost' => '/',
156  'destination' => 'topic-queue2',
157  'destination_type' => 'queue',
158  'routing_key' => '*.*.*',
159  'arguments' => [],
160  ],
161  ]
162  ],
163  ];
164  }
165 }
$value
Definition: gender.phtml:16
testTopologyInstallation(array $expectedConfig, array $bindingConfig)
if(!isset($_GET['name'])) $name
Definition: log.php:14