public function testUpdateTestObject() { $data = LeanClient::post("/classes/TestObject", array("name" => "alice", "story" => "in wonderland")); $this->assertArrayHasKey("objectId", $data); LeanClient::put("/classes/TestObject/{$data['objectId']}", array("name" => "Hiccup", "story" => "How to train your dragon")); $obj = LeanClient::get("/classes/TestObject/{$data['objectId']}"); $this->assertEquals($obj["name"], "Hiccup"); $this->assertEquals($obj["story"], "How to train your dragon"); LeanClient::delete("/classes/TestObject/{$obj['objectId']}"); }
/** * 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 = LeanClient::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\\LeanException", null, 301); $resp = LeanClient::put("/classes/TestObject/{$resp['objectId']}", $obj); LeanClient::delete("/classes/TestObject/{$obj['objectId']}"); }
/** * Reset password by SMS code. * * @param string $smsCode * @param string $newPassword */ public static function resetPasswordBySmsCode($smsCode, $newPassword) { LeanClient::put("/resetPasswordBySmsCode/{$smsCode}", array("password" => $newPassword)); }