2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
@@ -630,3 +630,68 @@ class UserAutocompleteTestCase extends DrupalWebTestCase {
$this->assertRaw($this->unprivileged_user->name,t('User name found in autocompletion results.'));
}
}
/**
* Test user blocks.
*/
classUserBlocksUnitTestsextendsDrupalWebTestCase{
functiongetInfo(){
returnarray(
'name'=>t('User blocks'),
'description'=>t('Test user blocks.'),
'group'=>t('User')
);
}
/**
* 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('%members and %visitors',array('%members'=>'2 users','%visitors'=>'2 guests')),t('Correct number of online users (2 users and 2 guests).'));
$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.'));