Query: Some documentation and test improvements for update_post_author_caches():

* Make the descriptions for `update_post_author_caches()` and `update_post_caches()` more specific.
* Move the unit test into its own file, for consistency with `update_post_cache()` tests. This also allows for using shared fixtures in case more tests are added in the future.

Follow-up to [53482].

See #55716.

git-svn-id: https://develop.svn.wordpress.org/trunk@53483 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2022-06-10 15:15:07 +00:00
parent aff6a79b27
commit de009085a9
6 changed files with 87 additions and 41 deletions

View File

@@ -620,39 +620,6 @@ class Tests_Query extends WP_UnitTestCase {
$this->assertSame( array( $p2 ), $q->posts );
}
/**
* @ticket 55716
*/
public function test_prime_user_cache() {
$action = new MockAction();
add_filter( 'update_user_metadata_cache', array( $action, 'filter' ), 10, 2 );
$user_ids = array();
$count = 5;
for ( $i = 0; $i < $count; $i ++ ) {
$user_ids[ $i ] = self::factory()->user->create();
self::factory()->post->create(
array(
'post_type' => 'post',
'post_author' => $user_ids[ $i ],
)
);
}
$q = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => $count,
)
);
while ( $q->have_posts() ) {
$q->the_post();
}
$args = $action->get_args();
$last_args = end( $args );
$this->assertSameSets( $user_ids, $last_args[1], 'Ensure that user ids are primed' );
}
/**
* @ticket 35601
*/