/** * @vcr DiscoveryTests/testReadDateAuthority.json * @link https://familysearch.org/developers/docs/api/discussions/Read_Date_Authority_usecase */ public function testReadDateAuthority() { $factory = new FamilyTreeStateFactory(); $collection = $factory->newDiscoveryState(); $subsState = $collection->readSubcollections(); $this->assertNotNull($subsState); $collections = $subsState->getCollections(); $link = null; foreach ($collections as $record) { if ($record->getId() == "FSDA") { $link = $record->getLink(Rel::SELF); break; } } $this->assertNotEmpty($link, 'Date Authority link not found'); /** @var FamilySearchCollectionState $dateState */ $dateState = $factory->newCollectionState($link->getHref()); $this->assertEquals(HttpStatus::OK, $dateState->getStatus(), $this->buildFailMessage(__METHOD__ . "(Read date collection)", $dateState)); $normalized = $dateState->normalizeDate("26 Nov 1934"); $this->assertEquals('gedcomx-date:+1934-11-26', $normalized->getFormal(), "Formalized date format incorrect: " . $normalized->getFormal()); $extensions = $normalized->getNormalizedExtensions(); $this->assertEquals('26 November 1934', $extensions[0]->getValue(), "Normalized date format incorrect: " . $extensions[0]->getValue()); }
/** * @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(); }
/** * Ensure the treeState propery exists */ private function createTreeState() { $this->createHomeState(); $this->treeState = $this->stateFactory->newCollectionState($this->homeState->getCollection()->getLink('family-tree')->getHref(), 'GET', $this->client); }