Skip to content

Commit

Permalink
Test cache is primed rather than function call.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Oct 13, 2024
1 parent 97a37d5 commit 7106868
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/phpunit/tests/rest-api/rest-posts-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1706,16 +1706,14 @@ public function test_get_items_primes_parent_post_caches() {
wp_cache_delete_multiple( $parent_ids, 'posts' );
wp_cache_delete_multiple( $attachment_ids, 'posts' );

$filter = new MockAction();
add_filter( 'update_post_metadata_cache', array( $filter, 'filter' ), 10, 2 );

$request = new WP_REST_Request( 'GET', '/wp/v2/media' );
rest_get_server()->dispatch( $request );

$args = $filter->get_args();
$last = end( $args );
$this->assertIsArray( $last, 'The last value is not an array' );
$this->assertSameSets( $parent_ids, $last[1] );
$this->assertNotFalse( wp_cache_get( $parent_id1, 'posts' ), 'Parent post 1 is expected to be primed.' );
$this->assertNotFalse( wp_cache_get( $parent_id1, 'post_meta' ), 'Parent post 1 meta data is expected to be primed.' );

$this->assertNotFalse( wp_cache_get( $parent_id2, 'posts' ), 'Parent post 2 is expected to be primed.' );
$this->assertNotFalse( wp_cache_get( $parent_id2, 'post_meta' ), 'Parent post 2 meta data is expected to be primed.' );
}

public function test_get_items_pagination_headers() {
Expand Down

0 comments on commit 7106868

Please sign in to comment.