@@ -59,7 +59,7 @@ public function testPublishWhenTopicMustBeCreated()
5959 ->once ();
6060 $ topic ->shouldReceive ('publish ' )
6161 ->with ([
62- 'data ' => 'a:1:{s:5: "hello";s:5: "world"; } ' ,
62+ 'data ' => '{ "hello": "world"} ' ,
6363 ])
6464 ->once ();
6565
@@ -83,7 +83,7 @@ public function testPublishWhenTopicExists()
8383 $ topic ->shouldNotHaveReceived ('create ' );
8484 $ topic ->shouldReceive ('publish ' )
8585 ->with ([
86- 'data ' => 'a:1:{s:5: "hello";s:5: "world"; } ' ,
86+ 'data ' => '{ "hello": "world"} ' ,
8787 ])
8888 ->once ();
8989
@@ -105,7 +105,7 @@ public function testPublishWhenAutoTopicCreationIsDisabled()
105105 $ topic ->shouldNotHaveReceived ('create ' );
106106 $ topic ->shouldReceive ('publish ' )
107107 ->with ([
108- 'data ' => 'a:1:{s:5: "hello";s:5: "world"; } ' ,
108+ 'data ' => '{ "hello": "world"} ' ,
109109 ])
110110 ->once ();
111111
@@ -120,11 +120,39 @@ public function testPublishWhenAutoTopicCreationIsDisabled()
120120 $ adapter ->publish ('channel_name ' , ['hello ' => 'world ' ]);
121121 }
122122
123+ public function testPublishBatch ()
124+ {
125+ $ topic = Mockery::mock (Topic::class);
126+ $ topic ->shouldReceive ('exists ' )
127+ ->once ()
128+ ->andReturn (true );
129+ $ topic ->shouldReceive ('publishBatch ' )
130+ ->with ([
131+ ['data ' => '{"hello":"world"} ' ],
132+ ['data ' => '"booo!" ' ],
133+ ])
134+ ->once ();
135+
136+ $ client = Mockery::mock (PubSubClient::class);
137+ $ client ->shouldReceive ('topic ' )
138+ ->with ('channel_name ' )
139+ ->once ()
140+ ->andReturn ($ topic );
141+
142+ $ adapter = new GoogleCloudPubSubAdapter ($ client );
143+
144+ $ messages = [
145+ ['hello ' => 'world ' ],
146+ 'booo! ' ,
147+ ];
148+ $ adapter ->publishBatch ('channel_name ' , $ messages );
149+ }
150+
123151 public function testSubscribeWhenSubscriptionMustBeCreated ()
124152 {
125- $ message1 = new Message (['data ' => 'a:1:{s:5: "hello";s:5: "world"; } ' ], ['ackId ' => 1 ]);
126- $ message2 = new Message (['data ' => 'this is a string ' ], ['ackId ' => 2 ]);
127- $ message3 = new Message (['data ' => 'unsubscribe ' ], ['ackId ' => 3 ]);
153+ $ message1 = new Message (['data ' => '{ "hello": "world"} ' ], ['ackId ' => 1 ]);
154+ $ message2 = new Message (['data ' => '" this is a string" ' ], ['ackId ' => 2 ]);
155+ $ message3 = new Message (['data ' => '" unsubscribe" ' ], ['ackId ' => 3 ]);
128156
129157 $ messageBatch1 = [
130158 $ message1 ,
@@ -198,9 +226,9 @@ public function testSubscribeWhenSubscriptionMustBeCreated()
198226
199227 public function testSubscribeWhenSubscriptionExists ()
200228 {
201- $ message1 = new Message (['data ' => 'a:1:{s:5: "hello";s:5: "world"; } ' ], ['ackId ' => 1 ]);
202- $ message2 = new Message (['data ' => 'this is a string ' ], ['ackId ' => 2 ]);
203- $ message3 = new Message (['data ' => 'unsubscribe ' ], ['ackId ' => 3 ]);
229+ $ message1 = new Message (['data ' => '{ "hello": "world"} ' ], ['ackId ' => 1 ]);
230+ $ message2 = new Message (['data ' => '" this is a string" ' ], ['ackId ' => 2 ]);
231+ $ message3 = new Message (['data ' => '" unsubscribe" ' ], ['ackId ' => 3 ]);
204232
205233 $ messageBatch1 = [
206234 $ message1 ,
@@ -272,9 +300,9 @@ public function testSubscribeWhenSubscriptionExists()
272300
273301 public function testSubscribeWhenAutoTopicCreationIsDisabled ()
274302 {
275- $ message1 = new Message (['data ' => 'a:1:{s:5: "hello";s:5: "world"; } ' ], ['ackId ' => 1 ]);
276- $ message2 = new Message (['data ' => 'this is a string ' ], ['ackId ' => 2 ]);
277- $ message3 = new Message (['data ' => 'unsubscribe ' ], ['ackId ' => 3 ]);
303+ $ message1 = new Message (['data ' => '{ "hello": "world"} ' ], ['ackId ' => 1 ]);
304+ $ message2 = new Message (['data ' => '" this is a string" ' ], ['ackId ' => 2 ]);
305+ $ message3 = new Message (['data ' => '" unsubscribe" ' ], ['ackId ' => 3 ]);
278306
279307 $ messageBatch1 = [
280308 $ message1 ,
0 commit comments