public function ForumBlockTest::testNewForumTopicsBlock in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/forum/src/Tests/ForumBlockTest.php \Drupal\forum\Tests\ForumBlockTest::testNewForumTopicsBlock()
Tests the "New forum topics" block.
File
- core/
modules/ forum/ src/ Tests/ ForumBlockTest.php, line 49 - Contains \Drupal\forum\Tests\ForumBlockTest.
Class
- ForumBlockTest
- Tests the forum blocks.
Namespace
Drupal\forum\TestsCode
public function testNewForumTopicsBlock() {
$this
->drupalLogin($this->adminUser);
// Enable the new forum topics block.
$block = $this
->drupalPlaceBlock('forum_new_block');
$this
->drupalGet('');
// Create 5 forum topics.
$topics = $this
->createForumTopics();
$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 topics block to only show 2 topics.
$block
->getPlugin()
->setConfigurationValue('block_count', 2);
$block
->save();
$this
->drupalGet('');
// 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],
)));
}
}
}