Repository navigation
Expand file tree
/
Copy pathSqsDriverTest.php
More file actions
153 lines (132 loc) · 3.72 KB
/
Copy pathSqsDriverTest.php
File metadata and controls
153 lines (132 loc) · 3.72 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
namespace Enqueue\Tests\Client\Driver;
use Enqueue\Client\Driver\GenericDriver;
use Enqueue\Client\Driver\SqsDriver;
use Enqueue\Client\DriverInterface;
use Enqueue\Client\Route;
use Enqueue\Client\RouteCollection;
use Enqueue\Sqs\SqsContext;
use Enqueue\Sqs\SqsDestination;
use Enqueue\Sqs\SqsMessage;
use Enqueue\Sqs\SqsProducer;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\Context;
use Interop\Queue\Message as InteropMessage;
use Interop\Queue\Producer as InteropProducer;
use Interop\Queue\Queue as InteropQueue;
use Interop\Queue\Topic as InteropTopic;
use PHPUnit\Framework\TestCase;
class SqsDriverTest extends TestCase
{
use ClassExtensionTrait;
use GenericDriverTestsTrait;
public function testShouldImplementsDriverInterface()
{
$this->assertClassImplements(DriverInterface::class, SqsDriver::class);
}
public function testShouldBeSubClassOfGenericDriver()
{
$this->assertClassExtends(GenericDriver::class, SqsDriver::class);
}
public function testShouldSetupBroker()
{
$routerQueue = new SqsDestination('');
$processorQueue = new SqsDestination('');
$context = $this->createContextMock();
// setup router
$context
->expects($this->at(0))
->method('createQueue')
->with('aprefix_dot_default')
->willReturn($routerQueue)
;
$context
->expects($this->at(1))
->method('declareQueue')
->with($this->identicalTo($routerQueue))
;
// setup processor queue
$context
->expects($this->at(2))
->method('createQueue')
->with('aprefix_dot_default')
->willReturn($processorQueue)
;
$context
->expects($this->at(3))
->method('declareQueue')
->with($this->identicalTo($processorQueue))
;
$driver = new SqsDriver(
$context,
$this->createDummyConfig(),
new RouteCollection([
new Route('topic', Route::TOPIC, 'processor'),
])
);
$driver->setupBroker();
}
protected function createDriver(...$args): DriverInterface
{
return new SqsDriver(...$args);
}
/**
* @return SqsContext
*/
protected function createContextMock(): Context
{
return $this->createMock(SqsContext::class);
}
/**
* @return SqsProducer
*/
protected function createProducerMock(): InteropProducer
{
return $this->createMock(SqsProducer::class);
}
/**
* @return SqsDestination
*/
protected function createQueue(string $name): InteropQueue
{
return new SqsDestination($name);
}
/**
* @return SqsDestination
*/
protected function createTopic(string $name): InteropTopic
{
return new SqsDestination($name);
}
/**
* @return SqsMessage
*/
protected function createMessage(): InteropMessage
{
return new SqsMessage();
}
protected function getPrefixAppFooQueueTransportName(): string
{
return 'aprefix_dot_anappname_dot_afooqueue';
}
protected function getPrefixFooQueueTransportName(): string
{
return 'aprefix_dot_afooqueue';
}
protected function getAppFooQueueTransportName(): string
{
return 'anappname_dot_afooqueue';
}
protected function getDefaultQueueTransportName(): string
{
return 'aprefix_dot_default';
}
protected function getCustomQueueTransportName(): string
{
return 'aprefix_dot_custom';
}
protected function getRouterTransportName(): string
{
return 'aprefix_dot_default';
}
}