Changeset 36721
- Timestamp:
- 02/26/2016 02:08:47 AM (9 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/bootstrap.php
r36715 r36721 25 25 require_once dirname( __FILE__ ) . '/functions.php'; 26 26 27 tests_reset_ SERVER();27 tests_reset__SERVER(); 28 28 29 29 define( 'WP_TESTS_TABLE_PREFIX', $table_prefix ); -
trunk/tests/phpunit/includes/functions.php
r36715 r36721 4 4 * Resets various `$_SERVER` variables that can get altered during tests. 5 5 */ 6 function tests_reset_ SERVER() {6 function tests_reset__SERVER() { 7 7 $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; 8 8 $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 9 9 $_SERVER['REQUEST_METHOD'] = 'GET'; 10 $_SERVER['REQUEST_URI'] = ''; 10 11 $_SERVER['SERVER_NAME'] = WP_TESTS_DOMAIN; 11 12 $_SERVER['SERVER_PORT'] = '80'; -
trunk/tests/phpunit/includes/install.php
r36715 r36721 14 14 require_once dirname( __FILE__ ) . '/functions.php'; 15 15 16 tests_reset_ SERVER();16 tests_reset__SERVER(); 17 17 18 18 $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php'; -
trunk/tests/phpunit/includes/testcase.php
r35849 r36721 102 102 $this->reset_taxonomies(); 103 103 $this->reset_post_statuses(); 104 $this->reset__SERVER(); 104 105 105 106 if ( $wp_rewrite->permalink_structure ) { … … 184 185 _unregister_post_status( $post_status ); 185 186 } 187 } 188 189 /** 190 * Reset `$_SERVER` variables 191 */ 192 protected function reset__SERVER() { 193 tests_reset__SERVER(); 186 194 } 187 195 -
trunk/tests/phpunit/tests/multisite/site.php
r35446 r36721 1028 1028 $is_ssl = is_ssl(); 1029 1029 $address = parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ); 1030 1031 unset( $_SERVER['HTTPS'] );1032 1030 1033 1031 $this->assertTrue( $is_ssl ); -
trunk/tests/phpunit/tests/post/attachments.php
r36711 r36721 297 297 $attachment_id = $this->_make_attachment( $upload ); 298 298 299 // Save server data for cleanup.300 $is_ssl = is_ssl();301 299 $_SERVER['HTTPS'] = 'off'; 302 300 303 301 $url = wp_get_attachment_url( $attachment_id ); 304 305 // Cleanup.306 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';307 302 308 303 $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) ); … … 327 322 $attachment_id = $this->_make_attachment( $upload ); 328 323 329 // Save server data for cleanup.330 $is_ssl = is_ssl();331 324 $_SERVER['HTTPS'] = 'off'; 332 325 333 326 $url = wp_get_attachment_url( $attachment_id ); 334 335 // Cleanup.336 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';337 327 338 328 $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) ); … … 357 347 $attachment_id = $this->_make_attachment( $upload ); 358 348 359 // Save server data for cleanup360 $is_ssl = is_ssl();361 $http_host = $_SERVER['HTTP_HOST'];362 363 349 $_SERVER['HTTPS'] = 'on'; 364 350 … … 370 356 $url = wp_get_attachment_url( $attachment_id ); 371 357 372 // Cleanup.373 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';374 $_SERVER['HTTP_HOST'] = $http_host;375 376 358 $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) ); 377 359 } … … 393 375 $attachment_id = $this->_make_attachment( $upload ); 394 376 395 // Save server data for cleanup.396 $is_ssl = is_ssl();397 $http_host = $_SERVER['HTTP_HOST'];398 399 377 $_SERVER['HTTPS'] = 'on'; 400 378 … … 405 383 // Test that wp_get_attachemt_url returns with https scheme. 406 384 $url = wp_get_attachment_url( $attachment_id ); 407 408 // Cleanup.409 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';410 $_SERVER['HTTP_HOST'] = $http_host;411 385 412 386 $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) ); … … 429 403 $attachment_id = $this->_make_attachment( $upload ); 430 404 431 $is_ssl = is_ssl();432 405 $_SERVER['HTTPS'] = 'on'; 433 406 set_current_screen( 'dashboard' ); … … 436 409 437 410 // Cleanup. 438 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';439 411 set_current_screen( 'front' ); 440 412 … … 458 430 $attachment_id = $this->_make_attachment( $upload ); 459 431 460 $is_ssl = is_ssl();461 432 $_SERVER['HTTPS'] = 'on'; 462 433 set_current_screen( 'dashboard' ); … … 465 436 466 437 // Cleanup. 467 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';468 438 set_current_screen( 'front' ); 469 439 remove_filter( 'upload_dir', '_upload_dir_https' ); -
trunk/tests/phpunit/tests/rest-api.php
r35651 r36721 286 286 */ 287 287 public function test_rest_url_scheme() { 288 if ( isset( $_SERVER['HTTPS'] ) ) {289 $_https = $_SERVER['HTTPS'];290 }291 $_name = $_SERVER['SERVER_NAME'];292 288 $_SERVER['SERVER_NAME'] = parse_url( home_url(), PHP_URL_HOST ); 293 289 $_siteurl = get_option( 'siteurl' ); … … 322 318 323 319 // Reset 324 if ( isset( $_https ) ) {325 $_SERVER['HTTPS'] = $_https;326 } else {327 unset( $_SERVER['HTTPS'] );328 }329 $_SERVER['SERVER_NAME'] = $_name;330 320 update_option( 'siteurl', $_siteurl ); 331 321 set_current_screen( 'front' ); -
trunk/tests/phpunit/tests/rewrite.php
r36711 r36721 104 104 105 105 function test_url_to_postid_set_url_scheme_http_to_https() { 106 // Save server data for cleanup107 $is_ssl = is_ssl();108 109 106 $_SERVER['HTTPS'] = 'on'; 110 107 … … 116 113 $page_permalink = get_permalink( $page_id ); 117 114 $page_url_to_id = url_to_postid( set_url_scheme( $page_permalink, 'http' ) ); 118 119 // Cleanup.120 $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';121 115 122 116 $this->assertEquals( $post_id, $post_url_to_id );
Note: See TracChangeset
for help on using the changeset viewer.