Make WordPress Core

Opened 16 months ago

Last modified 16 months ago

#58006 new enhancement

Final classes & testing

Reported by: neblabs's profile neblabs Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: reporter-feedback
Focuses: coding-standards Cc:


Sorry if this is not the place to post.

All (or most AFAIK) WordPress classes WP_* are declared final.

This is an issue when unit testing since final classes can't be mocked so unit testing a class that relies on a WP_Post instance is hard.

If I may ask, is there a reason why these classes are final? Have there been any talks to make them non-final, at least in the official testing environment that uses phpunit?

Change History (1)

#1 @costdev
16 months ago

  • Keywords reporter-feedback added
  • Version 6.1.1 deleted

Hi @neblabs, welcome to Trac!

Can you provide some detail on what you're trying to do?

  • Are you writing tests for Core, or for a plugin/theme?
  • What are you testing?
  • Why is mocking required for this test?
Note: See TracTickets for help on using tickets.