You are here

public function UIFTestCaseFieldFields::testUIFImportWithFieldOneField in User Import Framework 7

Test addition of one field.

File

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

Class

UIFTestCaseFieldFields
Test import with Field module fields.

Code

public function testUIFImportWithFieldOneField() {
  $this
    ->drupalLogin($this->admin_user);
  $edit = array();
  $edit['fields[_add_new_field][label]'] = 'First name';
  $edit['fields[_add_new_field][field_name]'] = 'first_name';
  $edit['fields[_add_new_field][type]'] = 'text';
  $edit['fields[_add_new_field][widget_type]'] = 'text_textfield';
  $this
    ->drupalPost('admin/config/people/accounts/fields', $edit, t('Save'));
  $this
    ->assertText(t('These settings apply to the @label field everywhere it is used.', array(
    '@label' => $edit['fields[_add_new_field][label]'],
  )));
  $this
    ->drupalGet('admin/config/people/accounts/display');
  $this
    ->assertText('No field is hidden');
  $this
    ->drupalLogin($this->import_user);
  $edit = array();
  $edit['files[user_upload]'] = DRUPAL_ROOT . '/' . drupal_get_path('module', 'uif') . '/test_data/test_fields_1.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('wilma@example.com', array()));
  $this
    ->assertText(t('(create)', array()));
  $this
    ->assertText(t('mail', array()));
  $this
    ->assertText(t('name', array()));
  $this
    ->assertText(t('pass', array()));
  $this
    ->assertText(t('first_name', array()));
  $this
    ->assertText(t('last_name', array()));
  $this
    ->drupalPost(NULL, array(), t('Import users'));
  $this
    ->assertText(t('User import complete', array()));
  $this
    ->assertNoText(t('Unknown column', array()));

  // Retrieve imported user
  field_cache_clear();
  $name = 'wilma';
  $account = user_load_by_name($name);
  $this
    ->assertTrue($account != NULL, t('User @name was loaded', array(
    '@name' => $name,
  )));
  $account->pass_raw = 'rubble';
  $this
    ->drupalLogin($account);
  $this
    ->assertText('First name');
  $this
    ->assertText('Wilma');
}