You are here

protected function InfiniteLoopTest::infiniteLoopTestHelper in Entity Share 8.2

Same name and namespace in other branches
  1. 8.3 modules/entity_share_client/tests/src/Functional/InfiniteLoopTest.php \Drupal\Tests\entity_share_client\Functional\InfiniteLoopTest::infiniteLoopTestHelper()

Helper function.

Parameters

array $selected_entities: The selected entities to pull.

2 calls to InfiniteLoopTest::infiniteLoopTestHelper()
InfiniteLoopTest::testInfiniteLoopFromNodeOne in modules/entity_share_client/tests/src/Functional/InfiniteLoopTest.php
Test that a referenced entity is pulled even if not selected.
InfiniteLoopTest::testInfiniteLoopFromNodeTwo in modules/entity_share_client/tests/src/Functional/InfiniteLoopTest.php
Test that a referenced entity is pulled even if not selected.

File

modules/entity_share_client/tests/src/Functional/InfiniteLoopTest.php, line 145

Class

InfiniteLoopTest
Functional test class for content entity reference field.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function infiniteLoopTestHelper(array $selected_entities) {
  $prepared_url = $this
    ->prepareUrlFilteredOnUuids($selected_entities, 'node_es_test_en');
  $this->jsonapiHelper
    ->setRemote($this->remote);
  $http_client = $this->remoteManager
    ->prepareJsonApiClient($this->remote);
  $response = $this->requestService
    ->request($http_client, 'GET', $prepared_url);
  $json = Json::decode((string) $response
    ->getBody());
  $this->jsonapiHelper
    ->importEntityListData(EntityShareUtility::prepareData($json['data']));

  // Check that both entities had been created. If the process ends the
  // infinite loop has been avoided.
  $uuids = [
    'es_test_content_reference_one',
    'es_test_content_reference_two',
  ];
  foreach ($uuids as $uuid) {
    $node = $this
      ->loadEntity('node', $uuid);
    $this
      ->assertTrue($node instanceof NodeInterface, 'The node with the uuid ' . $uuid . ' has been recreated.');
  }
}