示例#1
0
 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()));
 }
示例#2
0
 /**
  * Writes the contents of this Coverage to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     parent::writeXmlContents($writer);
     if ($this->recordType) {
         $writer->startElementNs('gx', 'recordType', null);
         $writer->text($this->recordType);
         $writer->endElement();
     }
     if ($this->spatial) {
         $writer->startElementNs('gx', 'spatial', null);
         $this->spatial->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->temporal) {
         $writer->startElementNs('gx', 'temporal', null);
         $this->temporal->writeXmlContents($writer);
         $writer->endElement();
     }
 }
示例#3
0
 /**
  * Writes the contents of this Fact to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->primary) {
         $writer->writeAttribute('primary', $this->primary);
     }
     if ($this->type) {
         $writer->writeAttribute('type', $this->type);
     }
     parent::writeXmlContents($writer);
     if ($this->date) {
         $writer->startElementNs('gx', 'date', null);
         $this->date->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->place) {
         $writer->startElementNs('gx', 'place', null);
         $this->place->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->value) {
         $writer->startElementNs('gx', 'value', null);
         $writer->text($this->value);
         $writer->endElement();
     }
     if ($this->qualifiers) {
         foreach ($this->qualifiers as $i => $x) {
             $writer->startElementNs('gx', 'qualifier', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
示例#4
0
 /**
  * Writes the contents of this Event to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->type) {
         $writer->writeAttribute('type', $this->type);
     }
     parent::writeXmlContents($writer);
     if ($this->date) {
         $writer->startElementNs('gx', 'date', null);
         $this->date->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->place) {
         $writer->startElementNs('gx', 'place', null);
         $this->place->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->roles) {
         foreach ($this->roles as $i => $x) {
             $writer->startElementNs('gx', 'role', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
示例#5
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());
 }