Changeset 59115 for trunk/tests/phpunit/tests/blocks/wpBlock.php
- Timestamp:
- 09/30/2024 01:17:40 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/wpBlock.php
r58160 r59115 465 465 466 466 /** 467 * @ticket 62014 468 */ 469 public function test_build_query_vars_from_query_block_standard_post_formats() { 470 $this->registry->register( 471 'core/example', 472 array( 'uses_context' => array( 'query' ) ) 473 ); 474 475 $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' ); 476 $parsed_block = $parsed_blocks[0]; 477 $context = array( 478 'query' => array( 479 'postType' => 'post', 480 'format' => array( 'standard' ), 481 ), 482 ); 483 $block = new WP_Block( $parsed_block, $context, $this->registry ); 484 $query = build_query_vars_from_query_block( $block, 1 ); 485 486 $this->assertSame( 487 array( 488 'post_type' => 'post', 489 'order' => 'DESC', 490 'orderby' => 'date', 491 'post__not_in' => array(), 492 'tax_query' => array( 493 'relation' => 'OR', 494 array( 495 'taxonomy' => 'post_format', 496 'field' => 'slug', 497 'operator' => 'NOT EXISTS', 498 ), 499 ), 500 ), 501 $query 502 ); 503 } 504 505 /** 506 * @ticket 62014 507 */ 508 public function test_build_query_vars_from_query_block_post_format() { 509 $this->registry->register( 510 'core/example', 511 array( 'uses_context' => array( 'query' ) ) 512 ); 513 514 $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' ); 515 $parsed_block = $parsed_blocks[0]; 516 $context = array( 517 'query' => array( 518 'postType' => 'post', 519 'format' => array( 'aside' ), 520 ), 521 ); 522 $block = new WP_Block( $parsed_block, $context, $this->registry ); 523 $query = build_query_vars_from_query_block( $block, 1 ); 524 525 $this->assertSame( 526 array( 527 'post_type' => 'post', 528 'order' => 'DESC', 529 'orderby' => 'date', 530 'post__not_in' => array(), 531 'tax_query' => array( 532 'relation' => 'OR', 533 array( 534 'taxonomy' => 'post_format', 535 'field' => 'slug', 536 'terms' => array( 'post-format-aside' ), 537 'operator' => 'IN', 538 ), 539 ), 540 ), 541 $query 542 ); 543 } 544 /** 545 * @ticket 62014 546 */ 547 public function test_build_query_vars_from_query_block_post_formats_with_category() { 548 $this->registry->register( 549 'core/example', 550 array( 'uses_context' => array( 'query' ) ) 551 ); 552 553 $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' ); 554 $parsed_block = $parsed_blocks[0]; 555 $context = array( 556 'query' => array( 557 'postType' => 'post', 558 'format' => array( 'standard' ), 559 'categoryIds' => array( 56 ), 560 ), 561 ); 562 $block = new WP_Block( $parsed_block, $context, $this->registry ); 563 $query = build_query_vars_from_query_block( $block, 1 ); 564 565 $this->assertSame( 566 array( 567 'post_type' => 'post', 568 'order' => 'DESC', 569 'orderby' => 'date', 570 'post__not_in' => array(), 571 'tax_query' => array( 572 'relation' => 'AND', 573 array( 574 array( 575 'taxonomy' => 'category', 576 'terms' => array( 56 ), 577 'include_children' => false, 578 ), 579 ), 580 array( 581 'relation' => 'OR', 582 array( 583 'taxonomy' => 'post_format', 584 'field' => 'slug', 585 'operator' => 'NOT EXISTS', 586 ), 587 ), 588 ), 589 ), 590 $query 591 ); 592 } 593 594 /** 467 595 * @ticket 52991 468 596 */ … … 482 610 'orderby' => 'date', 483 611 'post__not_in' => array(), 612 'tax_query' => array(), 484 613 ) 485 614 ); … … 513 642 'orderby' => 'date', 514 643 'post__not_in' => array(), 644 'tax_query' => array(), 515 645 'offset' => 0, 516 646 'posts_per_page' => 2, … … 545 675 'orderby' => 'date', 546 676 'post__not_in' => array(), 677 'tax_query' => array(), 547 678 'offset' => 10, 548 679 'posts_per_page' => 5, … … 577 708 'orderby' => 'date', 578 709 'post__not_in' => array(), 710 'tax_query' => array(), 579 711 'offset' => 12, 580 712 'posts_per_page' => 5, … … 620 752 'orderby' => 'title', 621 753 'post__not_in' => array(), 754 'tax_query' => array(), 622 755 ) 623 756 );
Note: See TracChangeset
for help on using the changeset viewer.