public function testDeleteTestObject()
 {
     $data = LeanClient::post("/classes/TestObject", array("name" => "alice", "story" => "in wonderland"));
     $this->assertArrayHasKey("objectId", $data);
     LeanClient::delete("/classes/TestObject/{$data['objectId']}");
     $obj = LeanClient::get("/classes/TestObject/{$data['objectId']}");
     $this->assertEmpty($obj);
 }
Beispiel #2
0
 public function testBatchGetNotFound()
 {
     $obj = array("name" => "alice");
     $resp = LeanClient::post("/classes/TestObject", $obj);
     $this->assertNotEmpty($resp["objectId"]);
     $req[] = array("path" => "/1.1/classes/TestObject/{$resp['objectId']}", "method" => "GET");
     $req[] = array("path" => "/1.1/classes/TestObject/nonexistent_id", "method" => "GET");
     $resp2 = LeanClient::batch($req);
     $this->assertNotEmpty($resp2[0]["success"]);
     $this->assertEmpty($resp2[1]["success"]);
     // empty when not found
     LeanClient::delete("/classes/TestObject/{$resp['objectId']}");
 }
Beispiel #3
0
 /**
  * Delete file on cloud
  *
  * @throws CloudException
  */
 public function destroy()
 {
     if (!$this->getObjectId()) {
         return false;
     }
     LeanClient::delete("/files/{$this->getObjectId()}");
 }
Beispiel #4
0
 public function testUserLogin()
 {
     $data = array("username" => "testuser", "password" => "5akf#a?^G", "phone" => "18612340000");
     $resp = LeanClient::post("/users", $data);
     $this->assertNotEmpty($resp["objectId"]);
     $this->assertNotEmpty($resp["sessionToken"]);
     $id = $resp["objectId"];
     $resp = LeanClient::get("/users/me", array("session_token" => $resp["sessionToken"]));
     $this->assertNotEmpty($resp["objectId"]);
     LeanClient::delete("/users/{$id}", $resp["sessionToken"]);
     // Raise 211: Could not find user.
     $this->setExpectedException("LeanCloud\\CloudException", null, 211);
     $resp = LeanClient::get("/users/me", array("session_token" => "non-existent-token"));
 }