Changeset 54555 for branches/5.6/tests/phpunit/tests/query/search.php
- Timestamp:
- 10/17/2022 05:56:34 PM (2 years ago)
- Location:
- branches/5.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.6
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/5.6/tests/phpunit/tests/query/search.php
r48939 r54555 456 456 457 457 add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true ); 458 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );458 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 459 459 460 460 // Pass post_type a string value. … … 486 486 487 487 add_post_meta( $attachment, '_wp_attached_file', 'some-image2.png', true ); 488 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );488 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 489 489 490 490 // Pass post_type an array value. … … 545 545 add_post_meta( $attachment, '_wp_attached_file', 'some-image4.png', true ); 546 546 add_post_meta( $attachment, '_test_meta_key', 'value', true ); 547 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );547 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 548 548 549 549 // Pass post_type a string value. … … 585 585 586 586 add_post_meta( $attachment, '_wp_attached_file', 'some-image5.png', true ); 587 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );587 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 588 588 589 589 // Pass post_type a string value. … … 610 610 * @ticket 22744 611 611 */ 612 public function test_filter_query_attachment_filenames_unhooks_itself() { 613 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 614 615 apply_filters( 616 'posts_clauses', 617 array( 618 'where' => '', 619 'groupby' => '', 620 'join' => '', 621 'orderby' => '', 622 'distinct' => '', 623 'fields' => '', 624 'limit' => '', 625 ) 626 ); 627 628 $result = has_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 629 630 $this->assertFalse( $result ); 612 public function test_wp_query_removes_filter_wp_allow_query_attachment_by_filename() { 613 $attachment = self::factory()->post->create( 614 array( 615 'post_type' => 'attachment', 616 'post_status' => 'publish', 617 'post_title' => 'bar foo', 618 'post_content' => 'foo bar', 619 'post_excerpt' => 'This post has foo', 620 ) 621 ); 622 623 add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true ); 624 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 625 626 $q = new WP_Query( 627 array( 628 's' => 'image1', 629 'fields' => 'ids', 630 'post_type' => 'attachment', 631 'post_status' => 'inherit', 632 ) 633 ); 634 635 $this->assertSame( array( $attachment ), $q->posts ); 636 637 /* 638 * WP_Query should have removed the wp_allow_query_attachment_by_filename filter 639 * and thus not match the attachment created above 640 */ 641 $q->get_posts(); 642 $this->assertEmpty( $q->posts ); 631 643 } 632 644
Note: See TracChangeset
for help on using the changeset viewer.