Ejemplo n.º 1
0
 public function testUpdateTestObject()
 {
     $data = Client::post("/classes/TestObject", array("name" => "alice", "story" => "in wonderland"));
     $this->assertArrayHasKey("objectId", $data);
     Client::put("/classes/TestObject/{$data['objectId']}", array("name" => "Hiccup", "story" => "How to train your dragon"));
     $obj = Client::get("/classes/TestObject/{$data['objectId']}");
     $this->assertEquals($obj["name"], "Hiccup");
     $this->assertEquals($obj["story"], "How to train your dragon");
     Client::delete("/classes/TestObject/{$obj['objectId']}");
 }
Ejemplo n.º 2
0
 /**
  * Batch on array operation will result error:
  *
  * 301 - Fails to insert new document, cannot update on ...
  *       at the same time.
  */
 public function testBatchOperationOnArray()
 {
     $obj = array("name" => "Batch test", "tags" => array());
     $resp = Client::post("/classes/TestObject", $obj);
     $this->assertNotEmpty($resp["objectId"]);
     $adds = array("__op" => "Add", "objects" => array("javascript", "frontend"));
     $removes = array("__op" => "Remove", "objects" => array("frontend", "css"));
     $obj = array("tags" => array("__op" => "Batch", "ops" => array($adds, $removes)));
     $this->setExpectedException("LeanCloud\\CloudException", null, 301);
     $resp = Client::put("/classes/TestObject/{$resp['objectId']}", $obj);
     Client::delete("/classes/TestObject/{$obj['objectId']}");
 }
Ejemplo n.º 3
0
 /**
  * Reset password by SMS code.
  *
  * @param string $smsCode
  * @param string $newPassword
  */
 public static function resetPasswordBySmsCode($smsCode, $newPassword)
 {
     Client::put("/resetPasswordBySmsCode/{$smsCode}", array("password" => $newPassword));
 }