Skip to content

Commit 45a5357

Browse files
committed
MCP-826: Use RabbitMQ for all consumers if AMQP is set in deployment config
- Add unit test;
1 parent ccb01f3 commit 45a5357

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\MessageQueue\Test\Unit;
9+
10+
use Magento\Framework\App\DeploymentConfig;
11+
use Magento\Framework\MessageQueue\DefaultValueProvider;
12+
use PHPUnit\Framework\TestCase;
13+
14+
class DefaultValueProviderTest extends TestCase
15+
{
16+
/**
17+
* @var DeploymentConfig
18+
*/
19+
private $config;
20+
21+
/**
22+
* @var DefaultValueProvider
23+
*/
24+
private DefaultValueProvider $model;
25+
26+
/**
27+
* @return void
28+
*/
29+
protected function setUp(): void
30+
{
31+
$this->config = $this->getMockBuilder(DeploymentConfig::class)
32+
->disableOriginalConstructor()
33+
->getMock();
34+
$this->model = new DefaultValueProvider('db', 'magento', $this->config);
35+
}
36+
37+
/**
38+
* @return void
39+
*/
40+
public function testGetConnection(): void
41+
{
42+
$this->assertEquals('db', $this->model->getConnection());
43+
}
44+
45+
/**
46+
* @return void
47+
*
48+
*/
49+
public function testGetDefaultConnection(): void
50+
{
51+
$this->config->method('get')->willReturnMap(
52+
[
53+
['queue/default_connection', null, 'test_connection'],
54+
]
55+
);
56+
57+
$this->assertEquals('test_connection', $this->model->getConnection());
58+
}
59+
60+
/**
61+
* @return void
62+
*
63+
*/
64+
public function testGetAMQPConnection(): void
65+
{
66+
$this->config->method('get')->willReturnMap(
67+
[
68+
['queue/default_connection', null, null],
69+
['queue/amqp', null, ['host' => '127.0.0.1', 'port' => '5672']]
70+
]
71+
);
72+
73+
$this->assertEquals('amqp', $this->model->getConnection());
74+
}
75+
}

0 commit comments

Comments
 (0)