22
33namespace Enqueue \Tests \Symfony \Client ;
44
5+ use Enqueue \Client \Message ;
56use Enqueue \Client \ProducerInterface ;
67use Enqueue \Container \Container ;
78use Enqueue \Symfony \Client \ProduceCommand ;
@@ -42,10 +43,11 @@ public function testShouldHaveExpectedOptions()
4243 $ command = new ProduceCommand ($ this ->createMock (ContainerInterface::class), 'default ' );
4344
4445 $ options = $ command ->getDefinition ()->getOptions ();
45- $ this ->assertCount (3 , $ options );
46+ $ this ->assertCount (4 , $ options );
4647 $ this ->assertArrayHasKey ('client ' , $ options );
4748 $ this ->assertArrayHasKey ('topic ' , $ options );
4849 $ this ->assertArrayHasKey ('command ' , $ options );
50+ $ this ->assertArrayHasKey ('header ' , $ options );
4951 }
5052
5153 public function testShouldHaveExpectedAttributes ()
@@ -112,11 +114,14 @@ public function testThrowIfBothTopicAndCommandOptionsAreSet()
112114
113115 public function testShouldSendEventToDefaultTransport ()
114116 {
117+ $ header = 'Content-Type: text/plain ' ;
118+ $ payload = 'theMessage ' ;
119+
115120 $ producerMock = $ this ->createProducerMock ();
116121 $ producerMock
117122 ->expects ($ this ->once ())
118123 ->method ('sendEvent ' )
119- ->with ('theTopic ' , ' theMessage ' )
124+ ->with ('theTopic ' , new Message ( $ payload , [], [ $ header ]) )
120125 ;
121126 $ producerMock
122127 ->expects ($ this ->never ())
@@ -129,7 +134,8 @@ public function testShouldSendEventToDefaultTransport()
129134
130135 $ tester = new CommandTester ($ command );
131136 $ tester ->execute ([
132- 'message ' => 'theMessage ' ,
137+ 'message ' => $ payload ,
138+ '--header ' => $ header ,
133139 '--topic ' => 'theTopic ' ,
134140 ]);
135141 }
@@ -160,6 +166,9 @@ public function testShouldSendCommandToDefaultTransport()
160166
161167 public function testShouldSendEventToFooTransport ()
162168 {
169+ $ header = 'Content-Type: text/plain ' ;
170+ $ payload = 'theMessage ' ;
171+
163172 $ defaultProducerMock = $ this ->createProducerMock ();
164173 $ defaultProducerMock
165174 ->expects ($ this ->never ())
@@ -174,7 +183,7 @@ public function testShouldSendEventToFooTransport()
174183 $ fooProducerMock
175184 ->expects ($ this ->once ())
176185 ->method ('sendEvent ' )
177- ->with ('theTopic ' , ' theMessage ' )
186+ ->with ('theTopic ' , new Message ( $ payload , [], [ $ header ]) )
178187 ;
179188 $ fooProducerMock
180189 ->expects ($ this ->never ())
@@ -188,7 +197,8 @@ public function testShouldSendEventToFooTransport()
188197
189198 $ tester = new CommandTester ($ command );
190199 $ tester ->execute ([
191- 'message ' => 'theMessage ' ,
200+ 'message ' => $ payload ,
201+ '--header ' => $ header ,
192202 '--topic ' => 'theTopic ' ,
193203 '--client ' => 'foo ' ,
194204 ]);
0 commit comments