Repository navigation
Expand file tree
/
Copy pathStompManagementClientTest.php
More file actions
114 lines (97 loc) · 2.97 KB
/
Copy pathStompManagementClientTest.php
File metadata and controls
114 lines (97 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace Enqueue\Tests\Client\Driver;
use Enqueue\Client\Driver\StompManagementClient;
use RabbitMq\ManagementApi\Api\Binding;
use RabbitMq\ManagementApi\Api\Exchange;
use RabbitMq\ManagementApi\Api\Queue;
use RabbitMq\ManagementApi\Client;
class StompManagementClientTest extends \PHPUnit\Framework\TestCase
{
public function testCouldDeclareExchange()
{
$exchange = $this->createExchangeMock();
$exchange
->expects($this->once())
->method('create')
->with('vhost', 'name', ['options'])
->willReturn([])
;
$client = $this->createClientMock();
$client
->expects($this->once())
->method('exchanges')
->willReturn($exchange)
;
$management = new StompManagementClient($client, 'vhost');
$management->declareExchange('name', ['options']);
}
public function testCouldDeclareQueue()
{
$queue = $this->createQueueMock();
$queue
->expects($this->once())
->method('create')
->with('vhost', 'name', ['options'])
->willReturn([])
;
$client = $this->createClientMock();
$client
->expects($this->once())
->method('queues')
->willReturn($queue)
;
$management = new StompManagementClient($client, 'vhost');
$management->declareQueue('name', ['options']);
}
public function testCouldBind()
{
$binding = $this->createBindingMock();
$binding
->expects($this->once())
->method('create')
->with('vhost', 'exchange', 'queue', 'routing-key', ['arguments'])
->willReturn([])
;
$client = $this->createClientMock();
$client
->expects($this->once())
->method('bindings')
->willReturn($binding)
;
$management = new StompManagementClient($client, 'vhost');
$management->bind('exchange', 'queue', 'routing-key', ['arguments']);
}
public function testCouldCreateNewInstanceUsingFactory()
{
$instance = StompManagementClient::create('', '');
$this->assertInstanceOf(StompManagementClient::class, $instance);
}
/**
* @return \PHPUnit\Framework\MockObject\MockObject|Client
*/
private function createClientMock()
{
return $this->createMock(Client::class);
}
/**
* @return \PHPUnit\Framework\MockObject\MockObject|Exchange
*/
private function createExchangeMock()
{
return $this->createMock(Exchange::class);
}
/**
* @return \PHPUnit\Framework\MockObject\MockObject|Queue
*/
private function createQueueMock()
{
return $this->createMock(Queue::class);
}
/**
* @return \PHPUnit\Framework\MockObject\MockObject|Binding
*/
private function createBindingMock()
{
return $this->createMock(Binding::class);
}
}