| | 1 | <?php |
| | 2 | /** |
| | 3 | * Search functionality |
| | 4 | * |
| | 5 | * @group query |
| | 6 | * @group search |
| | 7 | */ |
| | 8 | class Tests_Query_Search extends WP_UnitTestCase { |
| | 9 | |
| | 10 | function test_search_by_fields() { |
| | 11 | $post_id = $this->factory->post->create( array( 'post_title' => 'Taco', 'post_name' => 'burrito', 'post_content' => 'Enchilada' ) ); |
| | 12 | |
| | 13 | // post slug |
| | 14 | $q1 = new WP_Query( array( 's' => 'Burrito', 'fields' => 'ids' ) ); |
| | 15 | $this->assertEquals( array( $post_id ), $q1->posts ); |
| | 16 | |
| | 17 | // post title |
| | 18 | $q2 = new WP_Query( array( 's' => 'taco', 'fields' => 'ids' ) ); |
| | 19 | $this->assertEquals( array( $post_id ), $q2->posts ); |
| | 20 | |
| | 21 | // post content |
| | 22 | $q3 = new WP_Query( array( 's' => 'enchilada', 'fields' => 'ids' ) ); |
| | 23 | $this->assertEquals( array( $post_id ), $q3->posts ); |
| | 24 | } |
| | 25 | } |
| | 26 | No newline at end of file |