You are here

function TalkTests::setUp in Talk 7

Same name and namespace in other branches
  1. 6 talk.test \TalkTests::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

./talk.test, line 15

Class

TalkTests

Code

function setUp() {

  // Enable the talk module and its dependencies.
  parent::setUp('comment', 'talk');

  // Create a node type, and enable the talk module for that node type.
  $node_type = $this
    ->drupalCreateContentType();
  $this->talkType = $node_type->type;

  // This will automatically be reverted to whatever it was before the test took place after the test is over.
  variable_set('comment_talk_' . $node_type->type, TRUE);

  // We don't want to deal with comment previews.
  variable_set('comment_preview_' . $node_type->type, DRUPAL_OPTIONAL);

  // Set the talk title to something unique.
  $this->talkTitle = $this
    ->randomName();
  variable_set('talk_page', $this->talkTitle);
  $this->talkLink = $this
    ->randomName();
  variable_set('talk_link', $this->talkLink);
  $this->talkTab = $this
    ->randomName();
  variable_set('talk_tab', $this->talkTab);

  // Create and login a user with the appropriate permissions.
  $permissions = array(
    'access content',
    'access comments',
    'post comments',
    'skip comment approval',
  );
  $user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($user);
}