function CronRunTestCase::testCronRun

Test cron runs.

File

modules/system/system.test, line 813

Class

CronRunTestCase

Code

function testCronRun() {
    global $base_url;
    // Run cron anonymously without any cron key.
    $this->drupalGet($base_url . '/cron.php', array(
        'external' => TRUE,
    ));
    $this->assertResponse(403);
    // Run cron anonymously with a random cron key.
    $key = $this->randomName(16);
    $this->drupalGet($base_url . '/cron.php', array(
        'external' => TRUE,
        'query' => array(
            'cron_key' => $key,
        ),
    ));
    $this->assertResponse(403);
    // Run cron anonymously with the valid cron key.
    $key = variable_get('cron_key', 'drupal');
    $this->drupalGet($base_url . '/cron.php', array(
        'external' => TRUE,
        'query' => array(
            'cron_key' => $key,
        ),
    ));
    $this->assertResponse(200);
}

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