Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2013 05:49:35 PM (12 years ago)
Author:
boonebgorges
Message:

Fake some critical globals when running unit tests that touch wp_mail()

The wp_mail() function requires access to $_SERVERSERVER_NAME?, which is
not available when running the unit tests. We follow the WordPress core test
suite, by faking this value during automated testing.

Note that the long-term solution to this issue should be to break notification
functionality out of the wrapper functions that are used to request friendship,
etc. The current fix is something of an ugly workaround, just to get the tests
running properly when using E_STRICT.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/includes/testcase.php

    r7493 r7497  
    301301        $this->go_to( str_replace( $blog_1_url, '', trailingslashit( bp_get_root_domain() ) ) );
    302302    }
     303
     304    /**
     305     * Set up globals necessary to avoid errors when using wp_mail()
     306     */
     307    public function setUp_wp_mail() {
     308        $_SERVER['SERVER_NAME'] = 'example.com';
     309    }
     310
     311    /**
     312     * Tear down globals set up in setUp_wp_mail()
     313     */
     314    public function tearDown_wp_mail() {
     315        unset( $_SERVER['SERVER_NAME'] );
     316    }
    303317}
Note: See TracChangeset for help on using the changeset viewer.