Google\Cloud\Tests\PubSub\TopicTest::testPublishBatch PHP Method

testPublishBatch() public method

public testPublishBatch ( )
    public function testPublishBatch()
    {
        $messages = [['data' => 'hello world', 'attributes' => ['key' => 'value']], ['data' => 'hello again, world', 'attributes' => ['key' => 'other value i guess']]];
        $ids = ['message1id', 'message2id'];
        $this->connection->publishMessage(Argument::that(function ($options) use($messages) {
            if ($options['foo'] !== 'bar') {
                return false;
            }
            $messages[0]['data'] = base64_encode($messages[0]['data']);
            $messages[1]['data'] = base64_encode($messages[1]['data']);
            if ($options['messages'] !== $messages) {
                return false;
            }
            return true;
        }))->willReturn($ids);
        $this->topic->setConnection($this->connection->reveal());
        $res = $this->topic->publishBatch($messages, ['foo' => 'bar']);
        $this->assertEquals($res, $ids);
    }