Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AsyncMultipleHandlersTest.php
Go to the documentation of this file.
1 <?php
7 
9 
11 {
15  protected $expectedMessages;
16 
20  protected $consumers = [
21  'mtmh.queue.1.consumer',
22  'mtmh.queue.2.consumer',
23  ];
24 
28  private $topicValueMap = [
29  'mtmh.topic.1' => 'mtmh.topic.1',
30  'mtmh.topic.2' => ['mtmh.topic.2-1', 'mtmh.topic.2-2']
31  ];
32 
36  private $expectedValues = [
37  'string-mtmh.topic.1',
38  'mixed-mtmh.topic.1',
39  'array-mtmh.topic.2-1',
40  'array-mtmh.topic.2-2',
41  'mixed-mtmh.topic.2-1',
42  'mixed-mtmh.topic.2-2'
43  ];
44 
51  public function testAsynchronousRpcCommunication()
52  {
53  foreach ($this->topicValueMap as $topic => $data) {
54  $message = null;
55  if (is_array($data)) {
56  foreach ($data as $key => $value) {
58  $testObject = $this->objectManager->create(AsyncTestData::class);
59  $testObject->setValue($value);
60  $testObject->setTextFilePath($this->logFilePath);
61  $message[$key] = $testObject;
62  }
63  } else {
64  $testObject = $this->objectManager->create(AsyncTestData::class);
65  $testObject->setValue($data);
66  $testObject->setTextFilePath($this->logFilePath);
67  $message = $testObject;
68  }
69  $this->publisher->publish($topic, $message);
70  }
71 
72  $this->waitForAsynchronousResult(count($this->expectedValues), $this->logFilePath);
73 
74  //assertions
75  foreach ($this->expectedValues as $item) {
76  $this->assertContains($item, file_get_contents($this->logFilePath));
77  }
78  }
79 }
$message
$value
Definition: gender.phtml:16