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

testUpsert() public method

public testUpsert ( )
    public function testUpsert()
    {
        $snippet = $this->snippetFromMethod(Transaction::class, 'upsert');
        $snippet->addLocal('datastore', $this->datastore);
        $snippet->addLocal('transaction', $this->transaction);
        $snippet->addLocal('entity', $this->datastore->entity($this->key, [], ['populatedByService' => true]));
        $this->connection->commit(Argument::that(function ($args) {
            if ($args['transaction'] !== $this->transactionId) {
                return false;
            }
            if (array_keys($args['mutations'][0])[0] !== 'upsert') {
                return false;
            }
            return true;
        }))->shouldBeCalled()->willReturn(['mutationResults' => [['version' => 1]]]);
        $this->operation->setConnection($this->connection->reveal());
        $res = $snippet->invoke();
    }