Tests: Use the factory method instead of the property.

This replaces all references to the `WP_UnitTestCase_Base::$factory` property with static function calls to the `WP_UnitTestCase_Base::factory()` method.

This is a consistency improvement for the test suite.

Follow up to [35225], [35242], [49603], [54087], [54088].

Props jrf.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54090 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2022-09-06 22:09:49 +00:00
parent 563e24ced1
commit ff56396bf3
52 changed files with 598 additions and 598 deletions

View File

@@ -205,7 +205,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
// fixture file will be different between runs of PHPUnit tests, which
// is not desirable.
$administrator_id = $this->factory->user->create(
$administrator_id = self::factory()->user->create(
array(
'role' => 'administrator',
'display_name' => 'REST API Client Fixture: User',
@@ -215,7 +215,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
);
wp_set_current_user( $administrator_id );
$post_id = $this->factory->post->create(
$post_id = self::factory()->post->create(
array(
'post_name' => 'restapi-client-fixture-post',
'post_title' => 'REST API Client Fixture: Post',
@@ -243,7 +243,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
)
);
$page_id = $this->factory->post->create(
$page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_name' => 'restapi-client-fixture-page',
@@ -273,7 +273,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
)
);
$tag_id = $this->factory->tag->create(
$tag_id = self::factory()->tag->create(
array(
'name' => 'REST API Client Fixture: Tag',
'slug' => 'restapi-client-fixture-tag',
@@ -281,7 +281,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
)
);
$media_id = $this->factory->attachment->create_object(
$media_id = self::factory()->attachment->create_object(
get_temp_dir() . 'canola.jpg',
0,
array(
@@ -295,7 +295,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
)
);
$comment_id = $this->factory->comment->create(
$comment_id = self::factory()->comment->create(
array(
'comment_approved' => 1,
'comment_post_ID' => $post_id,