/** * Remove object(s) from the field * * @param object|array $objects Object(s) to remove */ public function remove($objects) { if (!is_array($objects)) { $objects = array($objects); } $op = new RelationOperation($this->key, null, $objects); $this->parent->set($this->key, $op); if (!$this->targetClassName) { $this->targetClassName = $op->getTargetClassName(); } }
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 testGeoPointLocation() { $point = new GeoPoint(25.269876, 110.333061); $location = new Object("Location"); $location->set("location", $point); $location->save(); $location->destroy(); }
public function testSaveObjectWithFile() { $obj = new Object("TestObject"); $obj->set("name", "alice"); $file = File::createWithData("test.txt", "你好,中国!"); $obj->addIn("files", $file); $obj->save(); $this->assertNotEmpty($obj->getObjectId()); $this->assertNotEmpty($file->getObjectId()); $this->assertNotEmpty($file->getUrl()); $file->destroy(); $obj->destroy(); }
public function testEncodeCircularObjectAsPointer() { $a = new Object("TestObject", "id001"); $b = new Object("TestObject", "id002"); $c = new Object("TestObject", "id003"); $a->set("name", "A"); $b->set("name", "B"); $c->set("name", "C"); $a->addIn("likes", $b); $b->addIn("likes", $c); $c->addIn("likes", $a); $jsonA = Client::encode($a, "toFullJSON"); $jsonB = $jsonA["likes"][0]; $jsonC = $jsonB["likes"][0]; $this->assertEquals("Object", $jsonA["__type"]); $this->assertEquals("Object", $jsonB["__type"]); $this->assertEquals("Object", $jsonC["__type"]); $this->assertEquals("Pointer", $jsonC["likes"][0]["__type"]); }