Skip to content

Commit ba72c37

Browse files
authored
Update test factory usage to static method calls (#2565)
1 parent 1932704 commit ba72c37

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

tests/phpunit/tests/includes/class-test-search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Test_Search extends \WP_UnitTestCase {
1818
*/
1919
public function test_regular_search_unchanged() {
2020
// Create a test post.
21-
$post_id = $this->factory->post->create(
21+
$post_id = self::factory()->post->create(
2222
array(
2323
'post_title' => 'Test Post About Cats',
2424
'post_content' => 'This is a test post about cats and dogs.',

tests/phpunit/tests/includes/handler/class-test-accept.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function test_handle_accept_moves_user_from_pending_to_following() {
122122
$object_guid = 'https://example.com/actor/123';
123123
$outbox_guid = 'https://example.com/outbox/123';
124124

125-
$outbox_post_id = $this->factory->post->create(
125+
$outbox_post_id = self::factory()->post->create(
126126
array(
127127
'post_type' => 'ap_outbox',
128128
'post_status' => 'publish',
@@ -133,7 +133,7 @@ public function test_handle_accept_moves_user_from_pending_to_following() {
133133
\add_post_meta( $outbox_post_id, '_activitypub_activity_type', 'Follow' );
134134

135135
// Create remote actor post.
136-
$post_id = $this->factory->post->create(
136+
$post_id = self::factory()->post->create(
137137
array(
138138
'post_type' => Remote_Actors::POST_TYPE,
139139
'post_status' => 'publish',

tests/phpunit/tests/includes/handler/class-test-reject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function test_handle_reject_keeps_user_in_pending() {
123123
$object_guid = 'https://example.com/actor/123';
124124
$outbox_guid = 'https://example.com/outbox/123';
125125

126-
$outbox_post_id = $this->factory->post->create(
126+
$outbox_post_id = self::factory()->post->create(
127127
array(
128128
'post_type' => Outbox::POST_TYPE,
129129
'post_status' => 'publish',
@@ -134,7 +134,7 @@ public function test_handle_reject_keeps_user_in_pending() {
134134
\add_post_meta( $outbox_post_id, '_activitypub_activity_type', 'Follow' );
135135

136136
// Create remote actor post.
137-
$post_id = $this->factory->post->create(
137+
$post_id = self::factory()->post->create(
138138
array(
139139
'post_type' => Remote_Actors::POST_TYPE,
140140
'post_status' => 'publish',

tests/phpunit/tests/includes/handler/class-test-undo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function test_handle_undo_comment_activities( $actor_url, $activity_type,
175175
\add_filter( 'pre_get_remote_metadata_by_actor', $mock_actor_metadata );
176176

177177
// Create a test post.
178-
$post_id = $this->factory->post->create(
178+
$post_id = self::factory()->post->create(
179179
array(
180180
'post_author' => self::$user_id,
181181
'post_title' => 'Test Post for ' . $description,

tests/phpunit/tests/includes/transformer/class-test-base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function get_object_var_keys() {
8484
* @param array $expected_audience The expected audience.
8585
*/
8686
public function test_set_audience( $content_visibility, $object_attributes, $expected_audience ) {
87-
$post_id = $this->factory->post->create(
87+
$post_id = self::factory()->post->create(
8888
array(
8989
'post_title' => 'Test Post',
9090
'post_content' => 'Test content that is longer than the note length limit',

tests/phpunit/tests/includes/transformer/class-test-post.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function tear_down() {
5555
public function test_get_type_returns_configured_type_when_option_set() {
5656
update_option( 'activitypub_object_type', 'Article' );
5757

58-
$post_id = $this->factory->post->create(
58+
$post_id = self::factory()->post->create(
5959
array(
6060
'post_title' => 'Test Post',
6161
'post_content' => 'Test content that is longer than the note length limit',
@@ -81,7 +81,7 @@ public function test_get_type_returns_configured_type_when_option_set() {
8181
* @param string $description Description of the test case.
8282
*/
8383
public function test_get_type( $post_data, $post_format, $expected_type, $description ) {
84-
$post_id = $this->factory->post->create( $post_data );
84+
$post_id = self::factory()->post->create( $post_data );
8585

8686
if ( $post_format ) {
8787
set_post_format( $post_id, $post_format );
@@ -180,7 +180,7 @@ public function test_get_type_respects_post_type_title_support() {
180180
)
181181
);
182182

183-
$post_id = $this->factory->post->create(
183+
$post_id = self::factory()->post->create(
184184
array(
185185
'post_title' => 'Test Post',
186186
'post_content' => str_repeat( 'Long content. ', 100 ),
@@ -213,7 +213,7 @@ public function test_get_type_respects_post_format_support() {
213213
)
214214
);
215215

216-
$post_id = $this->factory->post->create(
216+
$post_id = self::factory()->post->create(
217217
array(
218218
'post_title' => 'Test Post',
219219
'post_content' => str_repeat( 'Long content. ', 100 ),
@@ -496,7 +496,7 @@ public function test_get_media_from_blocks_handles_multiple_blocks() {
496496
* @covers ::get_icon
497497
*/
498498
public function test_get_icon() {
499-
$post_id = $this->factory->post->create(
499+
$post_id = self::factory()->post->create(
500500
array(
501501
'post_title' => 'Test Post',
502502
'post_content' => 'Test content',
@@ -620,7 +620,7 @@ public function create_upload_object( $file, $parent_id = 0 ) {
620620
*/
621621
public function test_preview_property() {
622622
// Create a test post of type "Article".
623-
$post = $this->factory->post->create_and_get(
623+
$post = self::factory()->post->create_and_get(
624624
array(
625625
'post_title' => 'Test Article',
626626
'post_content' => str_repeat( 'Long content. ', 100 ),
@@ -638,7 +638,7 @@ public function test_preview_property() {
638638
$this->assertNotEmpty( $preview['content'] );
639639

640640
// Create a test post of type "Note" (short content).
641-
$note_post = $this->factory->post->create_and_get(
641+
$note_post = self::factory()->post->create_and_get(
642642
array(
643643
'post_title' => '',
644644
'post_content' => 'Short note content',

tests/phpunit/tests/integration/class-test-akismet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public static function wpSetUpBeforeClass( $factory ) {
4040
*/
4141
public function test_comment_row_actions() {
4242
// Create a normal comment.
43-
$normal_comment_id = $this->factory->comment->create(
43+
$normal_comment_id = self::factory()->comment->create(
4444
array(
4545
'comment_post_ID' => self::$post_id,
4646
'comment_content' => 'Normal comment',
4747
)
4848
);
4949

5050
// Create an ActivityPub comment.
51-
$ap_comment_id = $this->factory->comment->create(
51+
$ap_comment_id = self::factory()->comment->create(
5252
array(
5353
'comment_post_ID' => self::$post_id,
5454
'comment_content' => 'ActivityPub comment',

tests/phpunit/tests/integration/class-test-stream-connector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function test_callback_activitypub_outbox_processing_complete() {
343343
}
344344

345345
// Create a mock outbox post.
346-
$outbox_post_id = $this->factory->post->create(
346+
$outbox_post_id = self::factory()->post->create(
347347
array(
348348
'post_type' => 'ap_outbox',
349349
'post_title' => get_permalink( self::$post_id ),
@@ -394,7 +394,7 @@ public function test_callback_activitypub_outbox_processing_batch_complete() {
394394
}
395395

396396
// Create a mock outbox post.
397-
$outbox_post_id = $this->factory->post->create(
397+
$outbox_post_id = self::factory()->post->create(
398398
array(
399399
'post_type' => 'ap_outbox',
400400
'post_title' => get_permalink( self::$post_id ),

0 commit comments

Comments
 (0)