Changeset 35344 for trunk/tests/phpunit/tests/rest-api.php
- Timestamp:
- 10/21/2015 10:06:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api.php
r35342 r35344 255 255 } 256 256 257 /**258 * @ticket 34299259 */260 public function test_rest_url_scheme() {261 if ( isset( $_SERVER['HTTPS'] ) ) {262 $_https = $_SERVER['HTTPS'];263 }264 if ( isset( $_SERVER['SERVER_NAME'] ) ) {265 $_name = $_SERVER['SERVER_NAME'];266 }267 $_SERVER['SERVER_NAME'] = parse_url( home_url(), PHP_URL_HOST );268 $_siteurl = get_option( 'siteurl' );269 270 // Test an HTTP URL271 unset( $_SERVER['HTTPS'] );272 $url = get_rest_url();273 $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );274 275 // Test an HTTPS URL276 $_SERVER['HTTPS'] = 'on';277 $url = get_rest_url();278 $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );279 280 // Switch to an admin request on a different domain name281 $_SERVER['SERVER_NAME'] = 'admin.example.org';282 update_option( 'siteurl', 'http://admin.example.org' );283 $this->assertNotEquals( $_SERVER['SERVER_NAME'], parse_url( home_url(), PHP_URL_HOST ) );284 285 set_current_screen( 'edit.php' );286 $this->assertTrue( is_admin() );287 288 // Test an HTTP URL289 unset( $_SERVER['HTTPS'] );290 $url = get_rest_url();291 $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );292 293 // Test an HTTPS URL294 $_SERVER['HTTPS'] = 'on';295 $url = get_rest_url();296 $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );297 298 // Reset299 if ( isset( $_https ) ) {300 $_SERVER['HTTPS'] = $_https;301 } else {302 unset( $_SERVER['HTTPS'] );303 }304 if ( isset( $_name ) ) {305 $_SERVER['SERVER_NAME'] = $_name;306 } else {307 unset( $_SERVER['SERVER_NAME'] );308 }309 update_option( 'siteurl', $_siteurl );310 set_current_screen( 'front' );311 312 }313 314 257 }
Note: See TracChangeset
for help on using the changeset viewer.