Make WordPress Core

Changeset 35350


Ignore:
Timestamp:
10/21/2015 11:51:45 PM (9 years ago)
Author:
johnbillion
Message:

Initialise $_SERVER['SERVER_NAME'] during the test bootstrap to avoid individual tests having to do it.

Fixes #34394

Location:
trunk/tests/phpunit
Files:
6 edited

Legend:

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

    r34928 r35350  
    3838$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
    3939$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
     40$_SERVER['SERVER_NAME'] = WP_TESTS_DOMAIN;
    4041$_SERVER['REQUEST_METHOD'] = 'GET';
    4142$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     43
    4244$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
    4345
  • trunk/tests/phpunit/includes/install.php

    r32785 r35350  
    1616$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
    1717$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
     18$_SERVER['SERVER_NAME'] = WP_TESTS_DOMAIN;
    1819$_SERVER['REQUEST_METHOD'] = 'GET';
     20$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     21
    1922$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
    2023
  • trunk/tests/phpunit/includes/testcase.php

    r35309 r35350  
    111111        $this->expectDeprecated();
    112112        add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
    113 
    114         add_filter( 'wp_mail', array( $this, 'set_wp_mail_globals' ) );
    115113    }
    116114
     
    670668
    671669    /**
    672      * When `wp_mail()` is called, make sure `$_SERVER['SERVER_NAME']` is faked.
    673      *
    674      * @since 4.3.0
    675      *
    676      * @param array $args `wp_mail()` arguments.
    677      * @return array $args
    678      */
    679     public function set_wp_mail_globals( $args ) {
    680         if ( ! isset( $_SERVER['SERVER_NAME'] ) ) {
    681             $_SERVER['SERVER_NAME'] = 'example.com';
    682             add_action( 'phpmailer_init', array( $this, 'tear_down_wp_mail_globals' ) );
    683         }
    684 
    685         return $args;
    686     }
    687 
    688     /**
    689      * Tear down the faked `$_SERVER['SERVER_NAME']` global used in `wp_mail()`.
    690      *
    691      * @since 4.3.0
    692      */
    693     public function tear_down_wp_mail_globals() {
    694         unset( $_SERVER['SERVER_NAME'] );
    695     }
    696 
    697     /**
    698670     * Multisite-agnostic way to delete a user from the database.
    699671     *
  • trunk/tests/phpunit/tests/comment.php

    r35347 r35350  
    381381    public function setup_notify_comment(){
    382382        /**
    383          * Mock some server variables.
    384          */
    385         $_SERVER['SERVER_NAME'] = 'phpunit.wordpress.dev';
    386         $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
    387 
    388         /**
    389383         * Prevent flood alert from firing.
    390384         */
  • trunk/tests/phpunit/tests/mail.php

    r35347 r35350  
    189189        $message  = "Test Message";
    190190        $headers  = "From: ";
    191         $expected = "From: WordPress <wordpress@example.com>";
     191        $expected = "From: WordPress <wordpress@" . WP_TESTS_DOMAIN . ">";
    192192
    193193        wp_mail( $to, $subject, $message, $headers );
  • trunk/tests/phpunit/wp-mail-real-test.php

    r25165 r35350  
    7373$headers[] = "CC: {$cc}";
    7474
    75 $_SERVER['SERVER_NAME'] = 'example.com';
    7675wp_mail( $to, $subject, $message, $headers );
    7776
Note: See TracChangeset for help on using the changeset viewer.