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:
John Blackbourn
2015-09-15 08:04:33 +00:00
parent c95d6b3ec8
commit c29412abf9
9 changed files with 1 additions and 42 deletions

View File

@@ -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'] );
}
}
/**