diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index a9627c4c47..e74b618691 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -38,6 +38,7 @@ define( 'WP_MAX_MEMORY_LIMIT', -1 ); $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; $_SERVER['REQUEST_METHOD'] = 'GET'; +$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php'; if ( "1" == getenv( 'WP_MULTISITE' ) || diff --git a/tests/phpunit/tests/ajax/ReplytoComment.php b/tests/phpunit/tests/ajax/ReplytoComment.php index 9e07051c5d..4d07720c89 100644 --- a/tests/phpunit/tests/ajax/ReplytoComment.php +++ b/tests/phpunit/tests/ajax/ReplytoComment.php @@ -38,8 +38,6 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { $post_id = $this->factory->post->create( array( 'post_status' => 'draft' ) ); $this->_draft_post = get_post( $post_id ); - - $_SERVER['REMOTE_ADDR'] = ''; } public function tearDown() { diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index 8bc64b740b..3d854755f7 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -77,13 +77,6 @@ class Tests_Comment extends WP_UnitTestCase { * @ticket 14279 */ public function test_wp_new_comment_respects_dates() { - // `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices. - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { - $remote_addr = $_SERVER['REMOTE_ADDR']; - } else { - $_SERVER['REMOTE_ADDR'] = ''; - } - $u = $this->factory->user->create(); $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); @@ -104,13 +97,6 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertEquals( $data['comment_date'], $comment->comment_date ); $this->assertEquals( $data['comment_date_gmt'], $comment->comment_date_gmt ); - - // Cleanup. - if ( isset( $remote_addr ) ) { - $_SERVER['REMOTE_ADDR'] = $remote_addr; - } else { - unset( $_SERVER['REMOTE_ADDR'] ); - } } /** @@ -238,13 +224,6 @@ class Tests_Comment extends WP_UnitTestCase { public function test_comment_field_lengths() { - // `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices. - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { - $remote_addr = $_SERVER['REMOTE_ADDR']; - } else { - $_SERVER['REMOTE_ADDR'] = ''; - } - $u = $this->factory->user->create(); $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); @@ -264,13 +243,6 @@ class Tests_Comment extends WP_UnitTestCase { $comment = get_comment( $id ); $this->assertEquals( strlen( $comment->comment_content ), 65535 ); - - // Cleanup. - if ( isset( $remote_addr ) ) { - $_SERVER['REMOTE_ADDR'] = $remote_addr; - } else { - unset( $_SERVER['REMOTE_ADDR'] ); - } } /** diff --git a/tests/phpunit/tests/multisite.php b/tests/phpunit/tests/multisite.php index e93edbcbe5..f6857d1c32 100644 --- a/tests/phpunit/tests/multisite.php +++ b/tests/phpunit/tests/multisite.php @@ -14,8 +14,6 @@ class Tests_Multisite extends WP_UnitTestCase { global $wpdb; parent::setUp(); $this->suppress = $wpdb->suppress_errors(); - - $_SERVER['REMOTE_ADDR'] = ''; } function tearDown() { diff --git a/tests/phpunit/tests/multisite/bootstrap.php b/tests/phpunit/tests/multisite/bootstrap.php index 294230d43e..9daa024425 100644 --- a/tests/phpunit/tests/multisite/bootstrap.php +++ b/tests/phpunit/tests/multisite/bootstrap.php @@ -15,8 +15,6 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase { global $wpdb; parent::setUp(); $this->suppress = $wpdb->suppress_errors(); - - $_SERVER[ 'REMOTE_ADDR' ] = ''; } function tearDown() { diff --git a/tests/phpunit/tests/multisite/ms-files-rewriting.php b/tests/phpunit/tests/multisite/ms-files-rewriting.php index 91b0f8268b..ab2877bafd 100644 --- a/tests/phpunit/tests/multisite/ms-files-rewriting.php +++ b/tests/phpunit/tests/multisite/ms-files-rewriting.php @@ -19,8 +19,6 @@ class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { parent::setUp(); $this->suppress = $wpdb->suppress_errors(); - $_SERVER[ 'REMOTE_ADDR' ] = ''; - update_site_option( 'ms_files_rewriting', 1 ); ms_upload_constants(); } diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index 70a4a0dbeb..4e0d34a85e 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -16,8 +16,6 @@ class Tests_Multisite_Network extends WP_UnitTestCase { global $wpdb; parent::setUp(); $this->suppress = $wpdb->suppress_errors(); - - $_SERVER[ 'REMOTE_ADDR' ] = ''; } function tearDown() { diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index d5053d23e9..9f82d84b3c 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -16,8 +16,6 @@ class Tests_Multisite_Option extends WP_UnitTestCase { global $wpdb; parent::setUp(); $this->suppress = $wpdb->suppress_errors(); - - $_SERVER['REMOTE_ADDR'] = null; } function tearDown() { diff --git a/tests/phpunit/tests/user/multisite.php b/tests/phpunit/tests/user/multisite.php index 67a8593ad6..35b3738fe4 100644 --- a/tests/phpunit/tests/user/multisite.php +++ b/tests/phpunit/tests/user/multisite.php @@ -16,8 +16,6 @@ class Tests_Multisite_User extends WP_UnitTestCase { global $wpdb; parent::setUp(); $this->suppress = $wpdb->suppress_errors(); - - $_SERVER[ 'REMOTE_ADDR' ] = ''; } function tearDown() {