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()));
 }
Exemple #2
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());
 }
 /**
  * Normalizes the specified date to a DateInfo.
  *
  * @param string                $date
  * @param StateTransitionOption $option,...
  *
  * @return \Gedcomx\Conclusion\DateInfo|null
  */
 public function normalizeDate($date, StateTransitionOption $option = null)
 {
     $link = $this->getLink(Rel::NORMALIZED_DATE);
     if ($link == null || $link->getTemplate() == null) {
         return null;
     }
     $uri = array($link->getTemplate(), array('date' => $date));
     $request = $this->createRequest('GET', $uri);
     $response = $this->passOptionsTo('invoke', array($request), func_get_args());
     $dateValue = new DateInfo();
     $dateValue->setOriginal($date);
     $dateValue->addNormalizedExtension(new TextValue(array('value' => $response->getBody())));
     $headers = $response->getHeaders();
     if ($headers != null && isset($headers["Location"])) {
         $dateValue->setFormal($headers["Location"][0]);
         return $dateValue;
     }
     return null;
 }