You are here

function BotchaBaseWebTestCase::setUp in BOTCHA Spam Prevention 6

Same name and namespace in other branches
  1. 6.2 botcha.test \BotchaBaseWebTestCase::setUp()
  2. 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::setUp()
  3. 7 botcha.test \BotchaBaseWebTestCase::setUp()
  4. 7.2 botcha.test \BotchaBaseWebTestCase::setUp()
  5. 7.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::setUp()

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

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

File

./botcha.test, line 67
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',
    'post comments without 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_query("UPDATE {botcha_points} SET botcha_type = '%s' WHERE form_id = '%s'", 'none', 'user_login');
  db_query("UPDATE {botcha_points} SET botcha_type = '%s' WHERE form_id = '%s'", 'none', 'user_login_block');
}