Make WordPress Core

Opened 3 years ago

Closed 4 months ago

#58006 closed enhancement (duplicate)

Final classes & testing

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

Description

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 (2)

#1 @costdev
3 years 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?

#2 @johnjamesjacoby
4 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #24672.

Note: See TracTickets for help on using tickets.