You are here

public function BotchaTestCase::setUp in BOTCHA Spam Prevention 7.3

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

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

5 calls to BotchaTestCase::setUp()
BotchaHoneypot2TestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaHoneypotTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaNoResubmitTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaObscureUrlTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaTimegateTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
5 methods override BotchaTestCase::setUp()
BotchaHoneypot2TestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaHoneypotTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaNoResubmitTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaObscureUrlTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.
BotchaTimegateTestCase::setUp in tests/botcha.simpletest.test
Sets up a Drupal site for running functional and integration tests.

File

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

Class

BotchaTestCase
Testing general BOTCHA functionality.

Code

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

  // Allow comment posting for guests.
  $this
    ->allowCommentPostingForAnonymousVisitors();

  // @todo Debug this situation: tests don't have any content types at the moment of the BOTCHA enabling.
  // It causes lack of some form protection: comment_node_page_form as an example.
  // For some reason we don't find this form after installation - but we should.
  // So fix it manually.
  $form_controller = $this->application
    ->getController(Botcha::CONTROLLER_TYPE_FORM);
  $botcha_form = $form_controller
    ->getForm('comment_node_page_form', TRUE)
    ->setRecipebook('default')
    ->setEnabled(TRUE);
  $this
    ->assertEqual($botcha_form, $form_controller
    ->save($botcha_form), 'Form object correctly saved.', 'BOTCHA');

  // Create recipebook "test" + bind all forms to it.
  $recipebook_controller = $this->application
    ->getController(Botcha::CONTROLLER_TYPE_RECIPEBOOK);
  $recipebook = $recipebook_controller
    ->getRecipebook('test', TRUE)
    ->setTitle('Test recipebook')
    ->setDescription("Created for {$this->testId}");
  $default_recipebook = $recipebook_controller
    ->getRecipebook();
  foreach ($default_recipebook
    ->getForms() as $form_id) {
    $recipebook = $recipebook
      ->setForm($form_id);
  }
  $this
    ->assertEqual($recipebook, $recipebook_controller
    ->save($recipebook), 'Recipebook object correctly saved.', 'BOTCHA');
}