public function testGetById() { $obj = new LeanObject("TestObject"); $id = microtime(); $obj->set("testid", $id); $obj->save(); $query = new LeanQuery("TestObject"); $obj2 = $query->get($obj->getObjectId()); $this->assertEquals($obj->get("testid"), $obj2->get("testid")); $obj->destroy(); }
/** * Test relation */ public function testAddRelation() { $obj = new LeanObject("TestObject"); $rel = $obj->getRelation("authors"); $rel->add(new LeanObject("TestAuthor", "abc101")); $out = $rel->encode(); $this->assertEquals("Relation", $out["__type"]); $this->assertEquals("TestAuthor", $out["className"]); $val = $obj->get("authors"); $this->assertTrue($val instanceof LeanRelation); $out = $val->encode(); $this->assertEquals("Relation", $out["__type"]); $this->assertEquals("TestAuthor", $out["className"]); }
public function testSetGeoPoint() { $obj = new LeanObject("TestObject"); $obj->set("location", new GeoPoint(39.9, 116.4)); $obj->save(); $obj2 = new LeanObject("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()); }