summaryrefslogtreecommitdiff
path: root/modules/contextual
diff options
context:
space:
mode:
Diffstat (limited to 'modules/contextual')
-rw-r--r--modules/contextual/contextual.info1
-rw-r--r--modules/contextual/contextual.module2
-rw-r--r--modules/contextual/contextual.test49
3 files changed, 51 insertions, 1 deletions
diff --git a/modules/contextual/contextual.info b/modules/contextual/contextual.info
index ffaabaf22..5ebc09809 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 = 7.x
+files[] = contextual.test
diff --git a/modules/contextual/contextual.module b/modules/contextual/contextual.module
index 9514b7123..0f371a574 100644
--- a/modules/contextual/contextual.module
+++ b/modules/contextual/contextual.module
@@ -13,7 +13,7 @@ function contextual_help($path, $arg) {
case 'admin/help#contextual':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Contextual links module displays links related to regions of pages on your site to users with <em>access contextual links</em> permission. For more information, see the online handbook entry for <a href="@contextual">Contextual links module</a>.', array('@contextual' => 'http://drupal.org/handbook/modules/contextual')) . '</p>';
+ $output .= '<p>' . t('The Contextual links module displays links related to regions of pages on your site to users with <em>access contextual links</em> permission. For more information, see the online handbook entry for <a href="@contextual">Contextual links module</a>.', array('@contextual' => 'http://drupal.org/documentation/modules/contextual')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Displaying contextual links') . '</dt>';
diff --git a/modules/contextual/contextual.test b/modules/contextual/contextual.test
new file mode 100644
index 000000000..79eedb86f
--- /dev/null
+++ b/modules/contextual/contextual.test
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @file
+ * Tests for contextual.module.
+ */
+
+/**
+ * Tests accessible links after inaccessible links on dynamic context.
+ */
+class ContextualDynamicContextTestCase extends DrupalWebTestCase {
+ protected $profile = 'testing';
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Contextual links on node lists',
+ 'description' => 'Tests if contextual links are showing on the front page depending on permissions.',
+ 'group' => 'Contextual',
+ );
+ }
+
+ function setUp() {
+ parent::setUp(array('contextual', 'node'));
+ $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content'));
+ $this->drupalLogin($web_user);
+ }
+
+ /**
+ * Tests contextual links on node lists with different permissions.
+ */
+ function testNodeLinks() {
+ // Create three nodes in the following order:
+ // - An article, which should be user-editable.
+ // - A page, which should not be user-editable.
+ // - A second article, which should also be user-editable.
+ $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+ $node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
+ $node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+
+ // Now, on the front page, all article nodes should have contextual edit
+ // links. The page node in between should not.
+ $this->drupalGet('node');
+ $this->assertRaw('node/' . $node1->nid . '/edit', 'Edit link for oldest article node showing.');
+ $this->assertNoRaw('node/' . $node2->nid . '/edit', 'No edit link for page nodes.');
+ $this->assertRaw('node/' . $node3->nid . '/edit', 'Edit link for most recent article node showing.');
+ }
+}