function ContextualDynamicContextTestCase::testNodeLinks in Drupal 7
Tests contextual links on node lists with different permissions.
File
- modules/
contextual/ contextual.test, line 33 - Tests for contextual.module.
Class
- ContextualDynamicContextTestCase
- Tests accessible links after inaccessible links on dynamic context.
Code
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.');
}