Changeset 12333
- Timestamp:
- 02/19/2019 03:31:05 PM (6 years ago)
- Location:
- branches/4.0
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
-
branches/4.0/src/bp-blogs/bp-blogs-functions.php
r12304 r12333 663 663 'object' => $activity_post_object->comments_tracking->component_id, 664 664 'action' => $activity_post_object->comments_tracking->action_id, 665 'primary_id' => get_current_blog_id(), 665 666 'secondary_id' => implode( ',', $comment_ids ), 666 667 ); -
branches/4.0/tests/phpunit/testcases/blogs/activity.php
r12246 r12333 308 308 309 309 $this->assertEquals( $this->comment_post_id, $p ); 310 } 311 312 /** 313 * @group post_type_comment_activities 314 */ 315 public function test_bp_blogs_update_post_title_activity_meta_should_not_be_the_same_for_same_comment_id() { 316 global $wpdb; 317 318 if ( ! is_multisite() ) { 319 $this->markTestSkipped(); 320 } 321 322 if ( function_exists( 'wp_initialize_site' ) ) { 323 $this->setExpectedDeprecated( 'wpmu_new_blog' ); 324 } 325 326 $b1 = self::factory()->blog->create(); 327 $b2 = self::factory()->blog->create(); 328 $b3 = self::factory()->blog->create(); 329 $u = self::factory()->user->create(); 330 $u2 = self::factory()->user->create(); 331 $commenter = self::factory()->user->get_object_by_id( $u2 ); 332 333 $bids = array( $b1, $b2, $b3 ); 334 $pids = array(); 335 336 foreach ( $bids as $bid ) { 337 switch_to_blog( $bid ); 338 339 // Ensure blog privacy is public so post activities are recorded. 340 update_option( 'blog_public', 1 ); 341 342 // Create the post. 343 $pids[ $bid ] = self::factory()->post->create( array( 344 'post_author' => $u, 345 ) ); 346 347 /* 348 * Create the post comment. 349 * 350 * Both user_id and comment_author_email are required for unit tests. 351 */ 352 $c = self::factory()->comment->create( array( 353 'user_id' => $u2, 354 'comment_author_email' => $commenter->user_email, 355 'comment_post_ID' => $pids[ $bid ], 356 ) ); 357 358 // Approve the comment so the activity item is generated. 359 self::factory()->comment->update_object( $c, array( 'comment_approved' => 1 ) ); 360 361 restore_current_blog(); 362 } 363 364 // Now update the post title on one blog only. 365 switch_to_blog( $b1 ); 366 wp_update_post( array( 367 'ID' => $pids[ $b1 ], 368 'post_title' => 'Updated' 369 ) ); 370 restore_current_blog(); 371 372 // Check our activity meta to see if the post title is different. 373 $aids = bp_activity_get( array( 374 'fields' => 'ids', 375 'filter' => array( 376 'action' => 'new_blog_comment' 377 ) 378 ) ); 379 $aids= $aids['activities']; 380 foreach ( $aids as $aid ) { 381 // Skip the check for the correct blog. 382 $a = new BP_Activity_Activity( $aid ); 383 if ( $a->item_id == $b1 ) { 384 continue; 385 } 386 387 // Assert that post title is different. 388 $post_title = bp_activity_get_meta( $aid, 'post_title' ); 389 $this->assertFalse( 'Updated' === $post_title, 'Post title should not be the same across all sites with the same post comment ID' ); 390 } 310 391 } 311 392
Note: See TracChangeset
for help on using the changeset viewer.