/** * @vcr GedcomxFileTests/testCreateGedxFile.json */ public function testCreateGedxFile() { $people = XMLBuilder::XMLRelationshipData(); $factory = new FamilyTreeStateFactory(); $this->collectionState($factory); $father = $this->collectionState()->addPerson($people['father']); $mother = $this->collectionState()->addPerson($people['mother']); $child = $this->collectionState()->addPerson($people['child']); $this->queueForDelete($father, $mother, $child); $family = new ChildAndParentsRelationship(); $family->setChild($child->getResourceReference()); $family->setFather($father->getResourceReference()); $family->setMother($mother->getResourceReference()); $relationship = $this->collectionState()->addChildAndParentsRelationship($family)->get(); $this->queueForDelete($relationship); $image1 = ArtifactBuilder::makeImage(); $image2 = ArtifactBuilder::makeImage(); $testfile = $this->tempDir . "test.gedx"; $writeIt = new GedcomxOutput(); $writeIt->addFamilySearchResource($relationship->getEntity()); $writeIt->addFileResource($image1); $writeIt->addFileResource($image2); $writeIt->writeToFile($testfile); $this->assertFileExists($testfile, "test.gedx not written."); $readIt = new GedcomxFile($testfile); $this->assertEmpty($readIt->getWarnings(), "No warnings should have been generated."); }
/** * @link https://familysearch.org/developers/docs/api/memories/Upload_Photo_Via_Multipart_Form_Data_usecase * SDK only supports uploading via multi-part form uploads. */ public function testUploadPhotoViaMultipartFormData() { $filename = ArtifactBuilder::makeImage(); $artifact = new DataSource(); $artifact->setFile($filename); $description = SourceBuilder::newSource(); $factory = new FamilySearchStateFactory(); /** @var FamilySearchMemories $memories */ $memories = $factory->newMemoriesState(); $memories = $this->authorize($memories); $this->assertNotEmpty($memories->getAccessToken()); $upload = $memories->addArtifact($artifact, $description); $this->queueForDelete($upload); $this->assertEquals(HttpStatus::CREATED, $upload->getStatus(), $this->buildFailMessage(__METHOD__, $upload)); $upload = $upload->get(); $this->assertEquals(HttpStatus::OK, $upload->getStatus()); }
/** * @link https://familysearch.org/developers/docs/api/tree/Read_Person_Portraits_usecase */ public function testReadPersonPortraits() { $this->markTestSkipped("Memories tests are slow and unreliable."); $factory = new FamilyTreeStateFactory(); $this->collectionState($factory); $memories = $factory->newMemoriesState(); $memories = $this->authorize($memories); $filename = ArtifactBuilder::makeImage(); $artifact = new DataSource(); $artifact->setFile($filename); /** @var FamilyTreePersonState $person */ $person = $this->createPerson(); $this->assertEquals(HttpStatus::CREATED, $person->getStatus()); $person = $person->get(); $this->assertEquals(HttpStatus::OK, $person->getStatus()); $description = $this->createSource()->get()->getSourceDescription(); /** @var \Gedcomx\Rs\Client\SourceDescriptionState $upload */ $upload = $memories->addArtifact($artifact, $description)->get(); $this->queueForDelete($upload); $persona = $upload->addPersonPersona(PersonBuilder::buildPerson('male'))->get(); $this->queueForDelete($persona); $person->addPersonaPersonState($persona); $portraits = $person->readPortraits(); $this->assertEquals(HttpStatus::OK, $portraits->getStatus(), $this->buildFailMessage(__METHOD__, $portraits)); $this->assertNotNull($portraits->getEntity()); $this->assertNotNull($portraits->getEntity()->getSourceDescriptions()); $this->assertGreaterThan(0, count($portraits->getEntity()->getSourceDescriptions())); }