You are here

public function LinkFieldTest::testBasicPull in Entity Share 8.3

Same name and namespace in other branches
  1. 8.2 modules/entity_share_client/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\entity_share_client\Functional\LinkFieldTest::testBasicPull()

Test basic pull feature.

File

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

Class

LinkFieldTest
Functional test class for link field.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

public function testBasicPull() {
  $this
    ->pullEveryChannels();
  $this
    ->checkCreatedEntities();

  // Test link_internal_content_importer plugin.
  // Need to remove all imported content prior to that.
  $this
    ->resetImportedContent();

  // Import only one content.
  $selected_entities = [
    'es_test_link_internal',
  ];
  $this
    ->importSelectedEntities($selected_entities);

  // Check that only the imported content had been pulled.
  $linking_entity = $this
    ->loadEntity('node', 'es_test_link_internal');
  $this
    ->assertNotNull($linking_entity, 'The linking node has been created.');
  $linked_entity = $this
    ->loadEntity('node', 'es_test');
  $this
    ->assertNull($linked_entity, 'The linked node has not been created.');

  // Enable the plugin.
  $this
    ->mergePluginsToImportConfig([
    'link_internal_content_importer' => [
      'max_recursion_depth' => -1,
      'weights' => [
        'prepare_importable_entity_data' => 20,
      ],
    ],
  ]);
  $this
    ->resetImportedContent();

  // Import only one content.
  $selected_entities = [
    'es_test_link_internal',
  ];
  $this
    ->importSelectedEntities($selected_entities);

  // Check that both contents had been imported.
  $linking_entity = $this
    ->loadEntity('node', 'es_test_link_internal');
  $this
    ->assertNotNull($linking_entity, 'The linking node has been created.');
  $linked_entity = $this
    ->loadEntity('node', 'es_test');
  $this
    ->assertNotNull($linked_entity, 'The linked node has been created.');
}