/** * {@inheritdoc} * * Store grid representation of terrains. */ public function addChild(Thing $child) { if (!$child instanceof Terrain) { throw new \Exception('Cannot attach something else than Terrain to World'); } //@todo return parent::addChild($child); }
/** * Test parentship from a parent viewpoint * AddChild and RemoveChild updates both sides of the relation. */ public function testAddChildRemoveChild() { $child = new Thing(); $parent = new Thing(); $parent->addChild($child); $this->assertSame($parent, $child->getParent()); $this->assertContains($child, $parent->getChildren()); $parent->removeChild($child); $this->assertNull($child->getParent()); $this->assertNotContains($child, $parent->getChildren()); }