Tests disabling and re-enabling the Forum module.
function testNewForumTopicsBlock() {
$this
->drupalLogin($this->adminUser);
// Create 5 forum topics.
$topics = $this
->createForumTopics();
// Enable the new forum block.
$edit = array();
$edit['blocks[forum_new][region]'] = 'sidebar_second';
$this
->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this
->assertResponse(200);
$this
->assertText(t('The block settings have been updated.'), '"New forum topics" block was enabled');
$this
->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.');
$this
->assertLinkByHref('forum', 0, 'New forum topics block has a "more"-link.');
// We expect all 5 forum topics to appear in the "New forum topics" block.
foreach ($topics as $topic) {
$this
->assertLink($topic, 0, format_string('Forum topic @topic found in the "New forum topics" block.', array(
'@topic' => $topic,
)));
}
// Configure the new forum block to only show 2 topics.
$edit = array();
$edit['block_new_limit'] = 2;
$this
->drupalPost('admin/structure/block/manage/forum/new/configure', $edit, t('Save block'));
$this
->assertResponse(200);
// We expect only the 2 most recent forum topics to appear in the "New forum
// topics" block.
for ($index = 0; $index < 5; $index++) {
if (in_array($index, array(
3,
4,
))) {
$this
->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "New forum topics" block.', array(
'@topic' => $topics[$index],
)));
}
else {
$this
->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "New forum topics" block.', array(
'@topic' => $topics[$index],
)));
}
}
// Disable the "New forum topics" block again.
$edit = array();
$edit['blocks[forum_new][region]'] = BLOCK_REGION_NONE;
$this
->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this
->assertResponse(200);
$this
->assertText(t('The block settings have been updated.'), '"New forum topics" block was disabled');
}