public function testRelationClassEncode() { $obj = new LeanObject("TestObject"); $rel = $obj->getRelation("likes"); $out = $rel->encode(); $this->assertEquals("Relation", $out["__type"]); $child1 = new LeanObject("User", "abc101"); $rel->add($child1); $out = $rel->encode(); $this->assertEquals("User", $out["className"]); }
/** * 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"]); }