Ejemplo n.º 1
0
 public static function setUpBeforeClass()
 {
     Client::initialize(getenv("LC_APP_ID"), getenv("LC_APP_KEY"), getenv("LC_APP_MASTER_KEY"));
     Client::useRegion(getenv("LC_API_REGION"));
     Client::setStorage(new SessionStorage());
     // Try to make a default user so we can login
     $user = new User();
     $user->setUsername("alice");
     $user->setPassword("blabla");
     try {
         $user->signUp();
     } catch (CloudException $ex) {
         // skip
     }
 }
Ejemplo n.º 2
0
<?php

require_once "src/autoload.php";
use LeanCloud\Client;
use LeanCloud\Engine\LeanEngine;
use LeanCloud\Engine\Cloud;
Client::initialize(getenv("LC_APP_ID"), getenv("LC_APP_KEY"), getenv("LC_APP_MASTER_KEY"));
// define a function
Cloud::define("hello", function () {
    return "hello";
});
// define function with named params
Cloud::define("sayHello", function ($params, $user) {
    return "hello {$params['name']}";
});
Cloud::define("_messageReceived", function ($params, $user) {
    if ($params["convId"]) {
        return array("drop" => false);
    } else {
        return array("drop" => true);
    }
});
Cloud::define("getMeta", function ($params, $user, $meta) {
    return array("remoteAddress" => $meta["remoteAddress"]);
});
Cloud::define("updateObject", function ($params, $user) {
    $obj = $params["object"];
    $obj->set("__testKey", 42);
    return $obj;
});
Cloud::onLogin(function ($user) {
Ejemplo n.º 3
0
 public static function setUpBeforeClass()
 {
     Client::initialize(getenv("LC_APP_ID"), getenv("LC_APP_KEY"), getenv("LC_APP_MASTER_KEY"));
     Client::useRegion(getenv("LC_API_REGION"));
 }
Ejemplo n.º 4
0
 public function testRequestUnauthorized()
 {
     Client::initialize(getenv("LC_APP_ID"), "invalid key", "invalid master key");
     $this->setExpectedException("LeanCloud\\CloudException", "Unauthorized");
     $data = Client::request("POST", "/classes/TestObject", array("name" => "alice", "story" => "in wonderland"));
     Client::delete("/classes/TestObject/{$data['objectId']}");
 }