You are here

function CDNUnitTestCase::setUp in CDN 7.2

Sets up unit test environment.

Unlike DrupalWebTestCase::setUp(), DrupalUnitTestCase::setUp() does not install modules because tests are performed without accessing the database. Any required files must be explicitly included by the child class setUp() method.

Overrides DrupalUnitTestCase::setUp

3 calls to CDNUnitTestCase::setUp()
CDNImageTestCase::setUp in tests/cdn.test
Sets up unit test environment.
CDNOriginPullFarFutureTestCase::setUp in tests/cdn.test
Sets up unit test environment.
CDNOriginPullTestCase::setUp in tests/cdn.test
Sets up unit test environment.
3 methods override CDNUnitTestCase::setUp()
CDNImageTestCase::setUp in tests/cdn.test
Sets up unit test environment.
CDNOriginPullFarFutureTestCase::setUp in tests/cdn.test
Sets up unit test environment.
CDNOriginPullTestCase::setUp in tests/cdn.test
Sets up unit test environment.

File

tests/cdn.test, line 9
Test CDN.

Class

CDNUnitTestCase
@file Test CDN.

Code

function setUp() {
  parent::setUp();

  // Alter $_SERVER to include some relatively rarely set HTTP headers.
  $alt_server = array(
    'HTTP_ACCEPT_ENCODING',
    'HTTPS' => 'off',
    'HTTP_X_FORWARDED_PROTO' => 'http',
    'HTTP_USER_AGENT' => $this
      ->randomName(),
  );
  $alt_server = array_merge($alt_server, $_SERVER);
  $_SERVER = $alt_server;
  $this
    ->setRequestProtocol('http');

  // Enable the private:// stream wrapper.
  $this
    ->variableSet('file_private_path', conf_path() . '/files/private');

  // Pretend the CDN module is enabled; this ensures invocations of its own
  // hook implementations will work as expected.
  $cdn_module_file = drupal_get_path('module', 'cdn') . '/cdn.module';
  $module_list['system']['filename'] = 'modules/system/system.module';
  $module_list['cdn']['filename'] = $cdn_module_file;
  module_list(TRUE, FALSE, FALSE, $module_list);
  $implementations =& drupal_static('module_implements');
  $implementations = array();
  $this
    ->loadFile('cdn.constants.inc');
  $this
    ->loadFile('cdn.module');

  // Override $conf to be able to use variable_set() and variable_get() in
  // DrupalUnitTestCase. At the same time, make sure we can restore the
  // original values.
  global $conf;
  $this->originalConfig = $conf;
  $this
    ->variableSetDefaults();
}