mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Unify the initialisation of $_SERVER variables during test bootstrap. This abstracts the (re-)initialisation into a function that can be used inside of tests too, before assertions are performed.
See #35954 git-svn-id: https://develop.svn.wordpress.org/trunk@36715 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1,5 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Resets various `$_SERVER` variables that can get altered during tests.
|
||||
*/
|
||||
function tests_reset_SERVER() {
|
||||
$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['SERVER_NAME'] = WP_TESTS_DOMAIN;
|
||||
$_SERVER['SERVER_PORT'] = '80';
|
||||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
||||
|
||||
unset( $_SERVER['HTTP_REFERER'] );
|
||||
unset( $_SERVER['HTTPS'] );
|
||||
}
|
||||
|
||||
// For adding hooks before loading WP
|
||||
function tests_add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
|
||||
global $wp_filter, $merged_filters;
|
||||
|
||||
Reference in New Issue
Block a user