Ticket #56350: 56350-fix.diff
| File 56350-fix.diff, 7.9 KB (added by , 3 years ago) |
|---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 571a2fd5f4..91ea83e78b 100644
a b 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-attachments-controller.php
diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 27519610e8..c46e584555 100644
a b class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control 216 216 'author_exclude', 217 217 'before', 218 218 'context', 219 'exact_search', 219 220 'exclude', 220 221 'include', 221 222 'media_type', -
tests/phpunit/tests/rest-api/rest-pages-controller.php
diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index a6a9cfa3f4..1151c09e53 100644
a b class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te 73 73 'author_exclude', 74 74 'before', 75 75 'context', 76 'exact_search', 76 77 'exclude', 77 78 'include', 78 79 'menu_order', -
tests/phpunit/tests/rest-api/rest-posts-controller.php
diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index b2a5512fba..0285457f13 100644
a b class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 194 194 'categories', 195 195 'categories_exclude', 196 196 'context', 197 'exact_search', 197 198 'exclude', 198 199 'include', 199 200 'modified_after', … … class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 749 750 } 750 751 } 751 752 753 /** 754 * @ticket 56350 755 */ 756 public function test_get_items_exact_search() { 757 758 self::factory()->post->create( 759 array( 760 'post_title' => 'Rye', 761 'post_content' => 'This is a post about Rye Bread', 762 'post_status' => 'publish', 763 ) 764 ); 765 766 self::factory()->post->create( 767 array( 768 'post_title' => 'Types of Bread', 769 'post_content' => 'Types of bread are White and Rye Bread', 770 'post_status' => 'publish', 771 ) 772 ); 773 774 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 775 776 // General search. 777 $request->set_param( 'search', 'Rye' ); 778 $response = rest_get_server()->dispatch( $request ); 779 $data = $response->get_data(); 780 $this->assertCount( 2, $data, 'Querying the API without exact_search should return all posts containing the search keyword' ); 781 782 // Exact search using same search param. 783 $request->set_param( 'exact_search', true ); 784 $response = rest_get_server()->dispatch( $request ); 785 $data = $response->get_data(); 786 $this->assertCount( 1, $data, 'Querying the API with exact_search should return posts matching the search keyword' ); 787 788 // Note that "exact_search" is still true. 789 $request->set_param( 'search', 'Rye Bread' ); 790 $response = rest_get_server()->dispatch( $request ); 791 $data = $response->get_data(); 792 $this->assertCount( 0, $data, 'Querying the API with exact_search should return posts matching the search keyword' ); 793 } 794 752 795 public function test_get_items_order_and_orderby() { 753 796 self::factory()->post->create( 754 797 array( -
tests/qunit/fixtures/wp-api-generated.js
diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 896322ed48..b31f3b1d8e 100644
a b mockedApiResponse.Schema = { 362 362 "default": [], 363 363 "required": false 364 364 }, 365 "exact_search": { 366 "description": "Use exact search instead of full search.", 367 "type": "boolean", 368 "required": false 369 }, 365 370 "offset": { 366 371 "description": "Offset the result set by a specific number of items.", 367 372 "type": "integer", … … mockedApiResponse.Schema = { 1700 1705 "type": "integer", 1701 1706 "required": false 1702 1707 }, 1708 "exact_search": { 1709 "description": "Use exact search instead of full search.", 1710 "type": "boolean", 1711 "required": false 1712 }, 1703 1713 "offset": { 1704 1714 "description": "Offset the result set by a specific number of items.", 1705 1715 "type": "integer", … … mockedApiResponse.Schema = { 2782 2792 "default": [], 2783 2793 "required": false 2784 2794 }, 2795 "exact_search": { 2796 "description": "Use exact search instead of full search.", 2797 "type": "boolean", 2798 "required": false 2799 }, 2785 2800 "offset": { 2786 2801 "description": "Offset the result set by a specific number of items.", 2787 2802 "type": "integer", … … mockedApiResponse.Schema = { 3509 3524 "default": [], 3510 3525 "required": false 3511 3526 }, 3527 "exact_search": { 3528 "description": "Use exact search instead of full search.", 3529 "type": "boolean", 3530 "required": false 3531 }, 3512 3532 "offset": { 3513 3533 "description": "Offset the result set by a specific number of items.", 3514 3534 "type": "integer", … … mockedApiResponse.Schema = { 4306 4326 "default": [], 4307 4327 "required": false 4308 4328 }, 4329 "exact_search": { 4330 "description": "Use exact search instead of full search.", 4331 "type": "boolean", 4332 "required": false 4333 }, 4309 4334 "offset": { 4310 4335 "description": "Offset the result set by a specific number of items.", 4311 4336 "type": "integer", … … mockedApiResponse.Schema = { 6457 6482 "default": [], 6458 6483 "required": false 6459 6484 }, 6485 "exact_search": { 6486 "description": "Use exact search instead of full search.", 6487 "type": "boolean", 6488 "required": false 6489 }, 6460 6490 "offset": { 6461 6491 "description": "Offset the result set by a specific number of items.", 6462 6492 "type": "integer",