diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 3b8fd57f83..42c6f4accd 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -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() { diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 32c8f863a3..92f1564e0b 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -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() {