1 bootstrap.test BootstrapOverrideServerVariablesTestCase::testBackdropOverrideServerVariablesProvidedURL()

Test providing a direct URL to to backdrop_override_server_variables().

File

core/modules/simpletest/tests/bootstrap.test, line 610

Class

BootstrapOverrideServerVariablesTestCase
Tests for overriding server variables via the API.

Code

function testBackdropOverrideServerVariablesProvidedURL() {
  $tests = array(
    'http://example.com' => array(
      'HTTP_HOST' => 'example.com',
      'SCRIPT_NAME' => isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL,
    ),
    'http://example.com/index.php' => array(
      'HTTP_HOST' => 'example.com',
      'SCRIPT_NAME' => '/index.php',
    ),
    'http://example.com/subdirectory/index.php' => array(
      'HTTP_HOST' => 'example.com',
      'SCRIPT_NAME' => '/subdirectory/index.php',
    ),
  );
  foreach ($tests as $url => $expected_server_values) {
    // Remember the original value of $_SERVER, since the function call below
    // will modify it.
    $original_server = $_SERVER;
    // Call backdrop_override_server_variables() and ensure that all expected
    // $_SERVER variables were modified correctly.
    backdrop_override_server_variables(array('url' => $url));
    foreach ($expected_server_values as $key => $value) {
      $this->assertIdentical($_SERVER[$key], $value);
    }
    // Restore the original value of $_SERVER.
    $_SERVER = $original_server;
  }
}