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

This allows third-party plugins 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@57149 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2023-12-02 11:56:31 +00:00
parent 0ce733c78f
commit 76ab1b8891

View File

@ -72,7 +72,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
$class = get_called_class();
if ( method_exists( $class, 'wpSetUpBeforeClass' ) ) {
call_user_func( array( $class, 'wpSetUpBeforeClass' ), self::factory() );
call_user_func( array( $class, 'wpSetUpBeforeClass' ), static::factory() );
}
self::commit_transaction();
@ -102,7 +102,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
public function set_up() {
set_time_limit( 0 );
$this->factory = self::factory();
$this->factory = static::factory();
if ( ! self::$ignore_files ) {
self::$ignore_files = $this->scan_user_uploads();