Make WordPress Core


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

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

Fixes #33877
Fixes #25162

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.