protected function EntityShareClientFunctionalTestBase::getEntityJsonData in Entity Share 8.2
Same name and namespace in other branches
- 8.3 modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php \Drupal\Tests\entity_share_client\Functional\EntityShareClientFunctionalTestBase::getEntityJsonData()
Helper function to import all channels.
Parameters
string $channel_id: The channel ID.
string $entity_uuid: The entity UUID.
Return value
array An array of decoded data.
1 call to EntityShareClientFunctionalTestBase::getEntityJsonData()
- MultilingualTest::expectedState in modules/entity_share_client/ tests/ src/ Functional/ MultilingualTest.php 
- Helper function.
File
- modules/entity_share_client/ tests/ src/ Functional/ EntityShareClientFunctionalTestBase.php, line 575 
Class
- EntityShareClientFunctionalTestBase
- Base class for Entity share server functional tests.
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
protected function getEntityJsonData($channel_id, $entity_uuid) {
  $json_data = [];
  $channel_infos = $this->remoteManager
    ->getChannelsInfos($this->remote);
  $this->jsonapiHelper
    ->setRemote($this->remote);
  $http_client = $this->remoteManager
    ->prepareJsonApiClient($this->remote);
  $channel_url = $channel_infos[$channel_id]['url'];
  while ($channel_url) {
    $response = $this->requestService
      ->request($http_client, 'GET', $channel_url);
    $json = Json::decode((string) $response
      ->getBody());
    $json_data = EntityShareUtility::prepareData($json['data']);
    foreach ($json_data as $entity_json_data) {
      if ($entity_json_data['id'] == $entity_uuid) {
        return $entity_json_data;
      }
    }
    if (isset($json['links']['next']['href'])) {
      $channel_url = $json['links']['next']['href'];
    }
    else {
      $channel_url = FALSE;
    }
  }
  return $json_data;
}