WordPress.org

Make WordPress Core

Changeset 34172


Ignore:
Timestamp:
09/15/2015 08:04:33 AM (4 years ago)
Author:
johnbillion
Message:

Initialise $_SERVER[ 'REMOTE_ADDR' ] during the test bootstrap so individual tests need not.

Fixes #33877
Fixes #25162

Location:
trunk/tests/phpunit
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r32785 r34172  
    3939$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
    4040$_SERVER['REQUEST_METHOD'] = 'GET';
     41$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
    4142$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
    4243
  • trunk/tests/phpunit/tests/ajax/ReplytoComment.php

    r31622 r34172  
    3939        $post_id = $this->factory->post->create( array( 'post_status' => 'draft' ) );
    4040        $this->_draft_post = get_post( $post_id );
    41 
    42         $_SERVER['REMOTE_ADDR'] = '';
    4341    }
    4442
  • trunk/tests/phpunit/tests/comment.php

    r33021 r34172  
    7878     */
    7979    public function test_wp_new_comment_respects_dates() {
    80         // `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices.
    81         if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
    82             $remote_addr = $_SERVER['REMOTE_ADDR'];
    83         } else {
    84             $_SERVER['REMOTE_ADDR'] = '';
    85         }
    86 
    8780        $u = $this->factory->user->create();
    8881        $post_id = $this->factory->post->create( array( 'post_author' => $u ) );
     
    10598        $this->assertEquals( $data['comment_date'], $comment->comment_date );
    10699        $this->assertEquals( $data['comment_date_gmt'], $comment->comment_date_gmt );
    107 
    108         // Cleanup.
    109         if ( isset( $remote_addr ) ) {
    110             $_SERVER['REMOTE_ADDR'] = $remote_addr;
    111         } else {
    112             unset( $_SERVER['REMOTE_ADDR'] );
    113         }
    114100    }
    115101
     
    239225
    240226    public function test_comment_field_lengths() {
    241         // `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices.
    242         if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
    243             $remote_addr = $_SERVER['REMOTE_ADDR'];
    244         } else {
    245             $_SERVER['REMOTE_ADDR'] = '';
    246         }
    247 
    248227        $u = $this->factory->user->create();
    249228        $post_id = $this->factory->post->create( array( 'post_author' => $u ) );
     
    265244
    266245        $this->assertEquals( strlen( $comment->comment_content ), 65535 );
    267 
    268         // Cleanup.
    269         if ( isset( $remote_addr ) ) {
    270             $_SERVER['REMOTE_ADDR'] = $remote_addr;
    271         } else {
    272             unset( $_SERVER['REMOTE_ADDR'] );
    273         }
    274246    }
    275247
  • trunk/tests/phpunit/tests/multisite.php

    r32638 r34172  
    1515        parent::setUp();
    1616        $this->suppress = $wpdb->suppress_errors();
    17 
    18         $_SERVER['REMOTE_ADDR'] = '';
    1917    }
    2018
  • trunk/tests/phpunit/tests/multisite/bootstrap.php

    r31623 r34172  
    1616        parent::setUp();
    1717        $this->suppress = $wpdb->suppress_errors();
    18 
    19         $_SERVER[ 'REMOTE_ADDR' ] = '';
    2018    }
    2119
  • trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php

    r31623 r34172  
    1919        parent::setUp();
    2020        $this->suppress = $wpdb->suppress_errors();
    21 
    22         $_SERVER[ 'REMOTE_ADDR' ] = '';
    2321
    2422        update_site_option( 'ms_files_rewriting', 1 );
  • trunk/tests/phpunit/tests/multisite/network.php

    r32775 r34172  
    1717        parent::setUp();
    1818        $this->suppress = $wpdb->suppress_errors();
    19 
    20         $_SERVER[ 'REMOTE_ADDR' ] = '';
    2119    }
    2220
  • trunk/tests/phpunit/tests/option/multisite.php

    r32634 r34172  
    1717        parent::setUp();
    1818        $this->suppress = $wpdb->suppress_errors();
    19 
    20         $_SERVER['REMOTE_ADDR'] = null;
    2119    }
    2220
  • trunk/tests/phpunit/tests/user/multisite.php

    r34034 r34172  
    1717        parent::setUp();
    1818        $this->suppress = $wpdb->suppress_errors();
    19 
    20         $_SERVER[ 'REMOTE_ADDR' ] = '';
    2119    }
    2220
Note: See TracChangeset for help on using the changeset viewer.