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 ;
@@ -112,11 +113,14 @@ public function testThrowIfBothTopicAndCommandOptionsAreSet()
112
113
113
114
public function testShouldSendEventToDefaultTransport ()
114
115
{
116
+ $ header = 'Content-Type: text/plain ' ;
117
+ $ payload = 'theMessage ' ;
118
+
115
119
$ producerMock = $ this ->createProducerMock ();
116
120
$ producerMock
117
121
->expects ($ this ->once ())
118
122
->method ('sendEvent ' )
119
- ->with ('theTopic ' , ' theMessage ' )
123
+ ->with ('theTopic ' , new Message ( $ payload , [], [ $ header ]) )
120
124
;
121
125
$ producerMock
122
126
->expects ($ this ->never ())
@@ -129,18 +133,22 @@ public function testShouldSendEventToDefaultTransport()
129
133
130
134
$ tester = new CommandTester ($ command );
131
135
$ tester ->execute ([
132
- 'message ' => 'theMessage ' ,
136
+ 'message ' => $ payload ,
137
+ '--header ' => $ header ,
133
138
'--topic ' => 'theTopic ' ,
134
139
]);
135
140
}
136
141
137
142
public function testShouldSendCommandToDefaultTransport ()
138
143
{
144
+ $ header = 'Content-Type: text/plain ' ;
145
+ $ payload = 'theMessage ' ;
146
+
139
147
$ producerMock = $ this ->createProducerMock ();
140
148
$ producerMock
141
149
->expects ($ this ->once ())
142
150
->method ('sendCommand ' )
143
- ->with ('theCommand ' , ' theMessage ' )
151
+ ->with ('theCommand ' , new Message ( $ payload , [], [ $ header ]) )
144
152
;
145
153
$ producerMock
146
154
->expects ($ this ->never ())
@@ -153,13 +161,17 @@ public function testShouldSendCommandToDefaultTransport()
153
161
154
162
$ tester = new CommandTester ($ command );
155
163
$ tester ->execute ([
156
- 'message ' => 'theMessage ' ,
164
+ 'message ' => $ payload ,
165
+ '--header ' => $ header ,
157
166
'--command ' => 'theCommand ' ,
158
167
]);
159
168
}
160
169
161
170
public function testShouldSendEventToFooTransport ()
162
171
{
172
+ $ header = 'Content-Type: text/plain ' ;
173
+ $ payload = 'theMessage ' ;
174
+
163
175
$ defaultProducerMock = $ this ->createProducerMock ();
164
176
$ defaultProducerMock
165
177
->expects ($ this ->never ())
@@ -174,7 +186,7 @@ public function testShouldSendEventToFooTransport()
174
186
$ fooProducerMock
175
187
->expects ($ this ->once ())
176
188
->method ('sendEvent ' )
177
- ->with ('theTopic ' , ' theMessage ' )
189
+ ->with ('theTopic ' , new Message ( $ payload , [], [ $ header ]) )
178
190
;
179
191
$ fooProducerMock
180
192
->expects ($ this ->never ())
@@ -188,7 +200,8 @@ public function testShouldSendEventToFooTransport()
188
200
189
201
$ tester = new CommandTester ($ command );
190
202
$ tester ->execute ([
191
- 'message ' => 'theMessage ' ,
203
+ 'message ' => $ payload ,
204
+ '--header ' => $ header ,
192
205
'--topic ' => 'theTopic ' ,
193
206
'--client ' => 'foo ' ,
194
207
]);
0 commit comments