You are here

page_view.test in SimpleTest 6

Same filename and directory in other branches
  1. 5 tests/page_view.test

File

tests/page_view.test
View source
<?php

class PageViewTest extends DrupalTestCase {

  /**
   * Implementation of get_info() for information
   */
  function get_info() {
    return array(
      'name' => t('Unauthorized node view'),
      'desc' => t('Creates a node of type page and then an unpermissioned user attempts to edit the node, ' . 'before tries with an anonymous user. Asserts failure.' . '</ br>WARNING: This is based on default registered user permuissions (no administer nodes).'),
      'group' => 'Node Tests',
    );
  }
  function testPageView() {

    /* Prepare a node to view */
    global $user;
    $node = $this
      ->drupalCreateNode();
    $this
      ->assertNotNull(node_load($node->nid), 'Node created');

    /* Tries to edit with anonymous user */
    $html = $this
      ->drupalGet("node/{$node->nid}/edit");
    $this
      ->assertResponse(403);

    /* Prepare a user to request the node view */
    $test_user = $this
      ->drupalCreateUserRolePerm(array(
      'access content',
    ));
    $this
      ->drupalLoginUser($test_user);
    $html = $this
      ->drupalGet("node/{$node->nid}/edit");
    $this
      ->assertResponse(403);
    $test_user = $this
      ->drupalCreateUserRolePerm(array(
      'administer nodes',
    ));

    //TODO: Add edit page attempt with administer nodes user
    node_delete($node->nid);
  }

}

Classes

Namesort descending Description
PageViewTest