diff --git a/modules/contextual/contextual.info b/modules/contextual/contextual.info index a006377..041f2e3 100644 --- a/modules/contextual/contextual.info +++ b/modules/contextual/contextual.info @@ -3,3 +3,4 @@ description = Provides contextual links to perform actions related to elements o package = Core version = VERSION core = 8.x +files[] = contextual.test diff --git a/modules/contextual/contextual.test b/modules/contextual/contextual.test new file mode 100644 index 0000000..93b0c1c --- /dev/null +++ b/modules/contextual/contextual.test @@ -0,0 +1,49 @@ + '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(array('contextual', 'block', 'forum')); + $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() { + // Set the forum_active block to the content region. + $edit = array(); + $edit['blocks[forum_active][region]'] = 'content'; + $edit['blocks[system_main][region]'] = 'content'; + $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); + $this->assertText(t('The block settings have been updated.'), 'Active forum topics block successfully moved to content region.'); + + // Make sure the block is visible on the front page to the logged in user. + $this->drupalGet('node'); + $this->assertLinkByHref('admin/structure/block/manage/forum/active/configure', 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('admin/structure/block/manage/forum/active/configure', 'Configure block link for Active forum topics block is not displayed for logged out user.'); + } +}