You are here

protected function AuthenticationTestBase::reimportChannel in Entity Share 8.3

Helper function: re-imports content from JSON:API.

Parameters

array $channel_infos: Channel infos as returned by entity_share_server entry point.

string|null $channel_id: The ID of channel.

2 calls to AuthenticationTestBase::reimportChannel()
AuthenticationBasicAuthTest::testImport in modules/entity_share_client/tests/src/Functional/AuthenticationBasicAuthTest.php
Test that correct entities are created with different authentications.
AuthenticationOAuthTest::testImport in modules/entity_share_client/tests/src/Functional/AuthenticationOAuthTest.php
Test that correct entities are created with different authentications.

File

modules/entity_share_client/tests/src/Functional/AuthenticationTestBase.php, line 148

Class

AuthenticationTestBase
Base class for functional tests of ES authorization plugins.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function reimportChannel(array $channel_infos, string $channel_id = NULL) {

  // Re-import data from JSON:API.
  // Get JSON data from the remote channel.
  if (empty($channel_id)) {
    $channel_id = static::$entityTypeId . '_' . static::$entityBundleId . '_' . static::$entityLangcode;
  }
  $channel_url = $channel_infos[$channel_id]['url'];
  $response = $this->remoteManager
    ->jsonApiRequest($this->remote, 'GET', $channel_url);
  $json = Json::decode((string) $response
    ->getBody());

  // Clean up the "server" content.
  $this
    ->deleteContent();
  $this->entities = [];

  // Launch the import.
  $import_context = new ImportContext($this->remote
    ->id(), $channel_id, $this::IMPORT_CONFIG_ID);
  $this->importService
    ->prepareImport($import_context);
  $this->importService
    ->importEntityListData(EntityShareUtility::prepareData($json['data']));
}