1 node.test PageViewTestCase::testPageView()

Tests an anonymous and unpermissioned user attempting to edit the node.

File

core/modules/node/tests/node.test, line 1201
Tests for node.module.

Class

PageViewTestCase
Tests the functionality of node entity edit permissions.

Code

function testPageView() {
  // Create a node to view.
  $node = $this->backdropCreateNode();
  $this->assertTrue(node_load($node->nid), 'Node created.');

  // Try to edit with anonymous user.
  $this->backdropLogout();
  $this->backdropGet("node/$node->nid/edit");
  $this->assertResponse(403);

  // Create a user without permission to edit node.
  $web_user = $this->backdropCreateUser(array('access content'));
  $this->backdropLogin($web_user);

  // Attempt to access edit page.
  $this->backdropGet("node/$node->nid/edit");
  $this->assertResponse(403);

  // Create user with permission to edit node.
  $web_user = $this->backdropCreateUser(array('bypass node access'));
  $this->backdropLogin($web_user);

  // Attempt to access edit page.
  $this->backdropGet("node/$node->nid/edit");
  $this->assertResponse(200);
}