function StatisticsTestCase::setUp

Overrides DrupalWebTestCase::setUp

File

modules/statistics/statistics.test, line 14

Class

StatisticsTestCase
Defines a base class for testing the Statistics module.

Code

function setUp() {
    parent::setUp('statistics');
    // Create user.
    $this->blocking_user = $this->drupalCreateUser(array(
        'access administration pages',
        'access site reports',
        'access statistics',
        'block IP addresses',
        'administer blocks',
        'administer statistics',
        'administer users',
    ));
    $this->drupalLogin($this->blocking_user);
    // Enable access logging.
    variable_set('statistics_enable_access_log', 1);
    variable_set('statistics_count_content_views', 1);
    // Insert dummy access by anonymous user into access log.
    db_insert('accesslog')->fields(array(
        'title' => 'test',
        'path' => 'node/1',
        'url' => 'http://example.com',
        'hostname' => '1.2.3.3',
        'uid' => 0,
        'sid' => 10,
        'timer' => 10,
        'timestamp' => REQUEST_TIME,
    ))
        ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.