You are here

public function ProtectedNodeRules::setUp in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x protected_node_rules/tests/protected_node_rules.test \ProtectedNodeRules::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

protected_node_rules/tests/protected_node_rules.test, line 27
Test protected node rules functionality.

Class

ProtectedNodeRules
Test protected node rules functionality.

Code

public function setUp() {
  parent::setUp('protected_node_rules');

  // Set the group.
  $this->group = 'Protected Node';

  // User with all needed permissions.
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'access protected node password form',
    'edit any protected node password',
    'edit protected content',
    'administer site configuration',
    'administer nodes',
    'bypass node access',
    'administer content types',
  ));

  // Users with access protected node permission.
  $this->normalAccessAllowedUser = $this
    ->drupalCreateUser(array(
    'access protected node password form',
  ));
  $this->normalAccessAllowedUser2 = $this
    ->drupalCreateUser(array(
    'access protected node password form',
  ));

  // User with view published content permission.
  $this->normalNonAccessAllowedUser = $this
    ->drupalCreateUser(array(
    'access content',
  ));

  // Log in an Admin.
  $this
    ->drupalLogin($this->adminUser);

  // Submit the configuration form.
  $protected_node_settings = array(
    'protected_node_use_global_password' => PROTECTED_NODE_PER_NODE_PASSWORD,
  );
  $this
    ->drupalPost('admin/config/content/protected_node', $protected_node_settings, t('Save configuration'));
}