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

testInsert() public method

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