Ticket #56350: 56350-latest.diff
File 56350-latest.diff, 7.9 KB (added by , 2 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 3ec9a3a1346..a02a692c4ba 100644
a b public function get_items( $request ) { 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 /* … … public function get_collection_params() { 2836 2837 ); 2837 2838 } 2838 2839 2840 $query_params['exact_search'] = array( 2841 'description' => __( 'Use exact search instead of full search.' ), 2842 'type' => 'boolean', 2843 ); 2844 2839 2845 $query_params['offset'] = array( 2840 2846 'description' => __( 'Offset the result set by a specific number of items.' ), 2841 2847 '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 27519610e86..c46e5845551 100644
a b public function test_registered_query_params() { 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 a6a9cfa3f46..1151c09e53c 100644
a b public function test_registered_query_params() { 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 4b66145d801..d846dab51f8 100644
a b public function test_registered_query_params() { 194 194 'categories', 195 195 'categories_exclude', 196 196 'context', 197 'exact_search', 197 198 'exclude', 198 199 'include', 199 200 'modified_after', … … public function test_get_items_status_without_permissions() { 749 750 } 750 751 } 751 752 753 /** 754 * @ticket 56350 755 * 756 * @dataProvider data_get_items_exact_search 757 * 758 * @param string $search_term The search term. 759 * @param bool $exact_search Whether the search is an exact or general search. 760 * @param int $expected The expected number of matching posts. 761 */ 762 public function test_get_items_exact_search( $search_term, $exact_search, $expected ) { 763 self::factory()->post->create( 764 array( 765 'post_title' => 'Rye', 766 'post_content' => 'This is a post about Rye Bread', 767 ) 768 ); 769 770 self::factory()->post->create( 771 array( 772 'post_title' => 'Types of Bread', 773 'post_content' => 'Types of bread are White and Rye Bread', 774 ) 775 ); 776 777 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 778 $request->set_param( 'search', $search_term ); 779 $request->set_param( 'exact_search', $exact_search ); 780 $response = rest_get_server()->dispatch( $request ); 781 $this->assertCount( $expected, $response->get_data() ); 782 } 783 784 /** 785 * Data provider for test_get_items_exact_search(). 786 * 787 * @return array[] 788 */ 789 public function data_get_items_exact_search() { 790 return array( 791 'general search, one exact match and one partial match' => array( 792 'search_term' => 'Rye', 793 'exact_search' => false, 794 'expected' => 2, 795 ), 796 'exact search, one exact match and one partial match' => array( 797 'search_term' => 'Rye', 798 'exact_search' => true, 799 'expected' => 1, 800 ), 801 'exact search, no match and one partial match' => array( 802 'search_term' => 'Rye Bread', 803 'exact_search' => true, 804 'expected' => 0, 805 ), 806 ); 807 } 808 752 809 public function test_get_items_order_and_orderby() { 753 810 self::factory()->post->create( 754 811 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 896322ed48d..b31f3b1d8e1 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",