Changeset 38446 for trunk/tests/phpunit/tests/comment/query.php
- Timestamp:
- 08/30/2016 02:48:00 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/comment/query.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/query.php
r38398 r38446 2496 2496 2497 2497 /** 2498 * @ticket 37696 2499 */ 2500 public function test_hierarchy_should_be_filled_when_cache_is_incomplete() { 2501 global $wpdb; 2502 2503 $p = self::factory()->post->create(); 2504 $comment_1 = self::factory()->comment->create( array( 2505 'comment_post_ID' => $p, 2506 'comment_approved' => '1', 2507 ) ); 2508 $comment_2 = self::factory()->comment->create( array( 2509 'comment_post_ID' => $p, 2510 'comment_approved' => '1', 2511 'comment_parent' => $comment_1, 2512 ) ); 2513 $comment_3 = self::factory()->comment->create( array( 2514 'comment_post_ID' => $p, 2515 'comment_approved' => '1', 2516 'comment_parent' => $comment_1, 2517 ) ); 2518 $comment_4 = self::factory()->comment->create( array( 2519 'comment_post_ID' => $p, 2520 'comment_approved' => '1', 2521 'comment_parent' => $comment_2, 2522 ) ); 2523 2524 // Prime cache. 2525 $q1 = new WP_Comment_Query( array( 2526 'post_id' => $p, 2527 'hierarchical' => true, 2528 ) ); 2529 $q1_ids = wp_list_pluck( $q1->comments, 'comment_ID' ); 2530 $this->assertEqualSets( array( $comment_1, $comment_2, $comment_3, $comment_4 ), $q1_ids ); 2531 2532 // Delete one of the parent caches. 2533 $last_changed = wp_cache_get( 'last_changed', 'comment' ); 2534 $key = md5( serialize( wp_array_slice_assoc( $q1->query_vars, array_keys( $q1->query_var_defaults ) ) ) ); 2535 $cache_key = "get_comment_child_ids:$comment_2:$key:$last_changed"; 2536 wp_cache_delete( $cache_key, 'comment' ); 2537 2538 $q2 = new WP_Comment_Query( array( 2539 'post_id' => $p, 2540 'hierarchical' => true, 2541 ) ); 2542 $q2_ids = wp_list_pluck( $q2->comments, 'comment_ID' ); 2543 $this->assertEqualSets( $q1_ids, $q2_ids ); 2544 } 2545 2546 /** 2498 2547 * @ticket 27571 2499 2548 */
Note: See TracChangeset
for help on using the changeset viewer.