Make WordPress Core

Opened 3 years ago

Closed 14 months ago

#58006 closed enhancement (duplicate)

Final classes & testing

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

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

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
14 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed

Duplicate of #24672.

Note: See TracTickets for help on using tickets.