1 node.test NodeRevisionPermissionsTestCase::setUp()

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

Generates a random database prefix and installs Backdrop with the specified installation profile in BackdropWebTestCase::$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.

Return value

bool: TRUE if set up completes, FALSE if an error occurred.

Overrides BackdropWebTestCase::setUp

See also

BackdropWebTestCase::prepareDatabasePrefix()

BackdropWebTestCase::changeDatabasePrefix()

BackdropWebTestCase::prepareEnvironment()

File

core/modules/node/tests/node.test, line 3446
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->backdropCreateNode();
  $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);
    $revision->is_active_revision = FALSE;
    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->backdropCreateUser(
    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->backdropCreateUser(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->backdropCreateUser();
  $normal_account->op = FALSE;
  $this->accounts[] = $normal_account;
}