You are here

public function BotchaBaseWebTestCase::setUp in BOTCHA Spam Prevention 7.3

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 botcha.test \BotchaBaseWebTestCase::setUp()
  5. 7.2 botcha.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()

2 calls to BotchaBaseWebTestCase::setUp()
BotchaAdminTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
2 methods override BotchaBaseWebTestCase::setUp()
BotchaAdminTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.

File

tests/botcha.simpletest.test, line 53
Simpletest-tests for BOTCHA module.

Class

BotchaBaseWebTestCase
Base class for BOTCHA tests.

Code

public function setUp() {

  // Backward compatibility together with support of new way of passing modules parameter.
  // @link DrupalWebTestCase::setUp() @endlink
  $modules = func_get_args();
  if (isset($modules[0]) && is_array($modules[0])) {
    $modules = $modules[0];
  }
  parent::setUp(array_merge($modules, array(
    'comment',
    'moopapi',
    'botcha',
  )));

  // Fill in the application.
  $this->application = ComponentFactory::get('Botcha', Component::TYPE_CONTROLLER, Component::ID_APPLICATION);

  // Create a normal user.
  $permissions = array(
    'access comments',
    'post comments',
    // @todo Abstract it.

    //'post comments without approval',
    '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';

  // It is for admin test case.
  $permissions[] = 'access site reports';
  $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);
}