$this->assertIdentical(user_get_authmaps($authname),$expected_output,t('Authmap for authname %authname was set correctly.',array('%authname'=>$authname)));
}
// Remove authmap for module poll, add authmap for module blog.
$authmaps=array(
'authname_poll'=>NULL,
'authname_blog'=>'external username three',
);
user_set_authmaps($account,$authmaps);
// Assert that external username one does not have authmaps.
$remove_username='external username one';
unset($expected_authmaps[$remove_username]);
$this->assertFalse(user_get_authmaps($remove_username),t('Authmap for %authname was removed.',array('%authname'=>$remove_username)));
// Assert that a new authmap was created for external username three, and
// existing authmaps for external username two were unchanged.
$this->assertIdentical(user_get_authmaps($authname),$expected_output,t('Authmap for authname %authname was set correctly.',array('%authname'=>$authname)));
$this->assertEqual(url('admin/people/permissions',array('absolute'=>TRUE)),$this->getUrl(),t('Still on the same page after login for access denied page'));
$this->assertEqual(url('user/'.$user->uid,array('absolute'=>TRUE)),$this->getUrl(),t('Redirected to user profile page after login from the frontpage'));
}
/**
* Test the Who's Online block.
*/
functiontestWhosOnlineBlock(){
// Generate users and make sure there are no current user sessions.
$user1=$this->drupalCreateUser(array());
$user2=$this->drupalCreateUser(array());
$user3=$this->drupalCreateUser(array());
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions}")->fetchField(),0,t('Sessions table is empty.'));
// Insert a user with two sessions.
$this->insertSession(array('uid'=>$user1->uid));
$this->insertSession(array('uid'=>$user1->uid));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid",array(':uid'=>$user1->uid))->fetchField(),2,t('Duplicate user session has been inserted.'));
$this->assertRaw(t('2 users'),t('Correct number of online users (2 users).'));
$this->assertText($user1->name,t('Active user 1 found in online list.'));
$this->assertText($user2->name,t('Active user 2 found in online list.'));
$this->assertNoText($user3->name,t("Inactive user not found in online list."));
$this->assertTrue(strpos($this->drupalGetContent(),$user1->name)>strpos($this->drupalGetContent(),$user2->name),t('Online users are ordered correctly.'));
}
/**
* Insert a user session into the {sessions} table. This function is used
* since we cannot log in more than one user at the same time in tests.
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid AND sid = :sid AND timestamp = :timestamp",array(':uid'=>$fields['uid'],':sid'=>$fields['sid'],':timestamp'=>$fields['timestamp']))->fetchField(),1,t('Session record inserted.'));
$this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'),t('Account cancellation request mailed message displayed.'));
$this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'),t('Bogus cancelling request rejected.'));
$account=user_load($account->uid);
$this->assertTrue($account->status==1,t('User account was not canceled.'));
$this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'),t('Expired cancel account request rejected.'));
$this->assertText(t('Are you sure you want to cancel your account?'),t('Confirmation form to cancel account displayed.'));
$this->assertText(t('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your user name.'),t('Informs that all content will be remain as is.'));
$this->assertNoText(t('Select the method to cancel the account above.'),t('Does not allow user to select account cancellation method.'));
// Confirm account cancellation.
$timestamp=time();
$this->drupalPost(NULL,NULL,t('Cancel account'));
$this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'),t('Account cancellation request mailed message displayed.'));