Skip to content

Commit

Permalink
Tests: Re-enable failing REST API test for `update_post_parent_caches…
Browse files Browse the repository at this point in the history
…()`.

Ensure that that attachment objects are not primed in cache so that test passes when object caching is enabled. 

Follow-up to [53506].

Props SergeyBiryukov.
See #55593.

git-svn-id: https://develop.svn.wordpress.org/trunk@53512 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
spacedmonkey committed Jun 15, 2022
1 parent c13b9ba commit 43879c0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/phpunit/tests/rest-api/rest-posts-controller.php
Expand Up @@ -1557,11 +1557,11 @@ public function test_get_items_primes_thumbnail_cache_for_featured_media() {
* @covers ::update_post_parent_caches
*/
public function test_get_items_primes_parent_post_caches() {
$parent_id1 = self::$post_ids[0];
$parent_id2 = self::$post_ids[1];
$parent_ids = array( $parent_id2, $parent_id1 );

$this->factory->attachment->create_object(
$parent_id1 = self::$post_ids[0];
$parent_id2 = self::$post_ids[1];
$parent_ids = array( $parent_id1, $parent_id2 );
$attachment_ids = array();
$attachment_ids[] = $this->factory->attachment->create_object(
DIR_TESTDATA . '/images/canola.jpg',
$parent_id1,
array(
Expand All @@ -1570,7 +1570,7 @@ public function test_get_items_primes_parent_post_caches() {
)
);

$this->factory->attachment->create_object(
$attachment_ids[] = $this->factory->attachment->create_object(
DIR_TESTDATA . '/images/canola.jpg',
$parent_id2,
array(
Expand All @@ -1581,6 +1581,7 @@ public function test_get_items_primes_parent_post_caches() {

// Attachment creation warms parent IDs. Needs clean up for test.
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 );
Expand All @@ -1591,8 +1592,7 @@ public function test_get_items_primes_parent_post_caches() {
$args = $filter->get_args();
$last = end( $args );
$this->assertIsArray( $last, 'The last value is not an array' );
// TODO: Enable this once the test is updated to pass with persistent object cache.
// $this->assertSameSets( $parent_ids, $last[1] );
$this->assertSameSets( $parent_ids, $last[1] );
}

public function test_get_items_pagination_headers() {
Expand Down

0 comments on commit 43879c0

Please sign in to comment.