Ticket #56350: 56350.tests.diff
File 56350.tests.diff, 2.3 KB (added by , 2 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 2c9bf40f19..65d410d5ec 100644
class WP_REST_Posts_Controller extends WP_REST_Controller { 251 251 'search' => 's', 252 252 'slug' => 'post_name__in', 253 253 'status' => 'post_status', 254 'exact_search' => 'exact', 254 255 ); 255 256 256 257 /* … … class WP_REST_Posts_Controller extends WP_REST_Controller { 2834 2835 ); 2835 2836 } 2836 2837 2838 $query_params['exact_search'] = array( 2839 'description' => __( 'Use exact search instead of full search.' ), 2840 'type' => 'boolean', 2841 ); 2842 2837 2843 $query_params['offset'] = array( 2838 2844 'description' => __( 'Offset the result set by a specific number of items.' ), 2839 2845 'type' => 'integer', -
tests/phpunit/tests/rest-api/rest-posts-controller.php
diff --git tests/phpunit/tests/rest-api/rest-posts-controller.php tests/phpunit/tests/rest-api/rest-posts-controller.php index 6ff1edae3e..22e9dd218c 100644
class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 738 738 } 739 739 } 740 740 741 /** 742 * @ticket 56350 743 */ 744 public function test_get_items_exact_search() { 745 746 $this->factory->post->create( 747 array( 748 'post_title' => 'Rye Bread', 749 'post_status' => 'publish', 750 'post_content' => 'Rye Bread is a type of bread', 751 ) 752 ); 753 754 $this->factory->post->create( 755 array( 756 'post_title' => 'Types of Bread', 757 'post_status' => 'publish', 758 'post_content' => 'White and Rye are types of Bread', 759 ) 760 ); 761 762 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 763 $request->set_param( 'search', 'rye bread' ); 764 765 $response = rest_get_server()->dispatch( $request ); 766 $data = $response->get_data(); 767 $this->assertCount( 2, $data ); 768 769 $request->set_param( 'exact_search', true ); 770 $response = rest_get_server()->dispatch( $request ); 771 $data = $response->get_data(); 772 $this->assertCount( 0, $data ); 773 } 774 741 775 public function test_get_items_order_and_orderby() { 742 776 $this->factory->post->create( 743 777 array(