Google\Cloud\Tests\PubSub\SubscriptionTest::testPullWithCustomArgs PHP Method

testPullWithCustomArgs() public method

    public function testPullWithCustomArgs()
    {
        $messages = ['receivedMessages' => [['message' => []], ['message' => []]]];
        $this->connection->pull(Argument::that(function ($args) {
            if ($args['foo'] !== 'bar') {
                return false;
            }
            if ($args['returnImmediately'] !== true) {
                return false;
            }
            if ($args['maxMessages'] !== 2) {
                return false;
            }
            return true;
        }))->willReturn($messages)->shouldBeCalledTimes(1);
        $this->subscription->setConnection($this->connection->reveal());
        $result = $this->subscription->pull(['foo' => 'bar', 'returnImmediately' => true, 'maxMessages' => 2]);
        $this->assertInstanceOf(Generator::class, $result);
        $arr = iterator_to_array($result);
        $this->assertInstanceOf(Message::class, $arr[0]);
        $this->assertInstanceOf(Message::class, $arr[1]);
    }