Make WordPress Core


Ignore:
Timestamp:
02/26/2016 02:08:47 AM (8 years ago)
Author:
johnbillion
Message:

Remove (or at least reduce) the need to reset common $_SERVER variables before assertions or between tests, by introducing a method which automatically resets them during test setup.

See #35954

File:
1 edited

Legend:

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

    r36711 r36721  
    297297        $attachment_id = $this->_make_attachment( $upload );
    298298
    299         // Save server data for cleanup.
    300         $is_ssl = is_ssl();
    301299        $_SERVER['HTTPS'] = 'off';
    302300
    303301        $url = wp_get_attachment_url( $attachment_id );
    304 
    305         // Cleanup.
    306         $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    307302
    308303        $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );
     
    327322        $attachment_id = $this->_make_attachment( $upload );
    328323
    329         // Save server data for cleanup.
    330         $is_ssl = is_ssl();
    331324        $_SERVER['HTTPS'] = 'off';
    332325
    333326        $url = wp_get_attachment_url( $attachment_id );
    334 
    335         // Cleanup.
    336         $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    337327
    338328        $this->assertSame( 'http', parse_url( $url, PHP_URL_SCHEME ) );
     
    357347        $attachment_id = $this->_make_attachment( $upload );
    358348
    359         // Save server data for cleanup
    360         $is_ssl = is_ssl();
    361         $http_host = $_SERVER['HTTP_HOST'];
    362 
    363349        $_SERVER['HTTPS'] = 'on';
    364350
     
    370356        $url = wp_get_attachment_url( $attachment_id );
    371357
    372         // Cleanup.
    373         $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    374         $_SERVER['HTTP_HOST'] = $http_host;
    375 
    376358        $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
    377359    }
     
    393375        $attachment_id = $this->_make_attachment( $upload );
    394376
    395         // Save server data for cleanup.
    396         $is_ssl = is_ssl();
    397         $http_host = $_SERVER['HTTP_HOST'];
    398 
    399377        $_SERVER['HTTPS'] = 'on';
    400378
     
    405383        // Test that wp_get_attachemt_url returns with https scheme.
    406384        $url = wp_get_attachment_url( $attachment_id );
    407 
    408         // Cleanup.
    409         $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    410         $_SERVER['HTTP_HOST'] = $http_host;
    411385
    412386        $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) );
     
    429403        $attachment_id = $this->_make_attachment( $upload );
    430404
    431         $is_ssl = is_ssl();
    432405        $_SERVER['HTTPS'] = 'on';
    433406        set_current_screen( 'dashboard' );
     
    436409
    437410        // Cleanup.
    438         $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    439411        set_current_screen( 'front' );
    440412
     
    458430        $attachment_id = $this->_make_attachment( $upload );
    459431
    460         $is_ssl = is_ssl();
    461432        $_SERVER['HTTPS'] = 'on';
    462433        set_current_screen( 'dashboard' );
     
    465436
    466437        // Cleanup.
    467         $_SERVER['HTTPS'] = $is_ssl ? 'on' : 'off';
    468438        set_current_screen( 'front' );
    469439        remove_filter( 'upload_dir', '_upload_dir_https' );
Note: See TracChangeset for help on using the changeset viewer.