class CDNGeneralTestCase

Hierarchy

Expanded class hierarchy of CDNGeneralTestCase

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
CDNGeneralTestCase::getInfo public static function
CDNGeneralTestCase::testHTTPSDetection function
CDNTestCase::configureHTTPS function Configure HTTPS-related settings.
CDNTestCase::getExpandedFilePath function Given a file URI, get the expanded file path.
CDNTestCase::loadFile function
CDNTestCase::setRequestProtocol function Set the protocol of the current "request".
CDNTestCase::setUp function
CDNTestCase::tearDown function
CDNTestCase::touchFile function Given a file URI, get its path, create the file and ensure it exists.
CDNTestCase::variableSet function Mock function for variable_set().
CDNTestCase::variableSetDefaults function Set the default variable values for the CDN module.

File

modules/contrib/cdn/cdn.test, line 137
Test CDN.

View source
class CDNGeneralTestCase extends CDNTestCase {
  public static function getInfo() {
    return array(
      'name' => 'General',
      'description' => 'Verify general functionality.',
      'group' => 'CDN',
    );
  }

  function testHTTPSDetection() {
    // HTTPS + HTTP_X_FORWARDED_PROTO permutations.
    $_SERVER['HTTPS'] = 'off';
    $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http';
    $this->assertEqual(FALSE, cdn_request_is_https(), 'HTTP request detected.');

    $_SERVER['HTTPS'] = 'off';
    $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
    $this->assertEqual(TRUE, cdn_request_is_https(), 'HTTPS request detected.');

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
    $this->assertEqual(TRUE, cdn_request_is_https(), 'HTTPS request detected.');

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http';
    $this->assertEqual(TRUE, cdn_request_is_https(), 'HTTPS request detected.');

    // HTTPS + HTTP_X_FORWARDED_PROTOCOL permutations.
    unset($_SERVER['HTTP_X_FORWARDED_PROTO']);
    $_SERVER['HTTPS'] = 'off';
    $_SERVER['HTTP_X_FORWARDED_PROTOCOL'] = 'http';
    $this->assertEqual(FALSE, cdn_request_is_https(), 'HTTP request detected.');

    $_SERVER['HTTPS'] = 'off';
    $_SERVER['HTTP_X_FORWARDED_PROTOCOL'] = 'https';
    $this->assertEqual(TRUE, cdn_request_is_https(), 'HTTPS request detected.');

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['HTTP_X_FORWARDED_PROTOCOL'] = 'https';
    $this->assertEqual(TRUE, cdn_request_is_https(), 'HTTPS request detected.');

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['HTTP_X_FORWARDED_PROTOCOL'] = 'http';
    $this->assertEqual(TRUE, cdn_request_is_https(), 'HTTPS request detected.');
  }
}