3 namespace Drupal\Tests\comment\Functional;
5 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
6 use Drupal\Core\Cache\Cache;
7 use Drupal\Core\Entity\Entity\EntityViewDisplay;
8 use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
11 * Tests comments as part of an RSS feed.
15 class CommentRssTest extends CommentTestBase {
17 use AssertPageCacheContextsAndTagsTrait;
24 public static $modules = ['views'];
29 protected function setUp() {
32 // Setup the rss view display.
33 EntityViewDisplay::create([
35 'targetEntityType' => 'node',
36 'bundle' => 'article',
38 'content' => ['links' => ['weight' => 100]],
43 * Tests comments as part of an RSS feed.
45 public function testCommentRss() {
46 // Find comment in RSS feed.
47 $this->drupalLogin($this->webUser);
48 $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName());
49 $this->drupalGet('rss.xml');
52 'languages:language_interface',
55 'user.node_grants:view',
59 $this->assertCacheContexts($cache_contexts);
61 $cache_context_tags = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($cache_contexts)->getCacheTags();
62 $this->assertCacheTags(Cache::mergeTags($cache_context_tags, [
63 'config:views.view.frontpage',
64 'node:1', 'node_list',
69 $raw = '<comments>' . $this->node->url('canonical', ['fragment' => 'comments', 'absolute' => TRUE]) . '</comments>';
70 $this->assertRaw($raw, 'Comments as part of RSS feed.');
72 // Hide comments from RSS feed and check presence.
73 $this->node->set('comment', CommentItemInterface::HIDDEN);
75 $this->drupalGet('rss.xml');
76 $this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.');