Make WordPress Core

Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#59881 closed defect (bug) (fixed)

Incorrect check for block theme in legacy PHPUnit test

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile 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 via wp_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

The check for whether a theme shouldn't be covered in the old test_switch_theme() method may be inaccurate because:

  • The block-templates theme support for block themes is added dynamically via wp_enable_block_templates(), so checking for that isn't reliable.
  • The conditions used in wp_enable_block_templates() should be used instead.

Related to #5634.

Trac ticket: https://core.trac.wordpress.org/ticket/59881

#2 @flixos90
11 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 57104:

Tests: Fix incorrect check for block themes in legacy PHPUnit test for themes.

Props mukesh27.
Fixes #59881.

Note: See TracTickets for help on using tickets.