You are here

protected function EntityShareServerFunctionalTest::checkEntitiesOnChannel in Entity Share 8.2

Same name and namespace in other branches
  1. 8.3 modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php \Drupal\Tests\entity_share_server\Functional\EntityShareServerFunctionalTest::checkEntitiesOnChannel()

Helper function to check the presence of entities on a specific channel.

Parameters

string $channel_id: The channel id on which to check the entities.

array $entity_uuids: The entity UUIDs to check for. Key is the entity UUID and the value is the expected status.

1 call to EntityShareServerFunctionalTest::checkEntitiesOnChannel()
EntityShareServerFunctionalTest::testFilteringAndSortingOnChannel in modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php
Test filters, groups of filters, and sorts.

File

modules/entity_share_server/tests/src/Functional/EntityShareServerFunctionalTest.php, line 759

Class

EntityShareServerFunctionalTest
General functional test class.

Namespace

Drupal\Tests\entity_share_server\Functional

Code

protected function checkEntitiesOnChannel($channel_id, array $entity_uuids) {
  $entity_share_entrypoint_url = Url::fromRoute('entity_share_server.resource_list');
  $response = $this
    ->request('GET', $entity_share_entrypoint_url, $this
    ->getAuthenticationRequestOptions($this->channelUser));
  $entity_share_endpoint_response = Json::decode((string) $response
    ->getBody());

  // Test that the node can be found on the channel URL.
  $response = $this
    ->request('GET', Url::fromUri($entity_share_endpoint_response['data']['channels'][$channel_id]['url']), $this
    ->getAuthenticationRequestOptions($this->channelUser));
  $channel_url_response = Json::decode((string) $response
    ->getBody());
  $channel_url_data = EntityShareUtility::prepareData($channel_url_response['data']);
  foreach ($entity_uuids as $entity_uuid => $expected) {
    $found = FALSE;
    foreach ($channel_url_data as $entity_data) {
      if ($entity_data['id'] == $entity_uuid) {
        $found = TRUE;
      }
    }
    $this
      ->assertEqual($found, $expected, 'Expected state for entity with UUID: ' . $entity_uuid);
  }
}