WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 23 months ago

#22 new enhancement

get_template_part() tests

Reported by: aaroncampbell 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 aaroncampbell23 months ago

  • Cc aaroncampbell added

comment:2 westi23 months ago

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

comment:3 aaroncampbell23 months ago

Again per our discussion in IRC, switch_theme doesn't work because locate_template uses the constants (STYLESHEETPATH and TEMPLATEPATH). See #WP18298

Note: See TracTickets for help on using tickets.