Beispiel #1
0
 /**
  * @vcr OrdinanceTests/testReadOrdinancesForbidden.json
  * @link https://familysearch.org/developers/docs/api/ordinances/Read_Ordinances_%28Access_Forbidden%29_usecase
  */
 public function testReadOrdinancesForbidden()
 {
     $factory = new StateFactory();
     $collectionState = $factory->newCollectionState()->authenticateViaOAuth2Password('general_public_user', '1234pass', SandboxCredentials::API_KEY);
     $response = $collectionState->getClient()->get($this->ordinanceUri, ['headers' => ['Authorization' => "Bearer " . $collectionState->getAccessToken(), 'Accept' => Gedcomx::JSON_MEDIA_TYPE, 'Content-Type' => Gedcomx::JSON_MEDIA_TYPE]]);
     $this->assertEquals(HttpStatus::FORBIDDEN, $response->getStatusCode(), 'Error with invalid Ordinance test. Returned: ' . HttpStatus::getText($response->getStatusCode()) . "(" . $response->getStatusCode() . ")");
 }
 /**
  * Reads the contributor for the specified resource reference.
  *
  * @param \Gedcomx\Common\ResourceReference                $contributor
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return \Gedcomx\Rs\Client\AgentState|null
  */
 public function readReferenceContributor(ResourceReference $contributor, StateTransitionOption $option = null)
 {
     if ($contributor == null || $contributor->getResource() == null) {
         return null;
     }
     $request = $this->createAuthenticatedGedcomxRequest('GET', $contributor->getResource());
     return $this->stateFactory->createState('AgentState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
Beispiel #3
0
 /**
  * @vcr DiscoveryTests/testReadFamilySearchHistoricalRecordsArchive.json
  * @link https://familysearch.org/developers/docs/api/memories/Read_FamilySearch_Historical_Records_Archive_usecase
  */
 public function testReadFamilySearchHistoricalRecordsArchive()
 {
     $factory = new StateFactory();
     $collection = $factory->newDiscoveryState();
     $subsState = $collection->readSubcollections();
     $collections = $subsState->getCollections();
     $link = null;
     foreach ($collections as $record) {
         if ($record->getId() == "FSHRA") {
             $link = $record->getLink(Rel::SELF);
             break;
         }
     }
     $this->assertNotEmpty($link, 'Place Authority link not found');
     $dateState = $factory->newCollectionState($link->getHref());
     $this->assertEquals(HttpStatus::OK, $dateState->getStatus(), $this->buildFailMessage(__METHOD__ . "(Read place collection)", $dateState));
 }
 /**
  * @link https://familysearch.org/developers/docs/api/authentication/Obtain_Access_Token_without_Authenticating_usecase
  */
 public function testObtainAccessTokenWithoutAuthenticating()
 {
     $factory = new StateFactory();
     $collectionState = $factory->newCollectionState()->authenticateViaOAuth2WithoutCredentials('0.0.0.0', $this->clientId);
     $this->assertNotEmpty($collectionState->getAccessToken());
 }