Google\Cloud\Tests\Datastore\OperationTest::testRunQuery PHP Method

testRunQuery() public method

public testRunQuery ( )
    public function testRunQuery()
    {
        $queryResult = json_decode(file_get_contents(__DIR__ . '/../fixtures/datastore/query-results.json'), true);
        $this->connection->runQuery(Argument::type('array'))->willReturn($queryResult['notPaged']);
        $this->operation->setConnection($this->connection->reveal());
        $q = $this->prophesize(QueryInterface::class);
        $q->queryKey()->shouldBeCalled()->willReturn('query');
        $q->queryObject()->shouldBeCalled()->willReturn([]);
        $q->canPaginate()->willReturn(true);
        $q->start(Argument::any());
        $res = $this->operation->runQuery($q->reveal());
        $this->assertInstanceOf(\Generator::class, $res);
        $arr = iterator_to_array($res);
        $this->assertEquals(count($arr), 2);
        $this->assertInstanceOf(Entity::class, $arr[0]);
    }