Opened 8 years ago
Closed 8 years ago
#7703 closed defect (bug) (fixed)
Unit tests: Run `'bp_template_redirect'` hook in `go_to()` method
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | 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.
Sorry @netweb! BP Trac auto-assigned you to this issue because you're the Build/Test Tools maintainer.