Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/04/2018 09:35:46 PM (8 years ago)
Author:
r-a-y
Message:

Unit Tests: Run 'bp_template_redirect' hook in go_to() method.

In PHPUnit, we mock page visits with the go_to() method, however we
previously only ran the 'bp_init' hook, which sets up various internal
page routing properties, but doesn't run any screen hooks.

This commit adds the 'bp_template_redirect' hook to the go_to() method,
which allows hooks like 'bp_actions' and 'bp_screens' to run. In order
for those hooks to run without errors in PHPUnit, we need to adjust our
bp_core_redirect() function so it doesn't kill execution. Also, for
PHPUnit, we do not allow redirects to occur since they cause 'headers
already sent' notices.

Lastly, we can adjust some unit tests to just use the go_to() method,
instead of needing to manually call a screen hook.

Fixes #7703.

File:
1 edited

Legend:

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

    r10470 r11882  
    99require dirname( __FILE__ ) . '/../../../src/bp-loader.php';
    1010
     11// Bail from redirects as they throw 'headers already sent' warnings.
     12tests_add_filter( 'wp_redirect', '__return_false' );
     13
    1114require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
    1215function _bp_mock_mailer( $class ) {
Note: See TracChangeset for help on using the changeset viewer.