diff --git a/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml b/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml
index 9fdf6d8..2a41073 100644
--- a/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml
+++ b/core/modules/migrate_drupal/config/schema/migrate_drupal.source.schema.yml
@@ -267,7 +267,7 @@ migrate.source.d6_user_picture_file:
           type: boolean
           label: 'Public'
 
-migrate.source.d6_user_picture_instance:
+migrate.source.user_picture_instance:
   type: migrate_source_sql
   label: 'Drupal 6 user picure display'
   mapping:
diff --git a/core/modules/migrate_drupal/src/Tests/Table/d7/Users.php b/core/modules/migrate_drupal/src/Tests/Table/d7/Users.php
index e14c767..03eb4aa 100644
--- a/core/modules/migrate_drupal/src/Tests/Table/d7/Users.php
+++ b/core/modules/migrate_drupal/src/Tests/Table/d7/Users.php
@@ -140,8 +140,25 @@ public function load() {
       'init',
       'data',
     ))
-    ->execute();
+    ->values(array(
+      'uid' => '2',
+      'name' => 'Odo',
+      'pass' => '$S$DwNxkEAljElEHziE84ou59zp1jaSRrRmYYOwjDMCL2u8yHLkwDtO',
+      'mail' => 'odo@local.host',
+      'theme' => '',
+      'signature' => '',
+      'signature_format' => 'filtered_html',
+      'created' => '1438027199',
+      'access' => '0',
+      'login' => '0',
+      'status' => '1',
+      'timezone' => 'America/Chicago',
+      'language' => '',
+      'picture' => '0',
+      'init' => 'odo@local.host',
+      'data' => 'a:1:{s:7:"contact";i:1;}',
+    ))->execute();
   }
 
 }
-#c4f52bf31f5fe27b4742639dea21039a
+#e5dcc4cf9125b32fffbabbe8b45498d8
diff --git a/core/modules/user/migration_templates/d7_user.yml b/core/modules/user/migration_templates/d7_user.yml
new file mode 100755
index 0000000..13c85bb
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user.yml
@@ -0,0 +1,34 @@
+id: d7_user
+migration_tags:
+  - Drupal 7
+source:
+  plugin: d7_user
+destination:
+  plugin: entity:user
+process:
+  uid: uid
+  name: name
+  pass: pass
+  mail: mail
+  status: status
+  created: created
+  changed: changed
+  access: access
+  login: login
+  timezone: timezone
+  langcode: language
+  preferred_langcode: language
+  preferred_admin_langcode: language
+  picture: picture
+  init: init
+  roles:
+    plugin: migration
+    migration: d7_user_role
+    source: roles
+migration_dependencies:
+  required:
+    - d7_user_role
+  optional:
+    # User pictures are references to file_managed, so if the d7_file migration
+    # (which migrates the entire file_managed table) exists, run it first.
+    - d7_file
diff --git a/core/modules/user/migration_templates/d7_user_flood.yml b/core/modules/user/migration_templates/d7_user_flood.yml
new file mode 100755
index 0000000..016acec
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_flood.yml
@@ -0,0 +1,20 @@
+id: d7_user_flood
+migration_tags:
+  - Drupal 7
+source:
+  plugin: variable
+  variables:
+    - user_failed_login_identifier_uid_only
+    - user_failed_login_ip_limit
+    - user_failed_login_ip_window
+    - user_failed_login_user_window
+    - user_failed_login_user_limit
+process:
+  uid_only: user_failed_login_identifier_uid_only
+  ip_limit: user_failed_login_ip_limit
+  ip_window: user_failed_login_ip_window
+  user_limit: user_failed_login_user_limit
+  user_window: user_failed_login_user_window
+destination:
+  plugin: config
+  config_name: user.flood
diff --git a/core/modules/user/migration_templates/d7_user_mail.yml b/core/modules/user/migration_templates/d7_user_mail.yml
new file mode 100644
index 0000000..246d57c
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_mail.yml
@@ -0,0 +1,39 @@
+id: d7_user_mail
+label: Drupal 7 user mail configuration
+migration_tags:
+  - Drupal 7
+source:
+  plugin: variable
+  variables:
+    - user_mail_status_activated_subject
+    - user_mail_status_activated_body
+    - user_mail_password_reset_subject
+    - user_mail_password_reset_body
+    - user_mail_status_deleted_subject
+    - user_mail_status_deleted_body
+    - user_mail_register_admin_created_subject
+    - user_mail_register_admin_created_body
+    - user_mail_register_no_approval_required_subject
+    - user_mail_register_no_approval_required_body
+    - user_mail_user_mail_register_pending_approval_subject
+    - user_mail_user_mail_register_pending_approval_body
+    - user_mail_status_blocked_subject
+    - user_mail_status_blocked_body
+process:
+  'status_activated/subject': user_mail_status_activated_subject
+  'status_activated/body': user_mail_status_activated_body
+  'password_reset/subject': user_mail_password_reset_subject
+  'password_reset/body': user_mail_password_reset_body
+  'cancel_confirm/subject': user_mail_status_deleted_subject
+  'cancel_confirm/body': user_mail_status_deleted_body
+  'register_admin_created/subject': user_mail_register_admin_created_subject
+  'register_admin_created/body': user_mail_register_admin_created_body
+  'register_no_approval_required/subject': user_mail_register_no_approval_required_subject
+  'register_no_approval_required/body': user_mail_register_no_approval_required_body
+  'register_pending_approval/subject': user_mail_user_mail_register_pending_approval_subject
+  'register_pending_approval/body': user_mail_user_mail_register_pending_approval_body
+  'status_blocked/subject': user_mail_status_blocked_subject
+  'status_blocked/body': user_mail_status_blocked_body
+destination:
+  plugin: config
+  config_name: user.mail
diff --git a/core/modules/user/migration_templates/d7_user_picture_entity_display.yml b/core/modules/user/migration_templates/d7_user_picture_entity_display.yml
new file mode 100755
index 0000000..7fe8bf9
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_picture_entity_display.yml
@@ -0,0 +1,27 @@
+id: d7_user_picture_entity_display
+label: Drupal 7 user picture display configuration
+migration_tags:
+  - Drupal 7
+source:
+  plugin: user_picture_instance
+  constants:
+    entity_type: user
+    bundle: user
+    view_mode: default
+    name: user_picture
+    type: image
+    options:
+      label: hidden
+      settings:
+        image_style: ''
+        image_link: content
+process:
+  entity_type: 'constants/entity_type'
+  bundle: 'constants/bundle'
+  view_mode: 'constants/view_mode'
+  field_name: 'constants/name'
+  type: 'constants/type'
+  options: 'constants/options'
+  'options/type': @type
+destination:
+  plugin: component_entity_display
diff --git a/core/modules/user/migration_templates/d7_user_picture_entity_form_display.yml b/core/modules/user/migration_templates/d7_user_picture_entity_form_display.yml
new file mode 100755
index 0000000..1cf89be
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_picture_entity_form_display.yml
@@ -0,0 +1,29 @@
+id: d7_user_picture_entity_form_display
+label: Drupal 7 user picture form display configuration
+migration_tags:
+  - Drupal 7
+source:
+  plugin: user_picture_instance
+  constants:
+    entity_type: user
+    bundle: user
+    form_mode: default
+    name: user_picture
+    type: image_image
+    options:
+      settings:
+        progress_indicator: throbber
+        preview_image_style: thumbnail
+process:
+  entity_type: 'constants/entity_type'
+  bundle: 'constants/bundle'
+  field_name: 'constants/name'
+  form_mode: 'constants/form_mode'
+  type: 'constants/type'
+  options: 'constants/options'
+  'options/type': @type
+destination:
+  plugin: component_entity_form_display
+migration_dependencies:
+  required:
+    - d7_user_picture_field_instance
diff --git a/core/modules/user/migration_templates/d7_user_picture_field.yml b/core/modules/user/migration_templates/d7_user_picture_field.yml
new file mode 100755
index 0000000..f9060d1
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_picture_field.yml
@@ -0,0 +1,20 @@
+id: d7_user_picture_field
+label: Drupal 7 user picture field configuration
+migration_tags:
+  - Drupal 7
+source:
+  # We do an empty source and a proper destination to have an idmap for
+  # dependencies.
+  plugin: empty
+  constants:
+    entity_type: user
+    type: image
+    name: user_picture
+    cardinality: 1
+process:
+  entity_type: 'constants/entity_type'
+  field_name: 'constants/name'
+  type: 'constants/type'
+  cardinality: 'constants/cardinality'
+destination:
+  plugin: entity:field_storage_config
diff --git a/core/modules/user/migration_templates/d7_user_picture_field_instance.yml b/core/modules/user/migration_templates/d7_user_picture_field_instance.yml
new file mode 100755
index 0000000..2d3927e
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_picture_field_instance.yml
@@ -0,0 +1,30 @@
+id: d7_user_picture_field_instance
+label: Drupal 7 user picture field instance configuration
+migration_tags:
+  - Drupal 7
+source:
+  plugin: user_picture_instance
+  constants:
+    entity_type: user
+    bundle: user
+    name: user_picture
+    settings:
+      file_extensions: 'png gif jpg jpeg'
+      alt_field: false
+      title_field: false
+      min_resolution: ''
+      alt_field_required: false
+      title_field_required: false
+process:
+  entity_type: 'constants/entity_type'
+  bundle: 'constants/bundle'
+  field_name: 'constants/name'
+  settings: 'constants/settings'
+  'settings/file_directory': file_directory
+  'settings/max_filesize': max_filesize
+  'settings/max_resolution': max_resolution
+destination:
+  plugin: entity:field_config
+migration_dependencies:
+  required:
+    - d7_user_picture_field
diff --git a/core/modules/user/migration_templates/d7_user_role.yml b/core/modules/user/migration_templates/d7_user_role.yml
new file mode 100755
index 0000000..0209b6a
--- /dev/null
+++ b/core/modules/user/migration_templates/d7_user_role.yml
@@ -0,0 +1,43 @@
+id: d7_user_role
+label: Drupal 7 user roles
+migration_tags:
+  - Drupal 7
+source:
+  plugin: d7_user_role
+process:
+  id:
+    -
+      plugin: machine_name
+      source: name
+    -
+      plugin: dedupe_entity
+      entity_type: user_role
+      field: id
+      length: 32
+  label: name
+  permissions:
+    -
+      plugin: static_map
+      source: permissions
+      bypass: true
+      map:
+        'use PHP for block visibility': 'use PHP for settings'
+        'administer site-wide contact form': 'administer contact forms'
+        'post comments without approval': 'skip comment approval'
+        'edit own blog entries' : 'edit own blog content'
+        'edit any blog entry' : 'edit any blog content'
+        'delete own blog entries' : 'delete own blog content'
+        'delete any blog entry' : 'delete any blog content'
+        'create forum topics' : 'create forum content'
+        'delete any forum topic' : 'delete any forum content'
+        'delete own forum topics' : 'delete own forum content'
+        'edit any forum topic' : 'edit any forum content'
+        'edit own forum topics' : 'edit own forum content'
+    # - plugin: system_update_7000
+    # - plugin: node_update_7008
+    - plugin: flatten
+destination:
+  plugin: entity:user_role
+migration_dependencies:
+  optional:
+    - d7_filter_format
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/UserPictureInstance.php b/core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
similarity index 83%
rename from core/modules/migrate_drupal/src/Plugin/migrate/source/d6/UserPictureInstance.php
rename to core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
index 667a551..9404099 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/UserPictureInstance.php
+++ b/core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
@@ -2,20 +2,20 @@
 
 /**
  * @file
- * Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPictureInstance.
+ * Contains \Drupal\user\Plugin\migrate\source\UserPictureInstance.
  */
 
-namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
+namespace Drupal\user\Plugin\migrate\source;
 
 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
 
 /**
- * Drupal 6 user picture field instance source.
+ * User picture field instance source.
  *
  * @todo Support default picture?
  *
  * @MigrateSource(
- *   id = "d6_user_picture_instance"
+ *   id = "user_picture_instance"
  * )
  */
 class UserPictureInstance extends DrupalSqlBase {
diff --git a/core/modules/user/src/Plugin/migrate/source/d7/Role.php b/core/modules/user/src/Plugin/migrate/source/d7/Role.php
new file mode 100755
index 0000000..8e290a3
--- /dev/null
+++ b/core/modules/user/src/Plugin/migrate/source/d7/Role.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Plugin\migrate\source\d7\Role.
+ */
+
+namespace Drupal\user\Plugin\migrate\source\d7;
+
+use Drupal\migrate\Row;
+use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
+
+/**
+ * Drupal 7 role source from database.
+ *
+ * @MigrateSource(
+ *   id = "d7_user_role"
+ * )
+ */
+class Role extends DrupalSqlBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function query() {
+    return $this->select('role', 'r')
+      ->fields('r', array('rid', 'name'));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function fields() {
+    return array(
+      'rid' => $this->t('Role ID.'),
+      'name' => $this->t('The name of the user role.'),
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function prepareRow(Row $row) {
+    $permissions = $this->select('role_permission', 'rp')
+      ->fields('rp', ['permission'])
+      ->condition('rid', $row->getSourceProperty('rid'))
+      ->execute()
+      ->fetchCol();
+    $row->setSourceProperty('permissions', $permissions);
+
+    return parent::prepareRow($row);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getIds() {
+    return ['rid' => ['type' => 'integer']];
+  }
+
+}
diff --git a/core/modules/user/src/Plugin/migrate/source/d7/User.php b/core/modules/user/src/Plugin/migrate/source/d7/User.php
new file mode 100755
index 0000000..c2de8fe
--- /dev/null
+++ b/core/modules/user/src/Plugin/migrate/source/d7/User.php
@@ -0,0 +1,91 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Plugin\migrate\source\d7\User.
+ */
+
+namespace Drupal\user\Plugin\migrate\source\d7;
+
+use Drupal\migrate\Plugin\SourceEntityInterface;
+use Drupal\migrate\Row;
+use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
+
+/**
+ * Extract users from Drupal 7 database.
+ *
+ * @MigrateSource(
+ *   id = "d7_user"
+ * )
+ */
+class User extends DrupalSqlBase implements SourceEntityInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function query() {
+    return $this->select('users', 'u')
+      ->fields('u', array_keys($this->fields()))
+      ->condition('uid', 0, '>');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function prepareRow(Row $row) {
+    $roles = $this->select('role', 'r')
+      ->fields('r', ['rid', 'name']);
+    $roles->join('users_roles', 'ur', 'ur.rid = r.rid');
+    $roles->condition('ur.uid', $row->getSourceProperty('uid'));
+    $row->setSourceProperty('roles', $roles->execute()->fetchAllKeyed());
+  }
+
+  /**
+  * {@inheritdoc}
+  */
+  public function fields() {
+    return array(
+      'uid' => $this->t('User ID'),
+      'name' => $this->t('Username'),
+      'pass' => $this->t('Password'),
+      'mail' => $this->t('Email address'),
+      'signature' => $this->t('Signature'),
+      'signature_format' => $this->t('Signature format'),
+      'created' => $this->t('Registered timestamp'),
+      'access' => $this->t('Last access timestamp'),
+      'login' => $this->t('Last login timestamp'),
+      'status' => $this->t('Status'),
+      'timezone' => $this->t('Timezone'),
+      'language' => $this->t('Language'),
+      'picture' => $this->t('Picture'),
+      'init' => $this->t('Init'),
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getIds() {
+    return array(
+      'uid' => array(
+        'type' => 'integer',
+        'alias' => 'u',
+      ),
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function bundleMigrationRequired() {
+    return FALSE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function entityTypeId() {
+    return 'user';
+  }
+
+}
\ No newline at end of file
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php
new file mode 100644
index 0000000..613b3b6
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserFloodTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * Migrates user flood control configuration.
+ *
+ * @group user
+ */
+class MigrateUserFloodTest extends MigrateDrupal7TestBase {
+
+  /**
+   * The modules to be enabled during the test.
+   *
+   * @var array
+   */
+  static $modules = array('system');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(['user']);
+    $this->loadDumps(['Variable.php']);
+    $this->executeMigration('d7_user_flood');
+  }
+
+  /**
+   * Tests the migration.
+   */
+  public function testMigration() {
+    $expected = [
+      'uid_only' => TRUE,
+      'ip_limit' => 30,
+      'ip_window' => 7200,
+      'user_limit' => 22,
+      'user_window' => 86400,
+    ];
+    $this->assertIdentical($expected, \Drupal::config('user.flood')->get());
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserMailTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserMailTest.php
new file mode 100644
index 0000000..1617046
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserMailTest.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserMailTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * Migrates user mail configuration.
+ *
+ * @group user
+ */
+class MigrateUserMailTest extends MigrateDrupal7TestBase {
+
+  /**
+   * The modules to be enabled during the test.
+   *
+   * @var array
+   */
+  static $modules = ['system', 'user'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(['user']);
+    $this->loadDumps(['Variable.php']);
+    $this->executeMigration('d7_user_mail');
+  }
+
+  /**
+   * Tests the migration.
+   */
+  public function testMigration() {
+    $config = \Drupal::config('user.mail');
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureEntityDisplayTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureEntityDisplayTest.php
new file mode 100644
index 0000000..55a8a62
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureEntityDisplayTest.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserPictureEntityDisplayTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * User picture entity display.
+ *
+ * @group user
+ */
+class MigrateUserPictureEntityDisplayTest extends MigrateDrupal7TestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  static $modules = array('image');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $id_mappings = array(
+      'd7_user_picture_field_instance' => array(
+        array(array(1), array('user', 'user', 'user_picture')),
+      ),
+    );
+    $this->prepareMigrations($id_mappings);
+    $this->executeMigration('d7_user_picture_entity_display');
+  }
+
+  /**
+   * Tests the Drupal 7 user picture to Drupal 8 entity display migration.
+   */
+  public function testUserPictureEntityDisplay() {
+    $component = entity_get_display('user', 'user', 'default')->getComponent('user_picture');
+    $this->assertIdentical('image', $component['type']);
+    $this->assertIdentical('', $component['settings']['image_style']);
+    $this->assertIdentical('content', $component['settings']['image_link']);
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureEntityFormDisplayTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureEntityFormDisplayTest.php
new file mode 100644
index 0000000..d758426
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureEntityFormDisplayTest.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserPictureEntityFormDisplayTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * Tests migration of the user_picture field's entity form display settings.
+ *
+ * @group user
+ */
+class MigrateUserPictureEntityFormDisplayTest extends MigrateDrupal7TestBase {
+
+  static $modules = array('image', 'file');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->executeMigration('d7_user_picture_field');
+    $this->executeMigration('d7_user_picture_field_instance');
+    $this->executeMigration('d7_user_picture_entity_form_display');
+  }
+
+  /**
+   * Tests the field's entity form display settings.
+   */
+  public function testEntityFormDisplaySettings() {
+    $component = entity_get_form_display('user', 'user', 'default')->getComponent('user_picture');
+    $this->assertIdentical('image_image', $component['type']);
+    $this->assertIdentical('throbber', $component['settings']['progress_indicator']);
+    $this->assertIdentical('thumbnail', $component['settings']['preview_image_style']);
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureFieldInstanceTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureFieldInstanceTest.php
new file mode 100644
index 0000000..f09b6c3
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureFieldInstanceTest.php
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserPictureFieldInstanceTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\Core\Field\FieldConfigInterface;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * User picture field instance migration.
+ *
+ * @group user
+ */
+class MigrateUserPictureFieldInstanceTest extends MigrateDrupal7TestBase {
+
+  static $modules = array('image', 'file');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->executeMigration('d7_user_picture_field');
+    $this->executeMigration('d7_user_picture_field_instance');
+  }
+
+  /**
+   * Test the user picture field migration.
+   */
+  public function testUserPictureField() {
+    /** @var \Drupal\field\FieldConfigInterface $field */
+    $field = FieldConfig::load('user.user.user_picture');
+    $this->assertTrue($field instanceof FieldConfigInterface);
+    $this->assertIdentical('user', $field->getTargetEntityTypeId());
+    $this->assertIdentical('user', $field->getTargetBundle());
+    $this->assertIdentical('user_picture', $field->getName());
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureFieldTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureFieldTest.php
new file mode 100644
index 0000000..4d374ec
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserPictureFieldTest.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserPictureFieldTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\field\FieldStorageConfigInterface;
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * User picture field migration.
+ *
+ * @group user
+ */
+class MigrateUserPictureFieldTest extends MigrateDrupal7TestBase {
+
+  static $modules = array('image', 'file');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->executeMigration('d7_user_picture_field');
+  }
+
+  /**
+   * Test the user picture field migration.
+   */
+  public function testUserPictureField() {
+    /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
+    $field_storage = FieldStorageConfig::load('user.user_picture');
+    $this->assertTrue($field_storage instanceof FieldStorageConfigInterface);
+    $this->assertIdentical('user.user_picture', $field_storage->id());
+    $this->assertIdentical('image', $field_storage->getType());
+    $this->assertIdentical('user', $field_storage->getTargetEntityTypeId());
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserRoleTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserRoleTest.php
new file mode 100644
index 0000000..1043cd9
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserRoleTest.php
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserRoleTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\Core\Database\Database;
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+use Drupal\user\Entity\Role;
+use Drupal\user\RoleInterface;
+
+/**
+ * Upgrade user roles to user.role.*.yml.
+ *
+ * @group user
+ */
+class MigrateUserRoleTest extends MigrateDrupal7TestBase {
+
+  /**
+   * The modules to be enabled during the test.
+   *
+   * @var array
+   */
+  static $modules = array('user');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->loadDumps(['Role.php', 'RolePermission.php', 'Variable.php']);
+    $this->executeMigration('d7_user_role');
+  }
+
+  protected function assertEntity($id, $label, $original_rid = NULL) {
+    /** @var \Drupal\user\RoleInterface $entity */
+    $entity = Role::load($id);
+    $this->assertTrue($entity instanceof RoleInterface);
+    $this->assertIdentical($label, $entity->label());
+    if (isset($original_rid)) {
+      $permissions = Database::getConnection('default', 'migrate')
+        ->select('role_permission', 'rp')
+        ->fields('rp', ['permission'])
+        ->condition('rid', $original_rid)
+        ->execute()
+        ->fetchCol();
+      $this->assertIdentical($permissions, $entity->getPermissions());
+    }
+  }
+
+  /**
+   * Tests user role migration.
+   */
+  public function testUserRole() {
+    $this->assertEntity('anonymous_user', 'anonymous user', 1);
+    $this->assertEntity('authenticated_user', 'authenticated user', 2);
+    $this->assertEntity('administrator', 'administrator', 3);
+  }
+
+}
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserTest.php
new file mode 100644
index 0000000..9b7a944
--- /dev/null
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserTest.php
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Migrate\d7\MigrateUserTest.
+ */
+
+namespace Drupal\user\Tests\Migrate\d7;
+
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+use Drupal\user\Entity\User;
+use Drupal\user\RoleInterface;
+use Drupal\user\UserInterface;
+
+/**
+ * Users migration.
+ *
+ * @group user
+ */
+class MigrateUserTest extends MigrateDrupal7TestBase {
+
+  /**
+   * The modules to be enabled during the test.
+   *
+   * @var array
+   */
+  static $modules = array('user');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->loadDumps([
+      'Role.php',
+      'RolePermission.php',
+      'Users.php',
+      'UsersRoles.php',
+    ]);
+    $this->executeMigration('d7_user_role');
+    $this->executeMigration('d7_user');
+  }
+
+  protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $langcode, $init, array $roles = [RoleInterface::AUTHENTICATED_ID]) {
+    /** @var \Drupal\user\UserInterface $user */
+    $user = User::load($id);
+    $this->assertTrue($user instanceof UserInterface);
+    $this->assertIdentical($label, $user->label());
+    $this->assertIdentical($mail, $user->getEmail());
+    $this->assertIdentical($access, $user->getLastAccessedTime());
+    $this->assertIdentical($login, $user->getLastLoginTime());
+    $this->assertIdentical($blocked, $user->isBlocked());
+    // $user->getPreferredLangcode() might fallback to default language if the
+    // user preferred language is not configured on the site. We just want to
+    // test if the value was imported correctly.
+    $this->assertIdentical($langcode, $user->langcode->value);
+    $this->assertIdentical($langcode, $user->preferred_langcode->value);
+    $this->assertIdentical($langcode, $user->preferred_admin_langcode->value);
+    $this->assertIdentical($init, $user->getInitialEmail());
+    $this->assertIdentical($roles, $user->getRoles());
+  }
+
+  /**
+   * Tests the Drupal 7 user to Drupal 8 migration.
+   */
+  public function testUser() {
+    $this->assertEntity(2, 'Odo', 'odo@local.host', '0', '0', FALSE, '', 'odo@local.host');
+  }
+
+}
diff --git a/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/RoleTest.php b/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/RoleTest.php
new file mode 100644
index 0000000..66fc8ef
--- /dev/null
+++ b/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/RoleTest.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\user\Unit\Plugin\migrate\source\d7\RoleTest.
+ */
+
+namespace Drupal\Tests\user\Unit\Plugin\migrate\source\d7;
+
+use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
+
+/**
+ * Tests D7 role source plugin.
+ *
+ * @group user
+ */
+class RoleTest extends MigrateSqlSourceTestCase {
+
+  // The plugin system is not working during unit testing so the source plugin
+  // class needs to be manually specified.
+  const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d7\Role';
+
+  // The fake Migration configuration entity.
+  protected $migrationConfiguration = array(
+    // The ID of the entity, can be any string.
+    'id' => 'test',
+    // Leave it empty for now.
+    'idlist' => array(),
+    // This needs to be the identifier of the actual key: cid for comment, nid
+    // for node and so on.
+    'source' => array(
+      'plugin' => 'd7_user_role',
+    ),
+  );
+
+  protected $expectedResults = array(
+    array(
+      'rid' => 1,
+      'name' => 'anonymous user',
+      'permissions' => array(
+        'access content',
+      ),
+    ),
+    array(
+      'rid' => 2,
+      'name' => 'authenticated user',
+      'permissions' => array(
+        'access comments',
+        'access content',
+        'post comments',
+        'post comments without approval',
+      ),
+    ),
+    array(
+      'rid' => 3,
+      'name' => 'administrator',
+      'permissions' => array(
+        'access comments',
+        'administer comments',
+        'post comments',
+        'post comments without approval',
+        'access content',
+        'administer content types',
+        'administer nodes',
+      ),
+    ),
+  );
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    foreach ($this->expectedResults as $row) {
+      foreach ($row['permissions'] as $permission) {
+        $this->databaseContents['role_permission'][] = array(
+          'permission' => $permission,
+          'rid' => $row['rid'],
+        );
+      }
+      unset($row['permissions']);
+      $this->databaseContents['role'][] = $row;
+    }
+    parent::setUp();
+  }
+
+}
diff --git a/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/UserTest.php b/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/UserTest.php
new file mode 100644
index 0000000..135de5e
--- /dev/null
+++ b/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/UserTest.php
@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\user\Unit\Plugin\migrate\source\d7\UserTest.
+ */
+
+namespace Drupal\Tests\user\Unit\Plugin\migrate\source\d7;
+
+use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
+
+/**
+ * Tests D7 user source plugin.
+ *
+ * @group user
+ */
+class UserTest extends MigrateSqlSourceTestCase {
+
+  const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d7\User';
+
+  protected $migrationConfiguration = [
+    'id' => 'test',
+    'idlist' => [],
+    'source' => [
+      'plugin' => 'd7_user',
+    ],
+  ];
+
+  protected $expectedResults = [
+    [
+      'uid' => '2',
+      'name' => 'Odo',
+      'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8',
+      'mail' => 'odo@local.host',
+      'signature' => '',
+      'signature_format' => 'filtered_html',
+      'created' => '1432750741',
+      'access' => '0',
+      'login' => '0',
+      'status' => '1',
+      'timezone' => 'America/Chicago',
+      'language' => '',
+      'picture' => '0',
+      'init' => 'odo@local.host',
+      'roles' => [
+        2 => 'authenticated user',
+      ],
+    ],
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    $this->databaseContents['users'][] = [
+      'uid' => '2',
+      'name' => 'Odo',
+      'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8',
+      'mail' => 'odo@local.host',
+      'theme' => '',
+      'signature' => '',
+      'signature_format' => 'filtered_html',
+      'created' => '1432750741',
+      'access' => '0',
+      'login' => '0',
+      'status' => '1',
+      'timezone' => 'America/Chicago',
+      'language' => '',
+      'picture' => '0',
+      'init' => 'odo@local.host',
+      'data' => 'a:1:{s:7:"contact";i:1;}',
+    ];
+    $this->databaseContents['users_roles'][] = [
+      'uid' => 2,
+      'rid' => 2,
+    ];
+    $this->databaseContents['role'][] = [
+      'rid' => 2,
+      'name' => 'authenticated user',
+      'weight' => 0,
+    ];
+    parent::setUp();
+  }
+
+}
