Test the Who's Online block.
function testWhosOnlineBlock() {
// Generate users.
$user1 = $this
->drupalCreateUser(array());
$user2 = $this
->drupalCreateUser(array());
$user3 = $this
->drupalCreateUser(array());
// Update access of two users to be within the active timespan.
$this
->updateAccess($user1->uid);
$this
->updateAccess($user2->uid, REQUEST_TIME + 1);
// Insert an inactive user who should not be seen in the block.
$this
->updateAccess($user3->uid, REQUEST_TIME - config('user.block')
->get('seconds_online') - 1);
// Test block output.
$block = user_block_view('online');
$block['content'] = render($block['content']);
$this
->drupalSetContent($block['content']);
$this
->assertRaw(t('2 users'), 'Correct number of online users (2 users).');
$this
->assertText($user1->name, 'Active user 1 found in online list.');
$this
->assertText($user2->name, 'Active user 2 found in online list.');
$this
->assertNoText($user3->name, 'Inactive user not found in online list.');
$this
->assertTrue(strpos($this
->drupalGetContent(), $user1->name) > strpos($this
->drupalGetContent(), $user2->name), 'Online users are ordered correctly.');
}