#29925 closed defect (bug) (fixed)
Setting WP_DEFAULT_THEME to a custom theme causes test to fail
Reported by: | mboynes | Owned by: | jorbin |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | |
Focuses: | Cc: |
Description
Today I ran core's unit tests with Underscores active and the following test failed:
There was 1 failure: 1) Tests_Theme::test_default_themes_have_textdomain Failed asserting that an array contains '_s'. /var/www/wordpress-develop/tests/phpunit/tests/theme.php:166
This test is directly asserting that WP_DEFAULT_THEME
is one of the included themes. I see no reason for this, especially in this test which offers no reference to WP_DEFAULT_THEME
and is checking that the default themes have a textdomain.
Attachments (2)
Change History (10)
#1
@
10 years ago
So, it is there for a reason, believe it or not. I think I wrote this one.
When we add a new theme, we update WP_DEFAULT_THEME. This isn't something we'll forget. But it's very possible that we'll forget to update the $default_themes property of the Tests_Theme class. That's why this assertion is there.
I'm generally not against adjusting poor assumptions in our unit tests, but we also can't make a guarantee that they'll always pass when the default environment is changed.
#2
@
10 years ago
Thanks for the insight @nacin!
What if we added a filter to $this->default_themes
?
I think there's a good use case for allowing someone to test their theme against the full suite of core unit tests, to ensure that customizations in the theme don't break core features. I'm open to other solutions to help accomplish that end goal.
#3
@
10 years ago
I think we could break this into a separate test, and only do the assertion if WP_DEFAULT_THEME starts with "twenty*", and otherwise skip the test.
#4
@
10 years ago
- Milestone changed from Awaiting Review to 4.1
- Owner set to jorbin
- Status changed from new to assigned
Nacin's suggestion seems like the right fix for this situation.
Remove assertion that WP_DEFAULT_THEME is one of the provided themes