function NodeRevisionPermissionsTestCase::setUp

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

drupal/modules/node/node.test, line 2587
Tests for node.module.

Class

NodeRevisionPermissionsTestCase
Tests user permissions for node revisions.

Code

function setUp() {
  parent::setUp();

  // Create a node with several revisions.
  $node = $this
    ->drupalCreateNode();
  $this->node_revisions[] = $node;
  for ($i = 0; $i < 3; $i++) {

    // Create a revision for the same nid and settings with a random log.
    $revision = clone $node;
    $revision->revision = 1;
    $revision->log = $this
      ->randomName(32);
    node_save($revision);
    $this->node_revisions[] = $revision;
  }

  // Create three users, one with each revision permission.
  foreach ($this->map as $op => $permission) {

    // Create the user.
    $account = $this
      ->drupalCreateUser(array(
      'access content',
      'edit any page content',
      'delete any page content',
      $permission,
    ));
    $account->op = $op;
    $this->accounts[] = $account;
  }

  // Create an admin account (returns TRUE for all revision permissions).
  $admin_account = $this
    ->drupalCreateUser(array(
    'access content',
    'administer nodes',
  ));
  $admin_account->is_admin = TRUE;
  $this->accounts['admin'] = $admin_account;

  // Create a normal account (returns FALSE for all revision permissions).
  $normal_account = $this
    ->drupalCreateUser();
  $normal_account->op = FALSE;
  $this->accounts[] = $normal_account;
}