function StatisticsLoggingTestCase::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

drupal/modules/statistics/statistics.test, line 63
Tests for the Statistics module.

Class

StatisticsLoggingTestCase
Tests that logging via statistics_exit() works for all pages.

Code

function setUp() {
  parent::setUp('statistics');
  $this->auth_user = $this
    ->drupalCreateUser(array(
    'access content',
    'create page content',
    'edit own page content',
  ));

  // Ensure we have a node page to access.
  $this->node = $this
    ->drupalCreateNode(array(
    'title' => $this
      ->randomName(255),
    'uid' => $this->auth_user->uid,
  ));

  // Enable page caching.
  variable_set('cache', TRUE);

  // Enable access logging.
  variable_set('statistics_enable_access_log', 1);
  variable_set('statistics_count_content_views', 1);

  // Clear the logs.
  db_truncate('accesslog');
  db_truncate('node_counter');
}