Changeset 13135
- Timestamp:
- 11/01/2021 05:43:00 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r13128 r13135 2312 2312 $activity = new BP_Activity_Activity( $activity_id ); 2313 2313 2314 // Check if the Post author has changed. 2315 if ( (int) $post->post_author !== (int) $activity->user_id ) { 2316 $activity->user_id = (int) $post->post_author; 2317 } 2318 2314 2319 if ( ! empty( $post->post_content ) ) { 2315 2320 $activity_summary = bp_activity_create_summary( $post->post_content, (array) $activity ); -
trunk/tests/phpunit/testcases/activity/actions.php
r11737 r13135 169 169 } 170 170 171 protected function activity_exists_for_post( $post_id, $action ) { 171 /** 172 * @ticket BP8579 173 * @group bp_activity_catch_transition_post_type_status 174 * @group activity_tracking 175 */ 176 public function test_bp_activity_catch_transition_post_type_status_publish_publish_author_changed() { 177 $u1 = self::factory()->user->create( 178 array( 179 'role' => 'auhor', 180 ) 181 ); 182 183 $u2 = self::factory()->user->create( 184 array( 185 'role' => 'auhor', 186 ) 187 ); 188 189 $post_id = self::factory()->post->create( array( 190 'post_status' => 'publish', 191 'post_author' => $u1, 192 'post_type' => 'post', 193 ) ); 194 195 $post = get_post( $post_id ); 196 197 // 'new' => 'publish' 198 $this->assertTrue( $this->activity_exists_for_post( $post_id, 'new_post' ), 'Published post type should have activity' ); 199 200 $post->post_author = $u2; 201 202 wp_update_post( $post ); 203 204 $a = $this->activity_exists_for_post( $post_id, 'new_post', true ); 205 206 $this->assertSame( $u2, $a->user_id, 'The Activity about a published post type should be updated when the post author has changed.' ); 207 } 208 209 /** 210 * @ticket BP8579 211 * @group bp_activity_catch_transition_post_type_status 212 * @group activity_tracking 213 */ 214 public function test_bp_activity_catch_transition_post_type_status_publish_publish_content_changed() { 215 $u1 = self::factory()->user->create( 216 array( 217 'role' => 'auhor', 218 ) 219 ); 220 221 $u2 = self::factory()->user->create( 222 array( 223 'role' => 'auhor', 224 ) 225 ); 226 227 $post_id = self::factory()->post->create( array( 228 'post_status' => 'publish', 229 'post_author' => $u1, 230 'post_type' => 'post', 231 ) ); 232 233 $post = get_post( $post_id ); 234 235 // 'new' => 'publish' 236 $this->assertTrue( $this->activity_exists_for_post( $post_id, 'new_post' ), 'Published post type should have activity' ); 237 238 $post->post_content = "This time {$u2} has not edited the post"; 239 240 wp_update_post( $post ); 241 242 $a = $this->activity_exists_for_post( $post_id, 'new_post', true ); 243 244 $this->assertSame( $post->post_content, $a->content, 'The Activity about a published post type should be updated when the post content has changed.' ); 245 } 246 247 protected function activity_exists_for_post( $post_id, $action, $get_object = false ) { 172 248 $a = bp_activity_get( array( 173 249 'action' => $action, … … 176 252 ) ); 177 253 254 if ( $get_object ) { 255 return reset( $a['activities'] ); 256 } 257 178 258 return ! empty( $a['activities'] ); 179 259 }
Note: See TracChangeset
for help on using the changeset viewer.