You are here

function CommentRssTest::testCommentRss in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Tests/CommentRssTest.php \Drupal\comment\Tests\CommentRssTest::testCommentRss()

Tests comments as part of an RSS feed.

File

core/modules/comment/src/Tests/CommentRssTest.php, line 50
Contains \Drupal\comment\Tests\CommentRssTest.

Class

CommentRssTest
Tests comments as part of an RSS feed.

Namespace

Drupal\comment\Tests

Code

function testCommentRss() {

  // Find comment in RSS feed.
  $this
    ->drupalLogin($this->webUser);
  $this
    ->postComment($this->node, $this
    ->randomMachineName(), $this
    ->randomMachineName());
  $this
    ->drupalGet('rss.xml');
  $cache_contexts = [
    'languages:language_interface',
    'theme',
    'url.site',
    'user.node_grants:view',
    'user.permissions',
    'timezone',
  ];
  $this
    ->assertCacheContexts($cache_contexts);
  $cache_context_tags = \Drupal::service('cache_contexts_manager')
    ->convertTokensToKeys($cache_contexts)
    ->getCacheTags();
  $this
    ->assertCacheTags(Cache::mergeTags($cache_context_tags, [
    'config:views.view.frontpage',
    'node:1',
    'node_list',
    'node_view',
    'user:3',
  ]));
  $raw = '<comments>' . $this->node
    ->url('canonical', array(
    'fragment' => 'comments',
    'absolute' => TRUE,
  )) . '</comments>';
  $this
    ->assertRaw($raw, 'Comments as part of RSS feed.');

  // Hide comments from RSS feed and check presence.
  $this->node
    ->set('comment', CommentItemInterface::HIDDEN);
  $this->node
    ->save();
  $this
    ->drupalGet('rss.xml');
  $this
    ->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.');
}