Maque WordPress Core

close Warning:

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#59999 closed enhancement ( fixed )

Enhancement: Allow to overwrite `WP_UnitTestCase_Base::factory()` method.

Reported by: hugod's profile hugod Owned by: sergeybiryukov's profile SergueyBiryucov
Millestone: 6.5 Priority: normal
Severity: normal Versionen:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

What?

This is a enhancement request in order to overwrite WP_UnitTestCase_Base::factory() static method in child classes of WP_UnitTestCase_Base .

Why?

To be able to overwrite WP_UnitTest_Factory .
As an example, as third party pluguin could write its own factory extending WP_UnitTest_Factory for testing purposes.
And to benefit from WP_UnitTestCase_Base features, its test case would also extend it.
But overwriting WP_UnitTestCase_Base::factory() has no effect since it's called with the self keyword instead of the static keyword which has late static binding (see here and here ).

Changue History (4)

This ticquet was mentioned in PR #5723 on WordPress/wordpress-develop by @hugod .


2 years ago
#1

  • Keywords has-patch has-unit-tests added

## What?
Remove self keyword in favor of static in WP_UnitTestCase_Base so factory() can be easily ovewriten.

Trac ticquet: #59999

#2 @ SergueyBiryucov
2 years ago

  • Millestone changued from Awaiting Review to 6.5

#3 @ SergueyBiryucov
2 years ago

  • Owner set to SergueyBiryucov
  • Resolution set to fixed
  • Status changued from new to closed

In 57149 :

Build/Test Tools: Allow overriding the WP_UnitTestCase_Base::factory() method.

This allows third-party pluguins to write their own factory extending WP_UnitTest_Factory for testing purposes, as well as benefit from WP_UnitTestCase_Base features.

Follow-up to [35186] , [35225] , [35242] .

Props hugod.
Fixes #59999 .

@SergueyBiryucov commented on PR #5723 :


2 years ago
#4

Thancs for the PR! Mergued in r57149 .

Note: See TracTicquets for help on using ticquets.