You are here

public function AuthcacheVarnishTestDefaultValidation::setUp in Authenticated User Page Caching (Authcache) 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

File

modules/authcache_varnish/authcache_varnish.test, line 306
Test cases for authcache_varnish module.

Class

AuthcacheVarnishTestDefaultValidation
Unit tests for authcache_varnish_request_validate().

Code

public function setUp() {
  global $conf;
  parent::setUp();
  require_once __DIR__ . '/authcache_varnish.module';
  $this->oldserver = $_SERVER;
  $this->oldconf = $conf;
  $this->remoteIp = '127.0.0.1';
  $this->proxyIp = '127.0.0.2';
  $this->proxy2Ip = '127.0.0.3';
  $this->untrustedIp = '0.0.0.0';

  // @ignore sniffer_semantics_remoteaddress_remoteaddress:class
  $_SERVER['REMOTE_ADDR'] = $this->remoteIp;
  unset($_SERVER['HTTP_X_VARNISH']);
  unset($_SERVER['HTTP_X_FORWARDED_FOR']);
  unset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']);
  unset($_SERVER['HTTP_X_AUTHCACHE_VARNISH_PASSPHRASE']);
  unset($_SERVER['HTTP_X_CUSTOM_PASSPHRASE_HEADER']);
  $this
    ->variableDel('authcache_varnish_validate_reverse_proxy_address');
  $this
    ->variableDel('authcache_varnish_header');
  $this
    ->variableDel('authcache_varnish_passphrase');
  $this
    ->variableDel('authcache_varnish_passphrase_header');
}