WordPress.org

Make WordPress Core

Changeset 36711


Ignore:
Timestamp:
02/25/2016 09:17:34 PM (6 years ago)
Author:
johnbillion
Message:

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

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/attachments.php

    r36565 r36711  
    302302
    303303        $url = wp_get_attachment_url( $attachment_id );
    304         $this->assertSame( set_url_scheme( $url, 'http' ), $url );
    305304
    306305        // Cleanup.
    307306        $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
     307
     308        $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );
    308309    }
    309310
     
    331332
    332333        $url = wp_get_attachment_url( $attachment_id );
    333         $this->assertSame( set_url_scheme( $url, 'http' ), $url );
    334334
    335335        // Cleanup.
    336336        $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
     337
     338        $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );
    337339    }
    338340
     
    361363        $_SERVER['HTTPS'] = 'on';
    362364
    363         // Verify that server host matches the host of wp_upload_dir().
     365        // Ensure that server host matches the host of wp_upload_dir().
    364366        $upload_dir = wp_upload_dir();
    365367        $_SERVER['HTTP_HOST'] = parse_url( $upload_dir['baseurl'], PHP_URL_HOST );
     
    367369        // Test that wp_get_attachemt_url returns with https scheme.
    368370        $url = wp_get_attachment_url( $attachment_id );
    369         $this->assertSame( set_url_scheme( $url, 'https' ), $url );
    370371
    371372        // Cleanup.
    372373        $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    373374        $_SERVER['HTTP_HOST'] = $http_host;
     375
     376        $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
    374377    }
    375378
     
    396399        $_SERVER['HTTPS'] = 'on';
    397400
    398         // Verify that server host matches the host of wp_upload_dir().
     401        // Ensure that server host matches the host of wp_upload_dir().
    399402        $upload_dir = wp_upload_dir();
    400403        $_SERVER['HTTP_HOST'] = parse_url( $upload_dir['baseurl'], PHP_URL_HOST );
     
    402405        // Test that wp_get_attachemt_url returns with https scheme.
    403406        $url = wp_get_attachment_url( $attachment_id );
    404         $this->assertSame( set_url_scheme( $url, 'https' ), $url );
    405407
    406408        // Cleanup.
    407409        $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    408410        $_SERVER['HTTP_HOST'] = $http_host;
     411
     412        $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
    409413    }
    410414
     
    465469        remove_filter( 'upload_dir', '_upload_dir_https' );
    466470
    467         $this->assertSame( set_url_scheme( $url, 'https' ), $url );
     471        $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
    468472    }
    469473
  • trunk/tests/phpunit/tests/rewrite.php

    r36307 r36711  
    106106        // Save server data for cleanup
    107107        $is_ssl = is_ssl();
    108         $http_host = $_SERVER['HTTP_HOST'];
    109108
    110109        $_SERVER['HTTPS'] = 'on';
    111110
    112         $post_id = self::factory()->post->create();
    113         $permalink = get_permalink( $post_id );
    114         $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) );
    115 
    116         $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    117         $permalink = get_permalink( $post_id );
    118         $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) );
     111        $post_id        = self::factory()->post->create();
     112        $post_permalink = get_permalink( $post_id );
     113        $post_url_to_id = url_to_postid( set_url_scheme( $post_permalink, 'http' ) );
     114
     115        $page_id        = self::factory()->post->create( array( 'post_type' => 'page' ) );
     116        $page_permalink = get_permalink( $page_id );
     117        $page_url_to_id = url_to_postid( set_url_scheme( $page_permalink, 'http' ) );
    119118
    120119        // Cleanup.
    121120        $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    122         $_SERVER['HTTP_HOST'] = $http_host;
     121
     122        $this->assertEquals( $post_id, $post_url_to_id );
     123        $this->assertEquals( $page_id, $page_url_to_id );
    123124    }
    124125
Note: See TracChangeset for help on using the changeset viewer.