public function testSaveChildsWithPersona() { $father = new Persona(Persona::GENDER_MALE); $son = new Persona(Persona::GENDER_MALE); $daughter = new Persona(Persona::GENDER_FEMALE); $father->addChild($son); $father->addChild($daughter); $repository = $this->getRepository(); $repository->save($father); $this->assertTableHasData('persona', ['id' => $son->getId(), 'father_id' => $father->getId()]); }
public function testParentsForChild() { $persona = new Persona(); $father = new Persona(Persona::GENDER_MALE); $father->addChild($persona); $this->assertEquals($father, $persona->getFather()); $mother = new Persona(Persona::GENDER_FEMALE); $mother->addChild($persona); $this->assertEquals($mother, $persona->getMother()); }