Example #1
0
 public function testSelectFields()
 {
     $query = new Query("TestObject");
     $query->select("name", "color", "foo", "bar");
     $out = $query->encode();
     $this->assertEquals("name,color,foo,bar", $out["keys"]);
     // it accepts variable number of keys
     $query = new Query("TestObject");
     $query->select("name");
     $query->select("color");
     $query->select("foo", "bar");
     $out = $query->encode();
     $this->assertEquals("name,color,foo,bar", $out["keys"]);
     // it also accepts an array of keys
     $query = new Query("TestObject");
     $query->select(array("name", "color", "foo", "bar"));
     $out = $query->encode();
     $this->assertEquals("name,color,foo,bar", $out["keys"]);
     // it can exclude fields too
     $query->select("-image");
     $out = $query->encode();
     $this->assertEquals("name,color,foo,bar,-image", $out["keys"]);
 }