function SiteMaintenanceTestCase::testCronSiteMaintenance

Verify access to cron.php with custom 403 page during maintenance mode.

File

modules/system/system.test, line 1286

Class

SiteMaintenanceTestCase
Tests site maintenance functionality.

Code

function testCronSiteMaintenance() {
  global $base_url;
  // Set custom 403 page.
  $this->drupalLogin($this->admin_user);
  $edit = array(
    'title' => $this->randomName(10),
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $this->randomName(100),
        ),
      ),
    ),
  );
  $node = $this->drupalCreateNode($edit);
  // Use a custom 403 page.
  $this->drupalPost('admin/config/system/site-information', array(
    'site_403' => 'node/' . $node->nid,
  ), t('Save configuration'));
  // Turn on maintenance mode.
  $edit = array(
    'maintenance_mode' => 1,
  );
  $this->drupalPost('admin/config/development/maintenance', $edit, t('Save configuration'));
  $this->drupalLogout();
  // Access cron.php without valid cron key.
  $this->drupalGet($base_url . '/cron.php', array(
    'external' => TRUE,
  ));
  $this->assertResponse(503);
  // Access cron.php with 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(503);
}

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