Ejemplo n.º 1
0
 /**
  * @link https://familysearch.org/developers/docs/api/tree/Read_Person_With_Multiple_Pending_Modifications_Activated_usecase
  */
 public function testReadPersonWithMultiplePendingModificationsActivated()
 {
     $factory = new FamilyTreeStateFactory();
     $this->collectionState($factory);
     /** @var Feature[] $features */
     $features = array();
     $request = $this->collectionState()->getClient()->createRequest("GET", "https://sandbox.familysearch.org/platform/pending-modifications");
     $request->addHeader("Accept", Gedcomx::JSON_APPLICATION_TYPE);
     // Get all the features that are pending
     $response = $request->send($request);
     // Get each pending feature
     $json = json_decode($response->getBody(true), true);
     $fsp = new FamilySearchPlatform($json);
     foreach ($fsp->getFeatures() as $feature) {
         $features[] = $feature;
     }
     // Add every pending feature to the tree's current client
     $this->collectionState()->getClient()->addFilter(new ExperimentsFilter(array_map(function (Feature $feature) {
         return $feature->getName();
     }, $features)));
     $state = $this->createPerson();
     // Ensure a response came back
     $this->assertNotNull($state);
     $check = array();
     /** @var HeaderInterface $header */
     foreach ($state->getRequest()->getHeaders() as $header) {
         if ($header->getName() == "X-FS-Feature-Tag") {
             $check[] = $header;
         }
     }
     /** @var string $requestedFeatures */
     $requestedFeatures = join(",", $check);
     // Ensure each requested feature was found in the request headers
     foreach ($features as $feature) {
         $this->assertTrue(strpos($requestedFeatures, $feature->getName()) !== false, $feature->getName() . " was not found in the requested features.");
     }
 }
Ejemplo n.º 2
0
 /**
  * Get a list of valid pending modifications
  * 
  * @return array Array of \Gedcomx\Extensions\FamilySearch\Feature
  */
 public function getAvailablePendingModifications()
 {
     $uri = $this->homeState->getCollection()->getLink('pending-modifications')->getHref();
     $headers = ['Accept' => Gedcomx::JSON_APPLICATION_TYPE];
     $request = new Request('GET', $uri, $headers);
     $response = GedcomxApplicationState::send($this->client, $request);
     // Get each pending feature
     $json = json_decode($response->getBody(), true);
     $fsp = new FamilySearchPlatform($json);
     $features = array();
     foreach ($fsp->getFeatures() as $feature) {
         $features[] = $feature;
     }
     return $features;
 }