Example #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);
 }
 /**
  * @vcr FamilySearchClientTests/testSetPendingModifications.json
  */
 public function testSetPendingModifications()
 {
     $features = $this->createAuthenticatedFamilySearchClient()->getAvailablePendingModifications();
     $modifications = array_map(function (Feature $feature) {
         return $feature->getName();
     }, $features);
     $featuresHeader = null;
     $client = $this->createAuthenticatedFamilySearchClient(['pendingModifications' => $modifications, 'middleware' => [Middleware::tap(function (RequestInterface $request, $options) use(&$featuresHeader) {
         $featuresHeader = $request->getHeader('X-FS-Feature-Tag')[0];
     })]]);
     $person = PersonBuilder::buildPerson('');
     $responseState = $client->familytree()->addPerson($person);
     $this->queueForDelete($responseState);
     // Ensure a response came back
     $this->assertNotNull($responseState);
     $check = array();
     // Ensure each requested feature was found in the request headers
     foreach ($features as $feature) {
         $this->assertTrue(strpos($featuresHeader, $feature->getName()) !== false, $feature->getName() . " was not found in the requested features.");
     }
 }
Example #3
0
 /**
  * @link https://familysearch.org/developers/docs/api/memories/Update_Memory_Persona_usecase
  */
 public function testCreateUpdateDeleteMemoryPersona()
 {
     $filename = ArtifactBuilder::makeImage();
     $artifact = new DataSource();
     $artifact->setFile($filename);
     $description = SourceBuilder::newSource();
     $factory = new FamilyTreeStateFactory();
     /** @var FamilySearchMemories $memories */
     $memories = $factory->newMemoriesState();
     $memories = $this->authorize($memories);
     $this->assertNotEmpty($memories->getAccessToken());
     /** @var \Gedcomx\Rs\Client\SourceDescriptionState $upload */
     $upload = $memories->addArtifact($artifact, $description);
     $this->assertEquals(HttpStatus::CREATED, $upload->getStatus());
     $upload = $upload->get();
     $this->assertEquals(HttpStatus::OK, $upload->getStatus());
     $factory = new StateFactory();
     $this->collectionState($factory);
     /** @var FamilyTreePersonState $person1 */
     $person1 = $this->createPerson('male');
     $this->assertEquals(HttpStatus::CREATED, $person1->getStatus());
     $person1 = $person1->get();
     $this->assertEquals(HttpStatus::OK, $person1->getStatus());
     $person2 = PersonBuilder::buildPerson('male');
     $persona = $upload->addPersonPersona($person2);
     $this->assertEquals(HttpStatus::CREATED, $persona->getStatus());
     $person1->addPersonaPersonState($persona);
     $personas = $person1->loadPersonaReferences();
     $this->assertEquals(HttpStatus::OK, $personas->getStatus());
     $personas = $personas->get();
     $this->assertEquals(HttpStatus::OK, $personas->getStatus());
     /** @var PersonState $updated */
     $updated = $personas->update($personas->getPerson());
     $this->assertEquals(HttpStatus::NO_CONTENT, $updated->getStatus(), $this->buildFailMessage(__METHOD__, $updated));
     $persona = $persona->delete();
     $this->assertEquals(HttpStatus::NO_CONTENT, $persona->getStatus(), $this->buildFailMessage(__METHOD__, $persona));
     $personas = $upload->readPersonas();
     $this->assertEquals(HttpStatus::NO_CONTENT, $personas->getStatus());
     $this->assertNull($personas->getPersons());
     $upload->delete();
     $person1->delete();
 }
 /**
  * @vcr SearchAndMatchTests/testUpdateMatchStatusForPersonRecordMatches.json
  * @link https://familysearch.org/developers/docs/api/tree/Update_Match_Status_for_Person_Record_Matches_usecase
  */
 public function testUpdateMatchStatusForPersonRecordMatches()
 {
     $factory = new FamilyTreeStateFactory();
     $this->collectionState($factory);
     $collection = new QueryParameter(true, "collection", "https://familysearch.org/platform/collections/records");
     $p = PersonBuilder::buildPerson(null);
     $person1 = $this->collectionState()->addPerson($p, $this->createCacheBreakerQueryParam());
     $this->assertEquals(HttpStatus::CREATED, $person1->getStatus());
     $person2 = $this->collectionState()->addPerson($p, $this->createCacheBreakerQueryParam());
     $this->assertEquals(HttpStatus::CREATED, $person2->getStatus());
     $person2 = $person2->get();
     $this->assertEquals(HttpStatus::OK, $person2->getStatus());
     $this->queueForDelete($person1, $person2);
     $this->waitForServerUpdates();
     /** @var \Gedcomx\Extensions\FamilySearch\Rs\Client\PersonMatchResultsState $matches */
     $matches = $person2->readMatches();
     $this->assertEquals(HttpStatus::OK, $matches->getStatus(), $this->buildFailMessage(__METHOD__, $matches));
     $accepted = new QueryParameter(true, "status", "accepted");
     $this->assertNotNull($matches->getResults());
     $this->assertNotEmpty($matches->getResults()->getEntries());
     $entries = $matches->getResults()->getEntries();
     /** @var \Gedcomx\Atom\Entry $entry */
     $entry = array_shift($entries);
     $id = $entry->getId();
     $state = $matches->updateMatchStatus($entry, $accepted, $collection);
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals(HttpStatus::NO_CONTENT, $state->getStatus());
     $statuses = new QueryParameter(true, "status", "accepted");
     $matches = $person2->readMatches($statuses);
     $this->assertEquals(HttpStatus::OK, $person2->getStatus());
     $this->assertNotNull($matches->getResults());
     $this->assertNotEmpty($matches->getResults()->getEntries());
     $entries = $matches->getResults()->getEntries();
     /** @var \Gedcomx\Atom\Entry $entry */
     $entry = array_shift($entries);
     $this->assertEquals($id, $entry->getId());
 }
Example #5
0
 /**
  * @vcr PersonTests/testDeletePersonNotAMatch.json
  * @link https://familysearch.org/developers/docs/api/tree/Delete_Person_Not-a-Match_usecase
  */
 public function testDeletePersonNotAMatch()
 {
     $factory = new FamilyTreeStateFactory();
     $this->collectionState($factory);
     $personData = PersonBuilder::buildPerson(null);
     /** @var FamilyTreePersonState $one */
     $one = $this->collectionState()->addPerson($personData)->get();
     $two = $this->collectionState()->addPerson($personData)->get();
     $this->queueForDelete($one, $two);
     $nonMatch = $one->addNonMatchPerson($two->getPerson());
     $rematch = $nonMatch->removeNonMatch($two->getPerson());
     $this->assertEquals(HttpStatus::NO_CONTENT, $rematch->getStatus(), "Restore person failed. Returned {$rematch->getStatus()}");
 }
Example #6
0
 protected function createPerson($gender = null)
 {
     $person = PersonBuilder::buildPerson($gender);
     $state = $this->collectionState()->addPerson($person);
     $this->queueForDelete($state);
     return $state;
 }