You are here

public function ContentEntityTest::testUserSource in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testUserSource()
  2. 10 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityTest::testUserSource()

Tests user source plugin.

@dataProvider migrationConfigurationProvider

File

core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php, line 270

Class

ContentEntityTest
Tests the entity content source plugin.

Namespace

Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source

Code

public function testUserSource(array $configuration) {
  $migration = $this->migrationPluginManager
    ->createStubMigration($this
    ->migrationDefinition('content_entity:user', $configuration));
  $user_source = $migration
    ->getSourcePlugin();
  $this
    ->assertSame('users', $user_source
    ->__toString());
  if (!$configuration['include_translations']) {
    $this
      ->assertEquals(1, $user_source
      ->count());
  }
  $this
    ->assertIds($user_source, $configuration);
  $fields = $user_source
    ->fields();
  $this
    ->assertArrayHasKey('name', $fields);
  $this
    ->assertArrayHasKey('pass', $fields);
  $this
    ->assertArrayHasKey('mail', $fields);
  $this
    ->assertArrayHasKey('uid', $fields);
  $this
    ->assertArrayHasKey('roles', $fields);
  $user_source
    ->rewind();
  $values = $user_source
    ->current()
    ->getSource();
  $this
    ->assertEquals('example@example.com', $values['mail'][0]['value']);
  $this
    ->assertEquals('user123', $values['name'][0]['value']);
  $this
    ->assertEquals(1, $values['uid']);
  $this
    ->assertEquals(1, $values['field_entity_reference'][0]['target_id']);
}