You are here

public function UserImportUpdateExportTest::testUserDataImportExport in Acquia Content Hub 8.2

Tests User Data import/export.

@dataProvider userDataImportExportDataProvider

Parameters

int $delta: Fixture delta.

array $validate_data: Data.

string $export_type: Exported entity type.

string $export_uuid: Entity UUID.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Kernel/UserImportUpdateExportTest.php, line 132

Class

UserImportUpdateExportTest
Tests user export, update, and import.

Namespace

Drupal\Tests\acquia_contenthub\Kernel

Code

public function testUserDataImportExport($delta, array $validate_data, $export_type, $export_uuid) {
  parent::contentEntityImportExport($delta, $validate_data, $export_type, $export_uuid);

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $user = $this->entityRepository
    ->loadEntityByUuid('user', $validate_data[0]['uuid']);
  $expected_1 = [
    'enabled' => 1,
  ];
  $this
    ->assertEquals($expected_1, $this->userData
    ->get('contact', $user
    ->id()));
  $expected_2 = [
    'attribute1' => '0',
    'attribute2' => '1',
    'attribute3' => TRUE,
    'attribute4' => 345,
    'attribute5' => [
      1,
      3,
      4,
      6,
    ],
    'attribute6' => 'a string',
  ];
  $this
    ->assertEquals($expected_2, $this->userData
    ->get('test', $user
    ->id()));
}