Exemple #1
0
 public function testMatchesFieldInQuery()
 {
     $q1 = new Query("Post");
     $q1->contains("title", "clojure");
     $out1 = $q1->encode();
     $where1 = array("title" => array('$regex' => "clojure"));
     $this->assertEquals(json_encode($where1), $out1["where"]);
     $query = new Query("Comment");
     $query->matchesFieldInQuery("author", "author", $q1);
     $out = $query->encode();
     $where = array("author" => array('$select' => array("key" => "author", "query" => array("where" => $where1, "className" => "Post"))));
     $this->assertEquals(json_encode($where), $out["where"]);
     $query = new Query("Comment");
     $query->notMatchFieldInQuery("author", "author", $q1);
     $out = $query->encode();
     $where = array("author" => array('$dontSelect' => array("key" => "author", "query" => array("where" => $where1, "className" => "Post"))));
     $this->assertEquals(json_encode($where), $out["where"]);
 }