Changeset 54175 for trunk/tests/phpunit/tests/blocks/wpBlock.php
- Timestamp:
- 09/15/2022 11:39:43 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/wpBlock.php
r53268 r54175 438 438 'orderBy' => 'title', 439 439 'tagIds' => array( 3, 11, 10 ), 440 'parents' => array( 1, 2 ), 440 441 ), 441 442 ); … … 446 447 $query, 447 448 array( 448 'post_type' => 'page',449 'order' => 'DESC',450 'orderby' => 'title',451 'post__not_in' => array( 1, 2 ),452 'tax_query' => array(449 'post_type' => 'page', 450 'order' => 'DESC', 451 'orderby' => 'title', 452 'post__not_in' => array( 1, 2 ), 453 'tax_query' => array( 453 454 array( 454 455 'taxonomy' => 'category', … … 462 463 ), 463 464 ), 465 'post_parent__in' => array( 1, 2 ), 464 466 ) 465 467 ); … … 581 583 'offset' => 12, 582 584 'posts_per_page' => 5, 585 ) 586 ); 587 } 588 589 /** 590 * @ticket 56467 591 */ 592 public function test_query_loop_block_query_vars_filter() { 593 $this->registry->register( 594 'core/example', 595 array( 'uses_context' => array( 'query' ) ) 596 ); 597 598 $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' ); 599 $parsed_block = $parsed_blocks[0]; 600 $context = array( 601 'query' => array( 602 'postType' => 'page', 603 'orderBy' => 'title', 604 ), 605 ); 606 $block = new WP_Block( $parsed_block, $context, $this->registry ); 607 function filterQuery( $query, $block, $page ) { 608 $query['post_type'] = 'book'; 609 return $query; 610 } 611 add_filter( 'query_loop_block_query_vars', 'filterQuery', 10, 3 ); 612 $query = build_query_vars_from_query_block( $block, 1 ); 613 remove_filter( 'query_loop_block_query_vars', 'filterQuery' ); 614 $this->assertSame( 615 $query, 616 array( 617 'post_type' => 'book', 618 'order' => 'DESC', 619 'orderby' => 'title', 620 'post__not_in' => array(), 583 621 ) 584 622 );
Note: See TracChangeset
for help on using the changeset viewer.