Beispiel #1
0
 public static function XMLRelationshipData()
 {
     //  MOTHER
     $birthDate = new \DateTime('January 21, 1923');
     $birth = new Fact(array("type" => FactType::BIRTH, "date" => new DateInfo(array("original" => $birthDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => 'Flagstaff, Arizona, United States'))));
     $deathDate = new \DateTime('October 12, 1987');
     $death = new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "One. Two. Buckle my shoe.", "original" => 'San Antonio, Texas, United States'))));
     $facts = array();
     $facts[] = $birth;
     $facts[] = $death;
     $mother = new Person();
     $mother->setGender(new Gender(array("type" => GenderType::FEMALE)));
     $mother->setLiving(false);
     $mother->setPrincipal(false);
     $name = PersonBuilder::makeName('Hildegard', 'Schmidlab');
     $mother->setNames(array($name));
     $mother->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => GenderType::FEMALE, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . $death->getDate()->getDateTime()->format("d M Y"), "name" => $name->toString()));
     $mother->setDisplayExtension($display);
     //  FATHER
     $birthDate = new \DateTime('February 2, 1915');
     $birth = new Fact(array("type" => FactType::BIRTH, "date" => new DateInfo(array("original" => $birthDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => 'Flagstaff, Arizona, United States'))));
     $deathDate = new \DateTime('January 12, 1977');
     $death = new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "One. Two. Buckle my shoe.", "original" => 'San Antonio, Texas, United States'))));
     $facts = array();
     $facts[] = $birth;
     $facts[] = $death;
     $father = new Person();
     $father->setGender(new Gender(array("type" => GenderType::MALE)));
     $father->setLiving(false);
     $father->setPrincipal(false);
     $name = PersonBuilder::makeName('Marvin', 'Schmidlab');
     $father->setNames(array($name));
     $father->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => GenderType::MALE, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . $death->getDate()->getDateTime()->format("d M Y"), "name" => $name->toString()));
     $father->setDisplayExtension($display);
     //  CHILD
     $birthDate = new \DateTime('March 12, 1935');
     $birth = new Fact(array("type" => FactType::BIRTH, "date" => new DateInfo(array("original" => $birthDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => 'Santa Fe, New Mexico, United States'))));
     $deathDate = new \DateTime('January 2, 2007');
     $death = new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "One. Two. Buckle my shoe.", "original" => 'San Antonio, Texas, United States'))));
     $facts = array();
     $facts[] = $birth;
     $facts[] = $death;
     $child = new Person();
     $child->setGender(new Gender(array("type" => GenderType::MALE)));
     $child->setLiving(false);
     $child->setPrincipal(false);
     $name = PersonBuilder::makeName('Englebert', 'Schmidlab');
     $child->setNames(array($name));
     $child->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => GenderType::MALE, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . $death->getDate()->getDateTime()->format("d M Y"), "name" => $name->toString()));
     $child->setDisplayExtension($display);
     return array('father' => $father, 'mother' => $mother, 'child' => $child);
 }
 public function testReadCoupleRelationshipChangeHistory()
 {
     $factory = new FamilyTreeStateFactory();
     $this->collectionState($factory);
     /** @var FamilyTreePersonState $husband */
     $husband = $this->createPerson('male')->get();
     $wife = $this->createPerson('female');
     /** @var FamilyTreeRelationshipState $relationship */
     $relationship = $husband->addSpouse($wife)->get();
     $this->queueForDelete($relationship);
     $fact = new Fact();
     $attribution = new Attribution();
     $attribution->setChangeMessage("Change message");
     $fact->setType("http://gedcomx.org/Marriage");
     $fact->setAttribution($attribution);
     $date = new DateInfo();
     $date->setOriginal("3 Apr 1930");
     $date->setFormal("+1930");
     $fact->setDate($date);
     $place = new PlaceReference();
     $place->setOriginal("Moscow, Russia");
     $fact->setPlace($place);
     $relationship->addFact($fact);
     $state = $relationship->readChangeHistory();
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals((int) $state->getResponse()->getStatusCode(), 200);
     $this->assertNotNull($state->getPage());
     $this->assertNotNull($state->getPage()->getEntries());
     $this->assertGreaterThan(0, count($state->getPage()->getEntries()));
 }
 /**
  * Delete a fact from this relationship
  *
  * @param \Gedcomx\Conclusion\Fact                         $fact
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return ChildAndParentsRelationshipState
  * @throws GedcomxApplicationException
  */
 public function deleteFact(Fact $fact, StateTransitionOption $option = null)
 {
     $link = $fact->getLink(Rel::CONCLUSION);
     $link = $link == null ? $fact->getLink(Rel::SELF) : $link;
     if ($link == null || $link->getHref() == null) {
         throw new GedcomxApplicationException("Conclusion cannot be deleted: missing link.");
     }
     $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes());
     return $this->stateFactory->createState('ChildAndParentsRelationshipState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
Beispiel #4
0
 /**
  * @vcr PedigreeTests/testReadPersonDescendancyWithSpecifiedSpouseAndAdditionalPersonAndMarriageDetails.json
  * @link https://familysearch.org/developers/docs/api/tree/Read_Person_Descendancy_with_Specified_Spouse_and_additional_person_and_marriage_details_usecase
  * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException
  */
 public function testReadPersonDescendancyWithSpecifiedSpouseAndAdditionalPersonAndMarriageDetails()
 {
     $factory = new FamilyTreeStateFactory();
     $collection = $this->collectionState($factory);
     $father = $this->createPerson('male');
     $this->assertEquals(HttpStatus::CREATED, $father->getStatus());
     $father = $father->get();
     $this->assertEquals(HttpStatus::OK, $father->getStatus());
     $mother = $this->createPerson('female');
     $this->assertEquals(HttpStatus::CREATED, $mother->getStatus());
     $son = $this->createPerson('male');
     $this->assertEquals(HttpStatus::CREATED, $son->getStatus());
     $fact = new Fact();
     $attribution = new Attribution();
     $attribution->setChangeMessage("Change message");
     $fact->setType("http://gedcomx.org/Marriage");
     $fact->setAttribution($attribution);
     $date = new DateInfo();
     $date->setOriginal("3 Apr 1930");
     $date->setFormal("+1930");
     $fact->setDate($date);
     $place = new PlaceReference();
     $place->setOriginal("Moscow, Russia");
     $fact->setPlace($place);
     $father->addSpouse($mother)->addFact($fact);
     $relationship = new ChildAndParentsRelationship();
     $relationship->setFather($father->getResourceReference());
     $relationship->setMother($mother->getResourceReference());
     $relationship->setChild($son->getResourceReference());
     $r1 = $collection->addChildAndParentsRelationship($relationship);
     $this->queueForDelete($r1);
     $this->assertEquals(HttpStatus::CREATED, $r1->getStatus());
     $state = $father->readDescendancy(new QueryParameter(true, "spouse", $mother->getHeader("X-ENTITY-ID")[0]), new QueryParameter(true, "personDetails", "true"), new QueryParameter(true, "marriageDetails", "true"));
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals((int) $state->getStatus(), 200);
     $this->assertNotNull($state->getTree());
     $this->assertNotNull($state->getTree()->getRoot());
     $this->assertNotNull($state->getTree()->getRoot()->getPerson());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse());
     $this->assertNotNull($state->getTree()->getRoot()->getChildren());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse()->getDisplayExtension());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse()->getDisplayExtension()->getMarriageDate());
     $this->assertNotNull($state->getTree()->getRoot()->getPerson()->getFacts());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse()->getFacts());
     $this->assertEquals(1, count($state->getTree()->getRoot()->getChildren()));
     $this->assertNotNull($state->getTree()->getRoot()->Children[0]->getPerson());
     $this->assertEquals($father->getPerson()->getId(), $state->getTree()->getRoot()->getPerson()->getId());
     $this->assertEquals($mother->getHeader("X-ENTITY-ID")[0], $state->getTree()->getRoot()->getSpouse()->getId());
     $this->assertEquals($son->getHeader("X-ENTITY-ID")[0], $state->getTree()->getRoot()->Children[0]->getPerson()->getId());
 }
Beispiel #5
0
 public static function death(Fact $birth)
 {
     $rnd = self::faker()->numberBetween(5, 95);
     $deathDate = new \DateTime($birth->getDate()->getDateTime()->format("F d, Y") . "+{$rnd}years");
     return new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => self::faker()->city() . ", " . self::faker()->state() . ", United States"))));
 }