Google\Cloud\Tests\Snippets\Datastore\TransactionTest::testRunQuery PHP Method

testRunQuery() public method

public testRunQuery ( )
    public function testRunQuery()
    {
        $snippet = $this->snippetFromMethod(Transaction::class, 'runQuery');
        $snippet->addLocal('datastore', $this->datastore);
        $snippet->addLocal('transaction', $this->transaction);
        $snippet->addLocal('query', $this->prophesize(QueryInterface::class)->reveal());
        $this->connection->runQuery(Argument::that(function ($args) {
            if ($args['transaction'] !== $this->transactionId) {
                return false;
            }
            return true;
        }))->shouldBeCalled()->willReturn(['batch' => ['entityResults' => [['entity' => ['key' => ['path' => [['kind' => 'Person', 'name' => 'Bob']]], 'properties' => ['firstName' => ['stringValue' => 'Bob']]]]]]]);
        $this->operation->setConnection($this->connection->reveal());
        $res = $snippet->invoke('result');
        $this->assertEquals('Bob', $res->output());
    }