Beispiel #1
0
 /**
  * @link https://familysearch.org/developers/docs/api/places/Search_For_Places_Under_a_Jurisdiction_usecase
  */
 public function testSearchForPlacesUnderAJurisdiction()
 {
     $factory = new FamilySearchStateFactory();
     //  First do a broad search
     $query = new GedcomxPlaceSearchQueryBuilder();
     $query->name("Paris");
     /** @var \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaces $collection */
     $collection = $factory->newPlacesState()->authenticateViaOAuth2Password(SandboxCredentials::USERNAME, SandboxCredentials::PASSWORD, SandboxCredentials::API_KEY);
     $generalResults = $collection->searchForPlaces($query);
     $this->assertEquals(HttpStatus::OK, $generalResults->getResponse()->getStatusCode());
     $this->assertNotNull($generalResults->getEntity(), "General search entity is null.");
     $this->assertNotEmpty($generalResults->getResults());
     //  Now narrow the search. Note the second parameter is the difference between this test
     //  and testSearchForPlacesDirectlyUnderAJurisdiction.
     $query->parentId('329', false, true);
     /** @var \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaces $collection */
     $collection = $factory->newPlacesState()->authenticateViaOAuth2Password(SandboxCredentials::USERNAME, SandboxCredentials::PASSWORD, SandboxCredentials::API_KEY);
     $specificResults = $collection->searchForPlaces($query);
     $this->assertEquals(HttpStatus::OK, $specificResults->getResponse()->getStatusCode());
     $this->assertNotNull($specificResults->getEntity(), "Specific entity is null.");
     $this->assertNotEmpty($specificResults->getResults());
     //  And assert we have fewer results
     $this->assertLessThan(count($generalResults->getResults()), count($specificResults->getResults()), "Specific result count not less than general result count.");
 }
Beispiel #2
0
 /**
  * @vcr PlacesTests/testSearchForPlaces.json
  * @link https://familysearch.org/developers/docs/api/places/Search_For_Places_usecase
  */
 public function testSearchForPlaces()
 {
     $query = new GedcomxPlaceSearchQueryBuilder();
     $query->name("Paris");
     $factory = new FamilySearchStateFactory();
     /** @var \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaces $collection */
     $collection = $factory->newPlacesState()->authenticateViaOAuth2Password(SandboxCredentials::USERNAME, SandboxCredentials::PASSWORD, SandboxCredentials::API_KEY);
     // Only ask for 5 results so that we don't record a ton of data
     $response = $collection->searchForPlaces($query, QueryParameter::count(5));
     $this->assertEquals(HttpStatus::OK, $response->getStatus());
     $this->assertNotNull($response->getEntity(), "Search results entity is null.");
     /** @var \Gedcomx\Atom\Entry[] $results */
     $results = $response->getResults();
     $this->assertNotEmpty($results, "Search should have returned results.");
     /** @var \Gedcomx\Gedcomx $gx */
     $gx = $results[0]->getContent()->getGedcomx();
     $this->assertNotEmpty($gx->getPlaces(), "Places information missing.");
 }