| Drupal | PHP Cross Reference | Content Management Systems |
1 <?php 2 3 class BootstrapIPAddressTestCase extends DrupalWebTestCase { 4 5 public static function getInfo() { 6 return array( 7 'name' => 'IP address and HTTP_HOST test', 8 'description' => 'Get the IP address from the current visitor from the server variables, check hostname validation.', 9 'group' => 'Bootstrap' 10 ); 11 } 12 13 function setUp() { 14 $this->oldserver = $_SERVER; 15 16 $this->remote_ip = '127.0.0.1'; 17 $this->proxy_ip = '127.0.0.2'; 18 $this->proxy2_ip = '127.0.0.3'; 19 $this->forwarded_ip = '127.0.0.4'; 20 $this->cluster_ip = '127.0.0.5'; 21 $this->untrusted_ip = '0.0.0.0'; 22 23 drupal_static_reset('ip_address'); 24 25 $_SERVER['REMOTE_ADDR'] = $this->remote_ip; 26 unset($_SERVER['HTTP_X_FORWARDED_FOR']); 27 unset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']); 28 29 parent::setUp(); 30 } 31 32 function tearDown() { 33 $_SERVER = $this->oldserver; 34 drupal_static_reset('ip_address'); 35 parent::tearDown(); 36 } 37 38 /** 39 * test IP Address and hostname 40 */ 41 function testIPAddressHost() { 42 // Test the normal IP address. 43 $this->assertTrue( 44 ip_address() == $this->remote_ip, 45 t('Got remote IP address.') 46 ); 47 48 // Proxy forwarding on but no proxy addresses defined. 49 variable_set('reverse_proxy', 1); 50 $this->assertTrue( 51 ip_address() == $this->remote_ip, 52 t('Proxy forwarding without trusted proxies got remote IP address.') 53 ); 54 55 // Proxy forwarding on and proxy address not trusted. 56 variable_set('reverse_proxy_addresses', array($this->proxy_ip, $this->proxy2_ip)); 57 drupal_static_reset('ip_address'); 58 $_SERVER['REMOTE_ADDR'] = $this->untrusted_ip; 59 $this->assertTrue( 60 ip_address() == $this->untrusted_ip, 61 t('Proxy forwarding with untrusted proxy got remote IP address.') 62 ); 63 64 // Proxy forwarding on and proxy address trusted. 65 $_SERVER['REMOTE_ADDR'] = $this->proxy_ip; 66 $_SERVER['HTTP_X_FORWARDED_FOR'] = $this->forwarded_ip; 67 drupal_static_reset('ip_address'); 68 $this->assertTrue( 69 ip_address() == $this->forwarded_ip, 70 t('Proxy forwarding with trusted proxy got forwarded IP address.') 71 ); 72 73 // Multi-tier architecture with comma separated values in header. 74 $_SERVER['REMOTE_ADDR'] = $this->proxy_ip; 75 $_SERVER['HTTP_X_FORWARDED_FOR'] = implode(', ', array($this->untrusted_ip, $this->forwarded_ip, $this->proxy2_ip)); 76 drupal_static_reset('ip_address'); 77 $this->assertTrue( 78 ip_address() == $this->forwarded_ip, 79 t('Proxy forwarding with trusted 2-tier proxy got forwarded IP address.') 80 ); 81 82 // Custom client-IP header. 83 variable_set('reverse_proxy_header', 'HTTP_X_CLUSTER_CLIENT_IP'); 84 $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] = $this->cluster_ip; 85 drupal_static_reset('ip_address'); 86 $this->assertTrue( 87 ip_address() == $this->cluster_ip, 88 t('Cluster environment got cluster client IP.') 89 ); 90 91 // Verifies that drupal_valid_http_host() prevents invalid characters. 92 $this->assertFalse(drupal_valid_http_host('security/.drupal.org:80'), t('HTTP_HOST with / is invalid')); 93 $this->assertFalse(drupal_valid_http_host('security\\.drupal.org:80'), t('HTTP_HOST with \\ is invalid')); 94 $this->assertFalse(drupal_valid_http_host('security<.drupal.org:80'), t('HTTP_HOST with < is invalid')); 95 $this->assertFalse(drupal_valid_http_host('security..drupal.org:80'), t('HTTP_HOST with .. is invalid')); 96 // IPv6 loopback address 97 $this->assertTrue(drupal_valid_http_host('[::1]:80'), t('HTTP_HOST containing IPv6 loopback is valid')); 98 } 99 } 100 101 class BootstrapPageCacheTestCase extends DrupalWebTestCase { 102 103 public static function getInfo() { 104 return array( 105 'name' => 'Page cache test', 106 'description' => 'Enable the page cache and test it with various HTTP requests.', 107 'group' => 'Bootstrap' 108 ); 109 } 110 111 function setUp() { 112 parent::setUp('system_test'); 113 } 114 115 /** 116 * Test support for requests containing If-Modified-Since and If-None-Match headers. 117 */ 118 function testConditionalRequests() { 119 variable_set('cache', 1); 120 121 // Fill the cache. 122 $this->drupalGet(''); 123 124 $this->drupalHead(''); 125 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); 126 $etag = $this->drupalGetHeader('ETag'); 127 $last_modified = $this->drupalGetHeader('Last-Modified'); 128 129 $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag)); 130 $this->assertResponse(304, t('Conditional request returned 304 Not Modified.')); 131 132 $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match: ' . $etag)); 133 $this->assertResponse(304, t('Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.')); 134 135 $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match: ' . $etag)); 136 $this->assertResponse(304, t('Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.')); 137 138 $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified)); 139 $this->assertResponse(200, t('Conditional request without If-None-Match returned 200 OK.')); 140 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); 141 142 $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC1123, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag)); 143 $this->assertResponse(200, t('Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.')); 144 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); 145 146 $user = $this->drupalCreateUser(); 147 $this->drupalLogin($user); 148 $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag)); 149 $this->assertResponse(200, t('Conditional request returned 200 OK for authenticated user.')); 150 $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), t('Absense of Page was not cached.')); 151 } 152 153 /** 154 * Test cache headers. 155 */ 156 function testPageCache() { 157 variable_set('cache', 1); 158 159 // Fill the cache. 160 $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); 161 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); 162 $this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', t('Vary header was sent.')); 163 $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', t('Cache-Control header was sent.')); 164 $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); 165 $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); 166 167 // Check cache. 168 $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); 169 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); 170 $this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', t('Vary: Cookie header was sent.')); 171 $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', t('Cache-Control header was sent.')); 172 $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); 173 $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); 174 175 // Check replacing default headers. 176 $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT'))); 177 $this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', t('Default header was replaced.')); 178 $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Vary', 'value' => 'User-Agent'))); 179 $this->assertEqual($this->drupalGetHeader('Vary'), 'User-Agent,Accept-Encoding', t('Default header was replaced.')); 180 181 // Check that authenticated users bypass the cache. 182 $user = $this->drupalCreateUser(); 183 $this->drupalLogin($user); 184 $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); 185 $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), t('Caching was bypassed.')); 186 $this->assertTrue(strpos($this->drupalGetHeader('Vary'), 'Cookie') === FALSE, t('Vary: Cookie header was not sent.')); 187 $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, must-revalidate, post-check=0, pre-check=0', t('Cache-Control header was sent.')); 188 $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); 189 $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); 190 191 } 192 193 /** 194 * Test page compression. 195 * 196 * The test should pass even if zlib.output_compression is enabled in php.ini, 197 * .htaccess or similar, or if compression is done outside PHP, e.g. by the 198 * mod_deflate Apache module. 199 */ 200 function testPageCompression() { 201 variable_set('cache', 1); 202 203 // Fill the cache and verify that output is compressed. 204 $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); 205 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); 206 $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); 207 $this->assertRaw('</html>', t('Page was gzip compressed.')); 208 209 // Verify that cached output is compressed. 210 $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); 211 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); 212 $this->assertEqual($this->drupalGetHeader('Content-Encoding'), 'gzip', t('A Content-Encoding header was sent.')); 213 $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); 214 $this->assertRaw('</html>', t('Page was gzip compressed.')); 215 216 // Verify that a client without compression support gets an uncompressed page. 217 $this->drupalGet(''); 218 $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); 219 $this->assertFalse($this->drupalGetHeader('Content-Encoding'), t('A Content-Encoding header was not sent.')); 220 $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), t('Site title matches.')); 221 $this->assertRaw('</html>', t('Page was not compressed.')); 222 } 223 } 224 225 class BootstrapVariableTestCase extends DrupalWebTestCase { 226 227 function setUp() { 228 parent::setUp('system_test'); 229 } 230 231 public static function getInfo() { 232 return array( 233 'name' => 'Variable test', 234 'description' => 'Make sure the variable system functions correctly.', 235 'group' => 'Bootstrap' 236 ); 237 } 238 239 /** 240 * testVariable 241 */ 242 function testVariable() { 243 // Setting and retrieving values. 244 $variable = $this->randomName(); 245 variable_set('simpletest_bootstrap_variable_test', $variable); 246 $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), t('Setting and retrieving values')); 247 248 // Make sure the variable persists across multiple requests. 249 $this->drupalGet('system-test/variable-get'); 250 $this->assertText($variable, t('Variable persists across multiple requests')); 251 252 // Deleting variables. 253 $default_value = $this->randomName(); 254 variable_del('simpletest_bootstrap_variable_test'); 255 $variable = variable_get('simpletest_bootstrap_variable_test', $default_value); 256 $this->assertIdentical($variable, $default_value, t('Deleting variables')); 257 } 258 259 /** 260 * Makes sure that the default variable parameter is passed through okay. 261 */ 262 function testVariableDefaults() { 263 // Tests passing nothing through to the default. 264 $this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), t('Variables are correctly defaulting to NULL.')); 265 266 // Tests passing 5 to the default parameter. 267 $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), t('The default variable parameter is passed through correctly.')); 268 } 269 270 } 271 272 /** 273 * Test hook_boot() and hook_exit(). 274 */ 275 class HookBootExitTestCase extends DrupalWebTestCase { 276 277 public static function getInfo() { 278 return array( 279 'name' => 'Boot and exit hook invocation', 280 'description' => 'Test that hook_boot() and hook_exit() are called correctly.', 281 'group' => 'Bootstrap', 282 ); 283 } 284 285 function setUp() { 286 parent::setUp('system_test', 'dblog'); 287 } 288 289 /** 290 * Test calling of hook_boot() and hook_exit(). 291 */ 292 function testHookBootExit() { 293 // Test with cache disabled. Boot and exit should always fire. 294 variable_set('cache', 0); 295 $this->drupalGet(''); 296 $calls = 1; 297 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot called with disabled cache.')); 298 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with disabled cache.')); 299 300 // Test with normal cache. Boot and exit should be called. 301 variable_set('cache', 1); 302 $this->drupalGet(''); 303 $calls++; 304 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot called with normal cache.')); 305 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with normal cache.')); 306 307 // Boot and exit should not fire since the page is cached. 308 variable_set('page_cache_invoke_hooks', FALSE); 309 $this->assertTrue(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been cached.')); 310 $this->drupalGet(''); 311 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot not called with aggressive cache and a cached page.')); 312 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit not called with aggressive cache and a cached page.')); 313 314 // Test with page cache cleared, boot and exit should be called. 315 $this->assertTrue(db_delete('cache_page')->execute(), t('Page cache cleared.')); 316 $this->drupalGet(''); 317 $calls++; 318 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot called with aggressive cache and no cached page.')); 319 $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with aggressive cache and no cached page.')); 320 } 321 } 322 323 /** 324 * Test drupal_get_filename()'s availability. 325 */ 326 class BootstrapGetFilenameTestCase extends DrupalUnitTestCase { 327 328 public static function getInfo() { 329 return array( 330 'name' => 'Get filename test', 331 'description' => 'Test that drupal_get_filename() works correctly when the file is not found in the database.', 332 'group' => 'Bootstrap', 333 ); 334 } 335 336 /** 337 * Test that drupal_get_filename() works correctly when the file is not found in the database. 338 */ 339 function testDrupalGetFilename() { 340 // Reset the static cache so we can test the "db is not active" code of 341 // drupal_get_filename(). 342 drupal_static_reset('drupal_get_filename'); 343 344 // Retrieving the location of a module. 345 $this->assertIdentical(drupal_get_filename('module', 'php'), 'modules/php/php.module', t('Retrieve module location.')); 346 347 // Retrieving the location of a theme. 348 $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'themes/stark/stark.info', t('Retrieve theme location.')); 349 350 // Retrieving the location of a theme engine. 351 $this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'themes/engines/phptemplate/phptemplate.engine', t('Retrieve theme engine location.')); 352 353 // Retrieving the location of a profile. Profiles are a special case with 354 // a fixed location and naming. 355 $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'profiles/standard/standard.profile', t('Retrieve install profile location.')); 356 357 // When a file is not found in the database cache, drupal_get_filename() 358 // searches several locations on the filesystem, including the DRUPAL_ROOT 359 // directory. We use the '.script' extension below because this is a 360 // non-existent filetype that will definitely not exist in the database. 361 // Since there is already a scripts directory, drupal_get_filename() will 362 // automatically check there for 'script' files, just as it does for (e.g.) 363 // 'module' files in modules. 364 $this->assertIdentical(drupal_get_filename('script', 'test'), 'scripts/test.script', t('Retrieve test script location.')); 365 } 366 } 367 368 class BootstrapTimerTestCase extends DrupalUnitTestCase { 369 370 public static function getInfo() { 371 return array( 372 'name' => 'Timer test', 373 'description' => 'Test that timer_read() works both when a timer is running and when a timer is stopped.', 374 'group' => 'Bootstrap', 375 ); 376 } 377 378 /** 379 * Test timer_read() to ensure it properly accumulates time when the timer 380 * started and stopped multiple times. 381 * @return 382 */ 383 function testTimer() { 384 timer_start('test'); 385 sleep(1); 386 $this->assertTrue(timer_read('test') >= 1000, t('Timer measured 1 second of sleeping while running.')); 387 sleep(1); 388 timer_stop('test'); 389 $this->assertTrue(timer_read('test') >= 2000, t('Timer measured 2 seconds of sleeping after being stopped.')); 390 timer_start('test'); 391 sleep(1); 392 $this->assertTrue(timer_read('test') >= 3000, t('Timer measured 3 seconds of sleeping after being restarted.')); 393 sleep(1); 394 $timer = timer_stop('test'); 395 $this->assertTrue(timer_read('test') >= 4000, t('Timer measured 4 seconds of sleeping after being stopped for a second time.')); 396 $this->assertEqual($timer['count'], 2, t('Timer counted 2 instances of being started.')); 397 } 398 } 399 400 /** 401 * Test that resetting static variables works. 402 */ 403 class BootstrapResettableStaticTestCase extends DrupalUnitTestCase { 404 405 public static function getInfo() { 406 return array( 407 'name' => 'Resettable static variables test', 408 'description' => 'Test that drupal_static() and drupal_static_reset() work.', 409 'group' => 'Bootstrap', 410 ); 411 } 412 413 /** 414 * Test that a variable reference returned by drupal_static() gets reset when 415 * drupal_static_reset() is called. 416 */ 417 function testDrupalStatic() { 418 $name = __CLASS__ . '_' . __METHOD__; 419 $var = &drupal_static($name, 'foo'); 420 $this->assertEqual($var, 'foo', t('Variable returned by drupal_static() was set to its default.')); 421 422 // Call the specific reset and the global reset each twice to ensure that 423 // multiple resets can be issued without odd side effects. 424 $var = 'bar'; 425 drupal_static_reset($name); 426 $this->assertEqual($var, 'foo', t('Variable was reset after first invocation of name-specific reset.')); 427 $var = 'bar'; 428 drupal_static_reset($name); 429 $this->assertEqual($var, 'foo', t('Variable was reset after second invocation of name-specific reset.')); 430 $var = 'bar'; 431 drupal_static_reset(); 432 $this->assertEqual($var, 'foo', t('Variable was reset after first invocation of global reset.')); 433 $var = 'bar'; 434 drupal_static_reset(); 435 $this->assertEqual($var, 'foo', t('Variable was reset after second invocation of global reset.')); 436 } 437 } 438 439 /** 440 * Test miscellaneous functions in bootstrap.inc. 441 */ 442 class BootstrapMiscTestCase extends DrupalUnitTestCase { 443 444 public static function getInfo() { 445 return array( 446 'name' => 'Miscellaneous bootstrap unit tests', 447 'description' => 'Test miscellaneous functions in bootstrap.inc.', 448 'group' => 'Bootstrap', 449 ); 450 } 451 452 /** 453 * Test miscellaneous functions in bootstrap.inc. 454 */ 455 function testMisc() { 456 // Test drupal_array_merge_deep(). 457 $link_options_1 = array('fragment' => 'x', 'attributes' => array('title' => 'X', 'class' => array('a', 'b')), 'language' => 'en'); 458 $link_options_2 = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('c', 'd')), 'html' => TRUE); 459 $expected = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('a', 'b', 'c', 'd')), 'language' => 'en', 'html' => TRUE); 460 $this->assertIdentical(drupal_array_merge_deep($link_options_1, $link_options_2), $expected, t('drupal_array_merge_deep() returned a properly merged array.')); 461 } 462 } 463 464 /** 465 * Tests for overriding server variables via the API. 466 */ 467 class BootstrapOverrideServerVariablesTestCase extends DrupalUnitTestCase { 468 public static function getInfo() { 469 return array( 470 'name' => 'Overriding server variables', 471 'description' => 'Test that drupal_override_server_variables() works correctly.', 472 'group' => 'Bootstrap', 473 ); 474 } 475 476 /** 477 * Test providing a direct URL to to drupal_override_server_variables(). 478 */ 479 function testDrupalOverrideServerVariablesProvidedURL() { 480 $tests = array( 481 'http://example.com' => array( 482 'HTTP_HOST' => 'example.com', 483 'SCRIPT_NAME' => isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL, 484 ), 485 'http://example.com/index.php' => array( 486 'HTTP_HOST' => 'example.com', 487 'SCRIPT_NAME' => '/index.php', 488 ), 489 'http://example.com/subdirectory/index.php' => array( 490 'HTTP_HOST' => 'example.com', 491 'SCRIPT_NAME' => '/subdirectory/index.php', 492 ), 493 ); 494 foreach ($tests as $url => $expected_server_values) { 495 // Remember the original value of $_SERVER, since the function call below 496 // will modify it. 497 $original_server = $_SERVER; 498 // Call drupal_override_server_variables() and ensure that all expected 499 // $_SERVER variables were modified correctly. 500 drupal_override_server_variables(array('url' => $url)); 501 foreach ($expected_server_values as $key => $value) { 502 $this->assertIdentical($_SERVER[$key], $value); 503 } 504 // Restore the original value of $_SERVER. 505 $_SERVER = $original_server; 506 } 507 } 508 } 509
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title