You are here

function UserImportNodeprofileTestCase::nodeprofileConfiguration in User Import 6.4

Same name and namespace in other branches
  1. 6.2 user_import.test \UserImportNodeprofileTestCase::nodeprofileConfiguration()

Configure modules

1 call to UserImportNodeprofileTestCase::nodeprofileConfiguration()
UserImportNodeprofileTestCase::testCreateImport in ./user_import.test
User with right permissions creates import (with new settings)

File

./user_import.test, line 233

Class

UserImportNodeprofileTestCase
Test import of user data into Profile module

Code

function nodeprofileConfiguration() {

  // create Identity content type
  $edit = array(
    'name' => 'Identity',
    'type' => 'identity',
    'title_label' => 'Title',
    'body_label' => '',
    'node_options[promote]' => 0,
    'content_profile_use' => 1,
  );
  $this
    ->drupalPost('admin/content/types/add', $edit, t('Save content type'));

  // create First Name field
  $edit = array(
    '_add_new_field[label]' => 'First Name',
    '_add_new_field[field_name]' => 'first_name',
    '_add_new_field[type]' => 'text',
    '_add_new_field[widget_type]' => 'text_textfield',
  );
  $this
    ->drupalPost('admin/content/node-type/identity/fields', $edit, t('Save'));
  $edit = array(
    'required' => 1,
  );
  $this
    ->drupalPost('admin/content/node-type/identity/fields/field_first_name', $edit, t('Save field settings'));

  // create Last Name field
  $edit = array(
    '_add_new_field[label]' => 'Last Name',
    '_add_new_field[field_name]' => 'last_name',
    '_add_new_field[type]' => 'text',
    '_add_new_field[widget_type]' => 'text_textfield',
  );
  $this
    ->drupalPost('admin/content/node-type/identity/fields', $edit, t('Save'));
  $edit = array(
    'required' => 1,
  );
  $this
    ->drupalPost('admin/content/node-type/identity/fields/field_last_name', $edit, t('Save field settings'));

  // create Biography content type
  $edit = array(
    'name' => 'Biography',
    'type' => 'biography',
    'title_label' => 'Title',
    'body_label' => '',
    'node_options[promote]' => 0,
    'content_profile_use' => 1,
  );
  $this
    ->drupalPost('admin/content/types/add', $edit, t('Save content type'));

  // create CV field
  $edit = array(
    '_add_new_field[label]' => 'CV',
    '_add_new_field[field_name]' => 'cv',
    '_add_new_field[type]' => 'text',
    '_add_new_field[widget_type]' => 'text_textarea',
  );
  $this
    ->drupalPost('admin/content/node-type/biography/fields', $edit, t('Save'));
  $edit = array(
    'required' => 1,
    'rows' => 5,
  );
  $this
    ->drupalPost('admin/content/node-type/biography/fields/field_cv', $edit, t('Save field settings'));

  // create Blog field (URL)
  $edit = array(
    '_add_new_field[label]' => 'Blog',
    '_add_new_field[field_name]' => 'blog',
    '_add_new_field[type]' => 'link',
    '_add_new_field[widget_type]' => 'link',
  );
  $this
    ->drupalPost('admin/content/node-type/biography/fields', $edit, t('Save'));

  // create Birthday field (date)
  $edit = array(
    '_add_new_field[label]' => 'Birthday',
    '_add_new_field[field_name]' => 'birthday',
    '_add_new_field[type]' => 'datestamp',
    '_add_new_field[widget_type]' => 'date_text',
  );
  $this
    ->drupalPost('admin/content/node-type/biography/fields', $edit, t('Save'));

  // create Interests Vocabulary
  $edit = array(
    'name' => 'Interests',
    'nodes[biography]' => 'biography',
    'tags' => 1,
  );
  $this
    ->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, t('Save'));
  $vocabularies = taxonomy_get_vocabularies('biography');
  foreach ($vocabularies as $vocabulary) {
    $this->vocabulary_id = $vocabulary->vid;
  }

  // create Contact Details contact type
  $edit = array(
    'name' => 'Contact Details',
    'type' => 'contact_details',
    'title_label' => 'Title',
    'body_label' => '',
    'node_options[promote]' => 0,
    'content_profile_use' => 1,
  );
  $this
    ->drupalPost('admin/content/types/add', $edit, t('Save content type'));

  // create Can Be Contacted field
  $edit = array(
    '_add_new_field[label]' => 'Contact',
    '_add_new_field[field_name]' => 'can_be_contacted',
    '_add_new_field[type]' => 'number_integer',
    '_add_new_field[widget_type]' => 'optionwidgets_onoff',
  );
  $this
    ->drupalPost('admin/content/node-type/contact-details/fields', $edit, t('Save'));
  $edit = array(
    'allowed_values' => "0\n    1|Can be contacted",
  );
  $this
    ->drupalPost('admin/content/node-type/contact-details/fields/field_can_be_contacted', $edit, t('Save field settings'));

  // create Contact Preference field
  $edit = array(
    '_add_new_field[label]' => 'Contact Preference',
    '_add_new_field[field_name]' => 'contact_preference',
    '_add_new_field[type]' => 'text',
    '_add_new_field[widget_type]' => 'optionwidgets_select',
  );
  $this
    ->drupalPost('admin/content/node-type/contact-details/fields', $edit, t('Save'));
  $edit = array(
    'allowed_values' => 'email|email
    telephone|telephone
    post|post',
  );
  $this
    ->drupalPost('admin/content/node-type/contact-details/fields/field_contact_preference', $edit, t('Save field settings'));

  // set access perm for authenticated users to creade profile nodes
  $edit = array(
    '2[create identity content]' => 'create identity content',
    '2[create biography content]' => 'create biography content',
    '2[create contact_details content]' => 'create contact_details content',
  );
  $this
    ->drupalPost('admin/user/permissions', $edit, t('Save permissions'));
}