createForumTopics example

/** * Tests the "New forum topics" block. */
  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->assertSession()->linkExists('More', 0, 'New forum topics block has a "more"-link.');
    $this->assertSession()->linkByHrefExists('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->assertSession()->linkExists($topic, 0, new FormattableMarkup('Forum topic @topic found in the "New forum topics" block.', ['@topic' => $topic]));
    }

    // Configure the new forum topics block to only show 2 topics.     $block->getPlugin()->setConfigurationValue('block_count', 2);
    
Home | Imprint | This part of the site doesn't use cookies.