Changeset 38844 for trunk/tests/phpunit/tests/query/search.php
- Timestamp:
- 10/20/2016 06:41:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/search.php
r38792 r38844 63 63 * @ticket 38099 64 64 */ 65 function test_ filter_wp_query_use_hyphen_for_exclusion() {65 function test_disable_search_exclusion_prefix() { 66 66 $title = '-HYPHENATION_TEST'; 67 67 … … 75 75 76 76 // After we disable the feature using the filter, we should get the result 77 add_filter( 'wp_query_ use_hyphen_for_exclusion', '__return_false' );77 add_filter( 'wp_query_search_exclusion_prefix', '__return_false' ); 78 78 $result = $this->get_search_results( $title ); 79 79 $post = array_pop( $result ); 80 80 $this->assertEquals( $post->ID, $post_id ); 81 remove_filter( 'wp_query_use_hyphen_for_exclusion', '__return_false' ); 81 remove_filter( 'wp_query_search_exclusion_prefix', '__return_false' ); 82 } 83 84 /** 85 * @ticket 38099 86 */ 87 function test_change_search_exclusion_prefix() { 88 $title = '#OCTOTHORPE_TEST'; 89 90 // Create a post with a title that starts with a non-hyphen prefix. 91 $post_id = self::factory()->post->create( array( 92 'post_content' => $title, 'post_type' => $this->post_type 93 ) ); 94 95 // By default, we should get the result. 96 $result = $this->get_search_results( $title ); 97 $post = array_pop( $result ); 98 $this->assertEquals( $post->ID, $post_id ); 99 100 // After we change the prefix, the result should be excluded. 101 add_filter( 'wp_query_search_exclusion_prefix', array( $this, 'filter_search_exclusion_prefix_octothorpe' ) ); 102 $found = $this->get_search_results( $title ); 103 remove_filter( 'wp_query_search_exclusion_prefix', array( $this, 'filter_search_exclusion_prefix_octothorpe' ) ); 104 $this->assertEquals( array(), $found ); 105 } 106 107 function filter_search_exclusion_prefix_octothorpe() { 108 return '#'; 82 109 } 83 110
Note: See TracChangeset
for help on using the changeset viewer.