WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#36917 closed task (blessed) (fixed)

Re-architect wpdb::init_charset() for unit testing

Reported by: pento Owned by: pento
Milestone: 4.6 Priority: normal
Severity: minor Version:
Component: Database Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

The behaviour of wpdb::init_charset() is becoming more complex, but due to the dependence on defines for passing data, instead of parameters, it's not possible to test that behaviour.

By splitting up the logic, we can add testing for this method.

See [37522].

Attachments (1)

36917.diff (3.1 KB) - added by pento 2 years ago.

Download all attachments as: .zip

Change History (4)

@pento
2 years ago

#1 @pento
2 years ago

  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Future Release to 4.6

First pass.

#2 @pento
2 years ago

  • Owner set to pento
  • Resolution set to fixed
  • Status changed from new to closed

In 37601:

Database: Split the logic of wpdb::init_charset() into a separate method.

The logic for determining the appropriate character set and collation to use is becoming more complex, particularly with the recent additions of [37522] and [37523]. As init_charset() has side effects, and makes use of constants instead of parameters, it's not possible to unit test this logic.

This commit splits the logic part of init_charset() out into a new method, wpdb::determine_charset(), along with appropriate unit tests.

See #32105, #37522.

Fixes #36917.

#3 @pento
2 years ago

In 37602:

Tests: Fix an incorrect @ticket header introduced in [37601].

See #32405, #36917.

Note: See TracTickets for help on using tickets.