/** * @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()); }
/** * 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); }