You are here

public function UIFTestCaseRoles::testUIFImportWithRoles in User Import Framework 7

Test role import.

File

./uif.test, line 403
UIF test code.

Class

UIFTestCaseRoles
Test import with roles.

Code

public function testUIFImportWithRoles() {
  $cook_rid = $this
    ->drupalCreateRole(array(), 'cook');
  $bottlewasher_rid = $this
    ->drupalCreateRole(array(), 'bottlewasher');
  $this
    ->drupalLogin($this->import_user);
  $edit = array();
  $edit['files[user_upload]'] = DRUPAL_ROOT . '/' . drupal_get_path('module', 'uif') . '/test_data/test_3_roles.csv';
  $this
    ->drupalPost('admin/people/uif', $edit, t('Next'));
  $this
    ->assertText(t('Preview these records and when ready to import click Import users', array()));
  $this
    ->assertText(t('frodo@example.com', array()));
  $this
    ->assertText(t('(create)', array()));
  $this
    ->assertText(t('email', array()));
  $this
    ->assertText(t('roles', array()));
  $this
    ->drupalPost(NULL, array(), t('Import users'));
  $this
    ->assertText(t('User import complete', array()));

  // Retrieve imported user
  $mail = 'frodo@example.com';
  $account = user_load_by_mail($mail);
  $this
    ->userLoadAndCheckRoleAssigned($account, $cook_rid);
  $this
    ->userLoadAndCheckRoleAssigned($account, $bottlewasher_rid, FALSE);
  $mail = 'bilbo@example.com';
  $account = user_load_by_mail($mail);
  $this
    ->userLoadAndCheckRoleAssigned($account, $cook_rid);
  $this
    ->userLoadAndCheckRoleAssigned($account, $bottlewasher_rid);
  $mail = 'gandalf@example.com';
  $account = user_load_by_mail($mail);
  $this
    ->userLoadAndCheckRoleAssigned($account, $cook_rid, FALSE);
  $this
    ->userLoadAndCheckRoleAssigned($account, $bottlewasher_rid, FALSE);
}