Opened 22 months ago
Last modified 22 months ago
#22 new enhancement
get_template_part() tests
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Capabilities | Keywords: | |
| Cc: | aaroncampbell |
Description
I'm going to try to add some test for get_template_part() as part of #wp15086. The problem is that get_template_part() uses locate_template() which relies on STYLESHEETPATH and TEMPLATEPATH. I'm a little unfamiliar still with the way the test suite works, but I didn't see any obvious way to hook in and tell it to use a different theme.
The problem is that before wp-test.php includes wp-settings.php add_(filter|action) don't exist, and after wp-settings.php has been included (by the time the test-suite plugins are loaded for example) the constants have already been defined. What we really need in this case is an actual active plugin in the actual WordPress? plugins directory, because this is included between the time when actions and filters exist and when they are used to set the constants we need to change.
Do you guys have a way in place for getting around this that I'm not seeing?
Change History (3)
comment:1
aaroncampbell — 22 months ago
- Cc aaroncampbell added
comment:3
aaroncampbell — 22 months ago
Again per our discussion in IRC, switch_theme doesn't work because locate_template uses the constants (STYLESHEETPATH and TEMPLATEPATH). See #WP18298

As mentioned in IRC you can just switch_theme inside the test like here: http://unit-tests.trac.wordpress.org/browser/wp-testcase/test_admin_includes_theme.php#L30