diff --git a/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualBlockCacheTest.php b/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualBlockCacheTest.php new file mode 100644 index 0000000..cabaac5 --- /dev/null +++ b/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualBlockCacheTest.php @@ -0,0 +1,57 @@ + 'Contextual link block caching', + 'description' => 'Tests if contextual links in blocks are cached properly and not shown to users without the correct permissions.', + 'group' => 'Contextual', + ); + } + + function setUp() { + parent::setUp(); + $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'administer blocks')); + $this->drupalLogin($web_user); + } + + /** + * Tests contextual links on Active forum topics block with different users. + */ + function testForumBlock() { + // Enable the Active forum topics block. + $block = $this->drupalPlaceBlock('forum_active_block'); + $this->assertText(t('The block configuration has been saved.'), '"Active forum topics" block was enabled'); + $configure_link = 'admin/structure/block/manage/' . $block['config_id'] . '/' . variable_get('theme_default', 'stark') . '/configure'; + + // Make sure the block is visible on the front page to the logged in user. + $this->drupalGet('node'); + $this->assertLinkByHref($configure_link, 0, 'Configure block link for Active forum topics block is displayed.'); + + // Log out and make sure the "Configure block" link is not visible to + // anonymous users. + $this->drupalLogout(); + $this->drupalGet('node'); + $this->assertNoLinkByHref($configure_link, 0, 'Configure block link for Active forum topics block is not displayed for logged out user.'); + } +}