public function testGetById() { $obj = new Object("TestObject"); $id = microtime(); $obj->set("testid", $id); $obj->save(); $query = new Query("TestObject"); $obj2 = $query->get($obj->getObjectId()); $this->assertEquals($obj->get("testid"), $obj2->get("testid")); $obj->destroy(); }
public function testSetGeoPoint() { $obj = new Object("TestObject"); $obj->set("location", new GeoPoint(39.9, 116.4)); $obj->save(); $obj2 = new Object("TestObject", $obj->getObjectId()); $obj2->fetch(); $loc = $obj2->get("location"); $this->assertTrue($loc instanceof GeoPoint); $this->assertEquals(39.9, $loc->getLatitude()); $this->assertEquals(116.4, $loc->getLongitude()); }
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(); }