[buddypress-trac] [BuddyPress Trac] #7703: Unit tests: Run `'bp_template_redirect'` hook in `go_to()` method

buddypress-trac noreply at wordpress.org
Sat Feb 24 21:21:47 UTC 2018


#7703: Unit tests: Run `'bp_template_redirect'` hook in `go_to()` method
------------------------------+-----------------------
 Reporter:  r-a-y             |      Owner:  netweb
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  3.0
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:  has-patch
------------------------------+-----------------------
 While looking at conditional loading in #7218, I ran into some issues with
 how we use the `go_to()` method to mock a visit to a page in PHPUnit.

 In the `go_to()` method, we only run `'bp_init'`, which gets us halfway
 there.  We also need to run `'bp_template_redirect'` so hooks running on
 `'bp_actions'` or `'bp_screens'` can also run.

 I'm guessing the issue why we never ran `'bp_template_redirect'` is due to
 the use of `wp_redirect()`, which causes "headers are already sent"
 notices when running PHPUnit.

 Attached patch alters `bp_core_redirect()` to only redirect if PHPUnit
 isn't running.

 This also allows us to remove some hacky attempts at running certain hooks
 in our tests, most notably in `@group mentions`.  This was the main
 problem that led me to fix this!

 Let me know if you have any questions.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7703>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list