Changeset 54568 for branches/4.8/tests/phpunit/tests/query/search.php
- Timestamp:
- 10/17/2022 06:10:19 PM (2 years ago)
- Location:
- branches/4.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/4.8/tests/phpunit/tests/query/search.php
r38844 r54568 371 371 372 372 add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true ); 373 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );373 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 374 374 375 375 // Pass post_type a string value. … … 397 397 398 398 add_post_meta( $attachment, '_wp_attached_file', 'some-image2.png', true ); 399 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );399 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 400 400 401 401 // Pass post_type an array value. … … 448 448 add_post_meta( $attachment, '_wp_attached_file', 'some-image4.png', true ); 449 449 add_post_meta( $attachment, '_test_meta_key', 'value', true ); 450 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );450 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 451 451 452 452 // Pass post_type a string value. … … 484 484 485 485 add_post_meta( $attachment, '_wp_attached_file', 'some-image5.png', true ); 486 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );486 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 487 487 488 488 // Pass post_type a string value. … … 507 507 * @ticket 22744 508 508 */ 509 public function test_filter_query_attachment_filenames_unhooks_itself() { 510 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 511 512 apply_filters( 'posts_clauses', array( 513 'where' => '', 514 'groupby' => '', 515 'join' => '', 516 'orderby' => '', 517 'distinct' => '', 518 'fields' => '', 519 'limit' => '', 520 ) ); 521 522 $result = has_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 523 524 $this->assertFalse( $result ); 509 public function test_wp_query_removes_filter_wp_allow_query_attachment_by_filename() { 510 $attachment = self::factory()->post->create( 511 array( 512 'post_type' => 'attachment', 513 'post_status' => 'publish', 514 'post_title' => 'bar foo', 515 'post_content' => 'foo bar', 516 'post_excerpt' => 'This post has foo', 517 ) 518 ); 519 520 add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true ); 521 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 522 523 $q = new WP_Query( 524 array( 525 's' => 'image1', 526 'fields' => 'ids', 527 'post_type' => 'attachment', 528 'post_status' => 'inherit', 529 ) 530 ); 531 532 $this->assertSame( array( $attachment ), $q->posts ); 533 534 /* 535 * WP_Query should have removed the wp_allow_query_attachment_by_filename filter 536 * and thus not match the attachment created above 537 */ 538 $q->get_posts(); 539 $this->assertEmpty( $q->posts ); 525 540 } 526 541
Note: See TracChangeset
for help on using the changeset viewer.