Opened 9 years ago
Closed 9 years ago
#7703 closed defect (bug) (fixed)
Unit tests: Run `'bp_template_redirect'` hook in `go_to()` method
| Reported by: | r-a-y | Owned by: | r-a-y |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: |
Description
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Sorry @netweb! BP Trac auto-assigned you to this issue because you're the Build/Test Tools maintainer.