Make WordPress Core


Ignore:
Timestamp:
06/10/2022 03:15:07 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query.php

    r53482 r53483  
    622622
    623623    /**
    624      * @ticket 55716
    625      */
    626     public function test_prime_user_cache() {
    627         $action = new MockAction();
    628         add_filter( 'update_user_metadata_cache', array( $action, 'filter' ), 10, 2 );
    629         $user_ids = array();
    630         $count    = 5;
    631         for ( $i = 0; $i < $count; $i ++ ) {
    632             $user_ids[ $i ] = self::factory()->user->create();
    633             self::factory()->post->create(
    634                 array(
    635                     'post_type'   => 'post',
    636                     'post_author' => $user_ids[ $i ],
    637                 )
    638             );
    639         }
    640 
    641         $q = new WP_Query(
    642             array(
    643                 'post_type'      => 'post',
    644                 'posts_per_page' => $count,
    645             )
    646         );
    647         while ( $q->have_posts() ) {
    648             $q->the_post();
    649         }
    650 
    651         $args      = $action->get_args();
    652         $last_args = end( $args );
    653         $this->assertSameSets( $user_ids, $last_args[1], 'Ensure that user ids are primed' );
    654     }
    655 
    656     /**
    657624     * @ticket 35601
    658625     */
Note: See TracChangeset for help on using the changeset viewer.