function UserImportNodeprofileTestCase::checkNodeprofileExist in User Import 6.2
Same name and namespace in other branches
- 6.4 user_import.test \UserImportNodeprofileTestCase::checkNodeprofileExist()
Check data in CSV file matches data in profiles
1 call to UserImportNodeprofileTestCase::checkNodeprofileExist()
- UserImportNodeprofileTestCase::testCreateImport in ./
user_import.test - User with right permissions creates import (with new settings)
File
- ./
user_import.test, line 326
Class
- UserImportNodeprofileTestCase
- Test import of user data into Profile module
Code
function checkNodeprofileExist() {
$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 nodeprofile field content
$identity = node_load(array(
'type' => 'identity',
'uid' => $user->uid,
), NULL, TRUE);
$this
->drupalGet("node/{$identity->nid}");
$this
->assertText(check_plain($csv[0]), "[Compare CSV and Profile data] Row: {$row} Field: First Name");
$this
->assertText(check_plain($csv[1]), "[Compare CSV and Profile data] Row: {$row} Field: Last Name " . $csv[1]);
$biography = node_load(array(
'type' => 'biography',
'uid' => $user->uid,
), NULL, TRUE);
$this
->drupalGet("node/{$biography->nid}");
$this
->assertText($csv[6], "[Compare CSV and Profile data] Row: {$row} Field: Blog");
$this
->assertText($csv[10], "[Compare CSV and Profile data] Row: {$row} Field: CV");
$birthday = format_date(strtotime($csv[11]), 'custom', 'D, j/m/Y');
$this
->assertText($birthday, "[Compare CSV and Profile data] Row: {$row} Field: Birthday " . $birthday);
$contact_details = node_load(array(
'type' => 'contact_details',
'uid' => $user->uid,
), NULL, TRUE);
$this
->drupalGet("node/{$contact_details->nid}");
if (isset($csv[7]) && !empty($csv[7])) {
$this
->assertText('Can be contacted', "[Compare CSV and Profile data] Row: {$row} Field: Contact Permission set");
}
else {
$this
->assertNoText('Can be contacted', "[Compare CSV and Profile data] Row: {$row} Field: Contact Permission not set");
}
$this
->assertText($csv[8], "[Compare CSV and Profile data] Row: {$row} Field: Contact Preference");
//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++;
}
}