2
2
3
3
namespace Enqueue \Tests \Symfony \Client ;
4
4
5
+ use Enqueue \Client \Message ;
5
6
use Enqueue \Client \ProducerInterface ;
6
7
use Enqueue \Container \Container ;
7
8
use Enqueue \Symfony \Client \ProduceCommand ;
@@ -42,10 +43,11 @@ public function testShouldHaveExpectedOptions()
42
43
$ command = new ProduceCommand ($ this ->createMock (ContainerInterface::class), 'default ' );
43
44
44
45
$ options = $ command ->getDefinition ()->getOptions ();
45
- $ this ->assertCount (3 , $ options );
46
+ $ this ->assertCount (4 , $ options );
46
47
$ this ->assertArrayHasKey ('client ' , $ options );
47
48
$ this ->assertArrayHasKey ('topic ' , $ options );
48
49
$ this ->assertArrayHasKey ('command ' , $ options );
50
+ $ this ->assertArrayHasKey ('header ' , $ options );
49
51
}
50
52
51
53
public function testShouldHaveExpectedAttributes ()
@@ -112,11 +114,14 @@ public function testThrowIfBothTopicAndCommandOptionsAreSet()
112
114
113
115
public function testShouldSendEventToDefaultTransport ()
114
116
{
117
+ $ header = 'Content-Type: text/plain ' ;
118
+ $ payload = 'theMessage ' ;
119
+
115
120
$ producerMock = $ this ->createProducerMock ();
116
121
$ producerMock
117
122
->expects ($ this ->once ())
118
123
->method ('sendEvent ' )
119
- ->with ('theTopic ' , ' theMessage ' )
124
+ ->with ('theTopic ' , new Message ( $ payload , [], [ $ header ]) )
120
125
;
121
126
$ producerMock
122
127
->expects ($ this ->never ())
@@ -129,7 +134,8 @@ public function testShouldSendEventToDefaultTransport()
129
134
130
135
$ tester = new CommandTester ($ command );
131
136
$ tester ->execute ([
132
- 'message ' => 'theMessage ' ,
137
+ 'message ' => $ payload ,
138
+ '--header ' => $ header ,
133
139
'--topic ' => 'theTopic ' ,
134
140
]);
135
141
}
@@ -160,6 +166,9 @@ public function testShouldSendCommandToDefaultTransport()
160
166
161
167
public function testShouldSendEventToFooTransport ()
162
168
{
169
+ $ header = 'Content-Type: text/plain ' ;
170
+ $ payload = 'theMessage ' ;
171
+
163
172
$ defaultProducerMock = $ this ->createProducerMock ();
164
173
$ defaultProducerMock
165
174
->expects ($ this ->never ())
@@ -174,7 +183,7 @@ public function testShouldSendEventToFooTransport()
174
183
$ fooProducerMock
175
184
->expects ($ this ->once ())
176
185
->method ('sendEvent ' )
177
- ->with ('theTopic ' , ' theMessage ' )
186
+ ->with ('theTopic ' , new Message ( $ payload , [], [ $ header ]) )
178
187
;
179
188
$ fooProducerMock
180
189
->expects ($ this ->never ())
@@ -188,7 +197,8 @@ public function testShouldSendEventToFooTransport()
188
197
189
198
$ tester = new CommandTester ($ command );
190
199
$ tester ->execute ([
191
- 'message ' => 'theMessage ' ,
200
+ 'message ' => $ payload ,
201
+ '--header ' => $ header ,
192
202
'--topic ' => 'theTopic ' ,
193
203
'--client ' => 'foo ' ,
194
204
]);
0 commit comments