Skip to content

Commit

Permalink
test: add test case for the id=>parent WP_Query the_posts object
Browse files Browse the repository at this point in the history
  • Loading branch information
Juzar10 committed Dec 10, 2024
1 parent c6a1534 commit 5a01801
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/phpunit/tests/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,28 @@ static function () {
$this->assertSame( '/* posts_join_paged */', $posts_clauses['join'] );
}

/**
* @ticket 56992
*/
public function test_the_loop_when_querying_post_parents_only() {
$parent = self::factory()->post->create( array( 'post_type' => 'page' ) );
$child = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $parent ) );

Check failure on line 753 in tests/phpunit/tests/query.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

When a multi-item array uses associative keys, each value should start on a new line.

$query = new WP_Query(
array(
'fields' => 'id=>parent',
'post_type' => 'page',
'page_id' => $child,
)
);

$query->the_post();
$global_post = get_post( null, ARRAY_A );
$specific_post = get_post( $child, ARRAY_A );

$this->assertEqualSetsWithIndex( $global_post, $specific_post );
}

/**
* Tests that the `posts_clauses_request` filter receives an array of clauses
* with the other `posts_*_request` filters applied, e.g. `posts_join_request`.
Expand Down

0 comments on commit 5a01801

Please sign in to comment.