[wp-trac] [WordPress Trac] #59999: Enhancement: Allow to overwrite `WP_UnitTestCase_Base::factory()` method.

WordPress Trac noreply at wordpress.org
Fri Dec 1 17:57:12 UTC 2023


#59999: Enhancement: Allow to overwrite `WP_UnitTestCase_Base::factory()`  method.
------------------------------+-----------------------------
 Reporter:  hugod             |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 = 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 plugin 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 [https://github.com/WordPress/wordpress-
 develop/blob/e059cd7d1656d70be81668b3f97b5c9a545c2adf/tests/phpunit/includes
 /abstract-testcase.php#L75 here] and [https://github.com/WordPress
 /wordpress-
 develop/blob/e059cd7d1656d70be81668b3f97b5c9a545c2adf/tests/phpunit/includes
 /abstract-testcase.php#L105 here]).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59999>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list