You are here

function UserImportProfile::checkProfileExist in User Import 5

Same name and namespace in other branches
  1. 8 tests/user_import_profile.test \UserImportProfile::checkProfileExist()

* Check data in CSV file matches data in profiles

1 call to UserImportProfile::checkProfileExist()
UserImportProfile::testCreateImport in tests/user_import_profile.test
* User with right permissions creates import (with new settings) * - test import of user data into Profile module

File

tests/user_import_profile.test, line 101

Class

UserImportProfile
Test import of user data into Profile module

Code

function checkProfileExist() {
  $file_path = drupal_get_path('module', 'user_import') . '/sample.txt';
  $handle = @fopen($file_path, "r");
  $row = 0;
  while ($csv = fgetcsv($handle, 1000, ',')) {
    if ($row > 0) {
      $user = user_load(array(
        'mail' => $csv[5],
      ));

      // test each data cell against Profile field content
      $this
        ->assertEqual($user->profile_first_name, $csv[0], "[Compare CSV data to Profile data] Row: {$row} Field: First Name");
      $this
        ->assertEqual($user->profile_last_name, $csv[1], "[Compare CSV data to Profile data] Row: {$row} Field: Last Name");
      $this
        ->assertEqual($user->profile_blog, $csv[6], "[Compare CSV data to Profile data] Row: {$row} Field: Blog");
      $this
        ->assertEqual($user->profile_contact_permission, $csv[7], "[Compare CSV data to Profile data] Row: {$row} Field: Contact Permission");
      $this
        ->assertEqual($user->profile_contact_preference, $csv[8], "[Compare CSV data to Profile data] Row: {$row} Field: Contact Preference");
      $this
        ->assertEqual($user->profile_interests, $csv[9], "[Compare CSV data to Profile data] Row: {$row} Field: Profile Interests");
      $this
        ->assertEqual($user->profile_cv, $csv[10], "[Compare CSV data to Profile data] Row: {$row} Field: CV");
      $this
        ->assertEqual($user->profile_birthday, $csv[11], "[Compare CSV data to Profile data] Row: {$row} Field: Birthday");

      //test interests link on profile page
      if (!empty($user->profile_interests)) {
        $interests = explode(',', $user->profile_interests);
        $this
          ->drupalGet('profile/profile_interests/' . $interests[0]);
        $this
          ->assertWantedRaw('<a title="View user profile." href="/' . url('user/' . $user->uid) . '">' . $user->name . '</a>', '[Freeform List] User is listed on page about item in list');
      }
    }
    $row++;
  }
}