You are here

function BotchaBaseWebTestCase::setUp in BOTCHA Spam Prevention 7

Same name and namespace in other branches
  1. 6 botcha.test \BotchaBaseWebTestCase::setUp()
  2. 6.2 botcha.test \BotchaBaseWebTestCase::setUp()
  3. 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::setUp()
  4. 7.2 botcha.test \BotchaBaseWebTestCase::setUp()
  5. 7.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::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

./botcha.test, line 64
Tests for BOTCHA module.

Class

BotchaBaseWebTestCase
Base class for BOTCHA tests.

Code

function setUp() {

  // Load two modules: the botcha module itself and the comment module for testing anonymous comments.
  parent::setUp('botcha', 'comment');
  module_load_include('inc', 'botcha');

  // Create a normal user.
  $permissions = array(
    'access comments',
    'post comments',
    'skip comment approval',
    'access content',
    'create page content',
    'edit own page content',
  );
  $this->normal_user = $this
    ->drupalCreateUser($permissions);

  // Create an admin user.
  $permissions[] = 'administer BOTCHA settings';
  $permissions[] = 'skip BOTCHA';
  $permissions[] = 'administer permissions';
  $permissions[] = 'administer content types';
  $this->admin_user = $this
    ->drupalCreateUser($permissions);

  // Put comments on page nodes on a separate page (default in D7: below post).
  variable_set('comment_form_location_page', COMMENT_FORM_SEPARATE_PAGE);

  // Tweak BOTCHA configuration
  db_update('botcha_points')
    ->fields(array(
    'botcha_type' => 'none',
  ))
    ->condition('form_id', 'user_login')
    ->execute();
  db_update('botcha_points')
    ->fields(array(
    'botcha_type' => 'none',
  ))
    ->condition('form_id', 'user_login_block')
    ->execute();
}