Move some assertions in HTTPS related tests, so failures that occur before the environment reset don't result in a contaminated test environment.
See #35954 git-svn-id: https://develop.svn.wordpress.org/trunk@36711 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d30e49fa60
commit
fd8e31e3b2
@ -301,10 +301,11 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
$_SERVER['HTTPS'] = 'off';
|
||||
|
||||
$url = wp_get_attachment_url( $attachment_id );
|
||||
$this->assertSame( set_url_scheme( $url, 'http' ), $url );
|
||||
|
||||
// Cleanup.
|
||||
$_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
|
||||
|
||||
$this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,10 +331,11 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
$_SERVER['HTTPS'] = 'off';
|
||||
|
||||
$url = wp_get_attachment_url( $attachment_id );
|
||||
$this->assertSame( set_url_scheme( $url, 'http' ), $url );
|
||||
|
||||
// Cleanup.
|
||||
$_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
|
||||
|
||||
$this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,17 +362,18 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
|
||||
// Verify that server host matches the host of wp_upload_dir().
|
||||
// Ensure that server host matches the host of wp_upload_dir().
|
||||
$upload_dir = wp_upload_dir();
|
||||
$_SERVER['HTTP_HOST'] = parse_url( $upload_dir['baseurl'], PHP_URL_HOST );
|
||||
|
||||
// Test that wp_get_attachemt_url returns with https scheme.
|
||||
$url = wp_get_attachment_url( $attachment_id );
|
||||
$this->assertSame( set_url_scheme( $url, 'https' ), $url );
|
||||
|
||||
// Cleanup.
|
||||
$_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
|
||||
$_SERVER['HTTP_HOST'] = $http_host;
|
||||
|
||||
$this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,17 +398,18 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
|
||||
// Verify that server host matches the host of wp_upload_dir().
|
||||
// Ensure that server host matches the host of wp_upload_dir().
|
||||
$upload_dir = wp_upload_dir();
|
||||
$_SERVER['HTTP_HOST'] = parse_url( $upload_dir['baseurl'], PHP_URL_HOST );
|
||||
|
||||
// Test that wp_get_attachemt_url returns with https scheme.
|
||||
$url = wp_get_attachment_url( $attachment_id );
|
||||
$this->assertSame( set_url_scheme( $url, 'https' ), $url );
|
||||
|
||||
// Cleanup.
|
||||
$_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
|
||||
$_SERVER['HTTP_HOST'] = $http_host;
|
||||
|
||||
$this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -464,7 +468,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
set_current_screen( 'front' );
|
||||
remove_filter( 'upload_dir', '_upload_dir_https' );
|
||||
|
||||
$this->assertSame( set_url_scheme( $url, 'https' ), $url );
|
||||
$this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
|
||||
}
|
||||
|
||||
public function test_wp_attachment_is() {
|
||||
|
@ -105,21 +105,22 @@ class Tests_Rewrite extends WP_UnitTestCase {
|
||||
function test_url_to_postid_set_url_scheme_http_to_https() {
|
||||
// Save server data for cleanup
|
||||
$is_ssl = is_ssl();
|
||||
$http_host = $_SERVER['HTTP_HOST'];
|
||||
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
|
||||
$post_id = self::factory()->post->create();
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) );
|
||||
$post_id = self::factory()->post->create();
|
||||
$post_permalink = get_permalink( $post_id );
|
||||
$post_url_to_id = url_to_postid( set_url_scheme( $post_permalink, 'http' ) );
|
||||
|
||||
$post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) );
|
||||
$page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
|
||||
$page_permalink = get_permalink( $page_id );
|
||||
$page_url_to_id = url_to_postid( set_url_scheme( $page_permalink, 'http' ) );
|
||||
|
||||
// Cleanup.
|
||||
$_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
|
||||
$_SERVER['HTTP_HOST'] = $http_host;
|
||||
|
||||
$this->assertEquals( $post_id, $post_url_to_id );
|
||||
$this->assertEquals( $page_id, $page_url_to_id );
|
||||
}
|
||||
|
||||
function test_url_to_postid_custom_post_type() {
|
||||
|
Loading…
Reference in New Issue
Block a user