Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/comment/tests/src/Functional/CommentRssTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | 12f9dff5fda9 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\comment\Functional; | |
4 | |
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; | |
9 | |
10 /** | |
11 * Tests comments as part of an RSS feed. | |
12 * | |
13 * @group comment | |
14 */ | |
15 class CommentRssTest extends CommentTestBase { | |
16 | |
17 use AssertPageCacheContextsAndTagsTrait; | |
18 | |
19 /** | |
20 * Modules to install. | |
21 * | |
22 * @var array | |
23 */ | |
24 public static $modules = ['views']; | |
25 | |
26 /** | |
27 * {@inheritdoc} | |
28 */ | |
29 protected function setUp() { | |
30 parent::setUp(); | |
31 | |
32 // Setup the rss view display. | |
33 EntityViewDisplay::create([ | |
34 'status' => TRUE, | |
35 'targetEntityType' => 'node', | |
36 'bundle' => 'article', | |
37 'mode' => 'rss', | |
38 'content' => ['links' => ['weight' => 100]], | |
39 ])->save(); | |
40 } | |
41 | |
42 /** | |
43 * Tests comments as part of an RSS feed. | |
44 */ | |
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'); | |
50 | |
51 $cache_contexts = [ | |
52 'languages:language_interface', | |
53 'theme', | |
54 'url.site', | |
55 'user.node_grants:view', | |
56 'user.permissions', | |
57 'timezone', | |
58 ]; | |
59 $this->assertCacheContexts($cache_contexts); | |
60 | |
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', | |
65 'node_view', | |
66 'user:3', | |
67 ])); | |
68 | |
69 $raw = '<comments>' . $this->node->url('canonical', ['fragment' => 'comments', 'absolute' => TRUE]) . '</comments>'; | |
70 $this->assertRaw($raw, 'Comments as part of RSS feed.'); | |
71 | |
72 // Hide comments from RSS feed and check presence. | |
73 $this->node->set('comment', CommentItemInterface::HIDDEN); | |
74 $this->node->save(); | |
75 $this->drupalGet('rss.xml'); | |
76 $this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.'); | |
77 } | |
78 | |
79 } |