예제 #1
0
파일: World.php 프로젝트: asiviero/forkwars
 /**
  * {@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);
 }
예제 #2
0
 /**
  * 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());
 }