Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EnabledConnectionTest.php
Go to the documentation of this file.
1 <?php
2 
9 
10 use \Magento\Framework\MessageQueue\Publisher\Config\Validator\EnabledConnection;
11 
12 class EnabledConnectionTest extends \PHPUnit\Framework\TestCase
13 {
17  private $model;
18 
19  protected function setUp()
20  {
21  $this->model = new EnabledConnection();
22  }
23 
24  public function testValidateValidConfig()
25  {
26  $configData = [
27  'pub01' => [
28  'topic' => 'pub01',
29  'disabled' => false,
30  'connections' => [
31  'con01' => ['name' => 'con1', 'exchange' => 'exchange01', 'disabled' => true],
32  'con02' => ['name' => 'con1', 'exchange' => 'exchange01', 'disabled' => false],
33  ],
34  ],
35  'pub02' => [
36  'topic' => 'pub02',
37  'disabled' => false,
38  'connections' => [
39  'con01' => ['name' => 'amqp', 'exchange' => 'magento', 'disabled' => true],
40  ]
41  ],
42  'pub03' => [
43  'topic' => 'pub02',
44  'disabled' => false,
45  ]
46  ];
47  $this->model->validate($configData);
48  }
49 
51  {
52  $this->expectException('\LogicException');
53  $this->expectExceptionMessage(
54  'More than 1 enabled connections configured for publisher pub01. ' .
55  'More than 1 enabled connections configured for publisher pub02.'
56  );
57  $configData = [
58  'pub01' => [
59  'topic' => 'pub01',
60  'disabled' => false,
61  'connections' => [
62  'con01' => ['name' => 'con1', 'exchange' => 'exchange01', 'disabled' => false],
63  'con02' => ['name' => 'con1', 'exchange' => 'exchange01', 'disabled' => false],
64  ],
65  ],
66  'pub02' => [
67  'topic' => 'pub02',
68  'disabled' => false,
69  'connections' => [
70  'con01' => ['name' => 'con1', 'exchange' => 'exchange01', 'disabled' => false],
71  'con02' => ['name' => 'con1', 'exchange' => 'exchange01', 'disabled' => false],
72  ],
73  ],
74  ];
75  $this->model->validate($configData);
76  }
77 }