#59881 closed defect (bug) (fixed)
Incorrect check for block theme in legacy PHPUnit test
Reported by: | flixos90 | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.5 |
Component: | Build/Test Tools | Keywords: | has-unit-tests has-patch |
Focuses: | Cc: |
Description
The very old test_switch_theme()
recently required updates, and at the same time was updated to not cover block themes, as the test is overly complex and not up to date with how PHPUnit tests should be written as of today. Still, simply removing is probably not a good idea. Ideally it could be refactored, but that's also a very low hanging fruit.
In any case, it was recently noticed that the test unintentionally was still covering block themes in certain conditions, due to a bug in the condition. Here's the problem and solution:
- The
block-templates
theme support for block themes is added dynamically viawp_enable_block_templates()
, so checking for that isn't reliable. - The conditions used in
wp_enable_block_templates()
should be used instead.
Change History (3)
This ticket was mentioned in PR #5650 on WordPress/wordpress-develop by @flixos90.
11 months ago
#1
@flixos90 commented on PR #5650:
11 months ago
#3
Committed in https://core.trac.wordpress.org/changeset/57104
Note: See
TracTickets for help on using
tickets.
The check for whether a theme shouldn't be covered in the old
test_switch_theme()
method may be inaccurate because:block-templates
theme support for block themes is added dynamically viawp_enable_block_templates()
, so checking for that isn't reliable.wp_enable_block_templates()
should be used instead.Related to #5634.
Trac ticket: https://core.trac.wordpress.org/ticket/59881