Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DependantFieldsTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\MessageQueue\Topology\Config\Validator\DependentFields;
9 
10 class DependantFieldsTest extends \PHPUnit\Framework\TestCase
11 {
15  private $model;
16 
17  protected function setUp()
18  {
19  $this->model = new DependentFields();
20  }
21 
22  public function testValidateValidConfig()
23  {
24  $configData = [
25  'ex01' => [
26  'name' => 'ex01',
27  'type' => 'topic',
28  'connection' => 'amqp',
29  'durable' => true,
30  'internal' => false,
31  'autoDelete' => false,
32  'arguments' => ['some' => 'argument'],
33  'bindings' => [
34  'bind01' => [
35  'id' => 'bind01',
36  'topic' => 'bind01',
37  'destinationType' => 'queue',
38  'destination' => 'bind01',
39  'disabled' => false,
40  'arguments' => ['some' => 'arguments'],
41  ],
42  ],
43  ],
44  'ex02' => [
45  'name' => 'ex01',
46  'type' => 'headers',
47  'connection' => 'amqp',
48  'durable' => true,
49  'internal' => false,
50  'autoDelete' => false,
51  'arguments' => ['some' => 'argument'],
52  'bindings' => [
53  'bind01' => [
54  'id' => 'bind01',
55  'destinationType' => 'queue',
56  'destination' => 'some.queue',
57  'disabled' => false,
58  'arguments' => ['some' => 'arguments'],
59  ],
60  ],
61  ],
62  ];
63  $this->model->validate($configData);
64  }
65 
67  {
68  $expectedMessage = "Topic name is required for topic based exchange: ex01";
69  $this->expectException('\LogicException');
70  $this->expectExceptionMessage($expectedMessage);
71  $configData = [
72  'ex01' => [
73  'name' => 'ex01',
74  'type' => 'topic',
75  'connection' => 'amqp',
76  'durable' => true,
77  'internal' => false,
78  'autoDelete' => false,
79  'arguments' => ['some' => 'argument'],
80  'bindings' => [
81  'bind01' => [
82  'id' => 'bind01',
83  'destinationType' => 'queue',
84  'destination' => 'bind01',
85  'disabled' => false,
86  'arguments' => ['some' => 'arguments'],
87  ],
88  ],
89  ]
90  ];
91  $this->model->validate($configData);
92  }
93 }