You are here

protected function EntityMetadataNodeRevisionAccessTestCase::setUp in Entity API 7

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

./entity.test, line 1284
Entity CRUD API tests.

Class

EntityMetadataNodeRevisionAccessTestCase
Tests user permissions for node revisions.

Code

protected function setUp() {
  parent::setUp('entity', 'node');

  // 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 = node_load($node->nid);
    $revision->revision = 1;
    $revision->log = $this
      ->randomName(32);
    node_save($revision);
    $this->node_revisions[] = node_load($revision->nid);
  }

  // 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;
}