@@ -62,6 +62,55 @@ public function test_schedule_post_activity_regular_post() {
62
62
\wp_delete_post ( $ post_id , true );
63
63
}
64
64
65
+ /**
66
+ * Test post activity scheduling during bulk edits.
67
+ *
68
+ * @covers ::schedule_post_activity
69
+ */
70
+ public function test_schedule_post_activity_bulk_edit () {
71
+ wp_set_current_user ( self ::$ user_id );
72
+ $ post_id = self ::factory ()->post ->create ( array ( 'post_author ' => self ::$ user_id ) );
73
+ $ activitpub_id = \add_query_arg ( 'p ' , $ post_id , \home_url ( '/ ' ) );
74
+
75
+ // Test bulk edit that should bail (no author or status change).
76
+ $ _REQUEST ['bulk_edit ' ] = 1 ;
77
+ $ _REQUEST ['post_author ' ] = -1 ;
78
+ $ _REQUEST ['_status ' ] = -1 ;
79
+ $ _REQUEST ['post ' ] = array ( $ post_id );
80
+
81
+ bulk_edit_posts ( $ _REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification
82
+
83
+ $ outbox_item = $ this ->get_latest_outbox_item ( $ activitpub_id );
84
+ $ this ->assertNotSame ( 'Update ' , \get_post_meta ( $ outbox_item ->ID , '_activitypub_activity_type ' , true ) );
85
+
86
+ // Test bulk edit with author change (should not bail).
87
+ $ new_user_id = self ::factory ()->user ->create ( array ( 'role ' => 'editor ' ) );
88
+ get_userdata ( $ new_user_id )->add_cap ( 'activitypub ' );
89
+ wp_set_current_user ( $ new_user_id );
90
+
91
+ $ _REQUEST ['post_author ' ] = $ new_user_id ;
92
+
93
+ bulk_edit_posts ( $ _REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification
94
+
95
+ $ outbox_item = $ this ->get_latest_outbox_item ( $ activitpub_id );
96
+ $ this ->assertNotNull ( $ outbox_item );
97
+
98
+ $ this ->assertSame ( 'Update ' , \get_post_meta ( $ outbox_item ->ID , '_activitypub_activity_type ' , true ) );
99
+
100
+ // Test bulk edit with status change (should not bail).
101
+ $ _REQUEST ['_status ' ] = 'trash ' ;
102
+
103
+ bulk_edit_posts ( $ _REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification
104
+
105
+ $ outbox_item = $ this ->get_latest_outbox_item ( $ activitpub_id );
106
+ $ this ->assertNotNull ( $ outbox_item );
107
+ $ this ->assertSame ( 'Delete ' , \get_post_meta ( $ outbox_item ->ID , '_activitypub_activity_type ' , true ) );
108
+
109
+ // Clean up.
110
+ unset( $ _REQUEST ['bulk_edit ' ], $ _REQUEST ['post_author ' ], $ _REQUEST ['post_status ' ] );
111
+ \wp_delete_post ( $ post_id , true );
112
+ }
113
+
65
114
/**
66
115
* Data provider for no activity tests.
67
116
*
0 commit comments