1.20.x contextual.test ContextualDynamicContextTestCase::testNodeLinks()

Tests contextual links on node lists with different permissions.

File

modules/contextual/tests/contextual.test, line 25
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 post, which should be user-editable.
  // - A page, which should not be user-editable.
  // - A second post, which should also be user-editable.
  $node1 = $this->backdropCreateNode(array('type' => 'post', 'promote' => 1));
  $node2 = $this->backdropCreateNode(array('type' => 'page', 'promote' => 1));
  $node3 = $this->backdropCreateNode(array('type' => 'post', 'promote' => 1));

  // Now, on the home page, all post nodes should have contextual edit
  // links. The page node in between should not.
  $this->backdropGet('node');
  $this->assertRaw('node/' . $node1->nid . '/edit', 'Edit link for oldest post 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 post node showing.');
}