Example #1
0
 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"]);
 }
Example #2
0
 public function testComposeCompexLogicalQuery()
 {
     $q1 = new Query("TestObject");
     $q1->greaterThanOrEqualTo("number", 42);
     $q2 = new Query("TestObject");
     $q2->lessThan("number", 24);
     $q3 = new Query("TestObject");
     $q3->contains("title", "clojure");
     $q = Query::orQuery($q1, $q2);
     $out = $q->encode();
     $where = array('$or' => array(array("number" => array('$gte' => 42)), array("number" => array('$lt' => 24))));
     $this->assertEquals(json_encode($where), $out["where"]);
     $q = Query::andQuery($q, $q3);
     $out = $q->encode();
     $where = array('$and' => array(array('$or' => array(array("number" => array('$gte' => 42)), array("number" => array('$lt' => 24)))), array("title" => array('$regex' => "clojure"))));
     $this->assertEquals(json_encode($where), $out["where"]);
 }