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

testInsert() public method

public testInsert ( )
    public function testInsert()
    {
        $snippet = $this->snippetFromMethod(DatastoreClient::class, 'insert');
        $snippet->addLocal('datastore', $this->client);
        $this->connection->commit(Argument::that(function ($args) {
            if (array_keys($args['mutations'][0])[0] !== 'insert') {
                return false;
            }
            return true;
        }))->shouldBeCalled()->willReturn(['mutationResults' => [['version' => 1]]]);
        $this->client->setConnection($this->connection->reveal());
        $res = $snippet->invoke('entity');
        $this->assertEquals(Key::STATE_NAMED, $res->returnVal()->key()->state());
    }