You are here

public function AuthenticationAnonymousTest::testImport in Entity Share 8.3

Test that correct entities are created with "Anonymous" authorization.

File

modules/entity_share_client/tests/src/Functional/AuthenticationAnonymousTest.php, line 99

Class

AuthenticationAnonymousTest
Functional test class for import with "Anonymous" authorization.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

public function testImport() {
  $this
    ->pullChannel('node_es_test_en');

  // Assertions.
  $entity_storage = $this->entityTypeManager
    ->getStorage('node');
  $published = $entity_storage
    ->loadByProperties([
    'uuid' => 'es_test_node_import_published',
  ]);
  $this
    ->assertEquals(count($published), 1, 'The published node was imported.');
  $not_published = $entity_storage
    ->loadByProperties([
    'uuid' => 'es_test_node_import_not_published',
  ]);
  $this
    ->assertEquals(count($not_published), 0, 'The unpublished node was not imported.');
  foreach (static::$filesData as $file_data) {
    $this
      ->assertTrue(file_exists($file_data['uri']), 'The private physical file ' . $file_data['filename'] . ' has been pulled and recreated.');
    $file_content = file_get_contents($file_data['uri']);
    $this
      ->assertEquals($file_content, $file_data['file_content'], 'Private physical file was downloaded with correct content.');
  }
}