Make WordPress Core


Ignore:
Timestamp:
02/25/2016 09:59:56 PM (9 years ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/functions.php

    r36565 r36715  
    11<?php
     2
     3/**
     4 * Resets various `$_SERVER` variables that can get altered during tests.
     5 */
     6function tests_reset_SERVER() {
     7    $_SERVER['HTTP_HOST']       = WP_TESTS_DOMAIN;
     8    $_SERVER['REMOTE_ADDR']     = '127.0.0.1';
     9    $_SERVER['REQUEST_METHOD']  = 'GET';
     10    $_SERVER['SERVER_NAME']     = WP_TESTS_DOMAIN;
     11    $_SERVER['SERVER_PORT']     = '80';
     12    $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
     13
     14    unset( $_SERVER['HTTP_REFERER'] );
     15    unset( $_SERVER['HTTPS'] );
     16}
    217
    318// For adding hooks before loading WP
Note: See TracChangeset for help on using the changeset viewer.