public function testSetWhere() { $push = new Push(array("alert" => "Hello world!")); $query = new Query("_Installation"); $date = new DateTime(); $query->lessThan("updatedAt", $date); $push->setWhere($query); $out = $push->encode(); $this->assertEquals(array("updatedAt" => array('$lt' => Client::encode($date))), $out["where"]); }
public function testDoCloudQueryWithPvalues() { $obj = new Object("TestObject"); $obj->set("name", "alice"); $obj->save(); $resp = Query::doCloudQuery("SELECT * FROM TestObject " . "WHERE name = ? LIMIT ?", array("alice", 1)); $this->assertGreaterThan(0, count($resp["results"])); $obj->destroy(); }
public function testSaveWhenWhere() { $obj = new Object("TestObject"); $obj->set("score", 6); $obj->save(); $this->assertNotEmpty($obj->getObjectId()); $obj->set("level", "good"); $query = new Query("TestObject"); $query->greaterThanOrEqualTo("score", 8); $option = new SaveOption(); $option->where = $query; $this->setExpectedException("LeanCloud\\CloudException"); $obj->save($option); $query->greaterThanOrEqualTo("score", 6); $option->where = $query; $obj->increment("score"); $obj->save($option); $this->assertEquals(7, $obj->get("score")); }
/** * Not-match values of specified field from a sub-query * * @param string $key * @param string $queryKey Target field key in sub-query * @param Query $query The sub-query * @return self */ public function notMatchFieldInQuery($key, $queryKey, $query) { $this->_addCondition($key, '$dontSelect', array("key" => $queryKey, "query" => array("where" => $query->where, "className" => $query->getClassName()))); return $this; }
/** * Query on the parent class where child is in the relation * * @param Object $child Child object * @return Query */ public function getReverseQuery(Object $child) { $query = new Query($this->parent->getClassName()); $query->equalTo($this->key, $child->getPointer()); return $query; }
public function testFindUserWithSession() { $user = User::logIn("alice", "blabla"); $query = new Query("_User"); // it should not raise: 1 Forbidden to find by class permission. $query->first(); }
/** * Get roles the user belongs to * * @return array Array of Role */ public function getRoles() { if (!$this->getObjectId()) { return array(); } $query = new Query("_Role"); $query->equalTo("users", $this); $roles = $query->find(); return $roles; }