mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Initialise $_SERVER[ 'REMOTE_ADDR' ] during the test bootstrap so individual tests need not.
Fixes #33877 Fixes #25162 git-svn-id: https://develop.svn.wordpress.org/trunk@34172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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' ) ||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,8 +14,6 @@ class Tests_Multisite extends WP_UnitTestCase {
|
||||
global $wpdb;
|
||||
parent::setUp();
|
||||
$this->suppress = $wpdb->suppress_errors();
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '';
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user