Changeset 49132
- Timestamp:
- 10/12/2020 07:52:57 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r49120 r49132 277 277 new WP_REST_Post_Search_Handler(), 278 278 new WP_REST_Term_Search_Handler(), 279 new WP_REST_Post_Format_Search_Handler(), 279 280 ); 280 281 -
trunk/src/wp-settings.php
r49109 r49132 270 270 require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php'; 271 271 require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-term-search-handler.php'; 272 require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-format-search-handler.php'; 272 273 require ABSPATH . WPINC . '/sitemaps.php'; 273 274 require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps.php'; -
trunk/tests/phpunit/tests/rest-api/rest-search-controller.php
r49103 r49132 55 55 */ 56 56 public static function wpSetUpBeforeClass( $factory ) { 57 add_theme_support( 'post-formats' ); 58 57 59 self::$my_title_post_ids = $factory->post->create_many( 58 60 4, … … 78 80 ); 79 81 82 set_post_format( self::$my_title_post_ids[0], 'aside' ); 83 80 84 self::$my_category_id = $factory->term->create( 81 85 array( … … 97 101 */ 98 102 public static function wpTearDownAfterClass() { 103 remove_theme_support( 'post-formats' ); 104 99 105 $post_ids = array_merge( 100 106 self::$my_title_post_ids, … … 705 711 706 712 /** 713 * Search through post formats of any type. 714 * 715 * @ticket 51459 716 */ 717 public function test_get_items_search_type_post_format() { 718 $response = $this->do_request_with_params( 719 array( 720 'per_page' => 100, 721 'type' => 'post-format', 722 ) 723 ); 724 $this->assertEquals( 200, $response->get_status() ); 725 $this->assertContains( 726 'Aside', 727 wp_list_pluck( $response->get_data(), 'title' ) 728 ); 729 } 730 731 /** 732 * Search through all that matches a 'Aside' search. 733 * 734 * @ticket 51459 735 */ 736 public function test_get_items_search_for_test_post_format() { 737 $response = $this->do_request_with_params( 738 array( 739 'per_page' => 100, 740 'search' => 'Aside', 741 'type' => 'post-format', 742 ) 743 ); 744 745 $this->assertEquals( 200, $response->get_status() ); 746 $this->assertContains( 747 'Aside', 748 wp_list_pluck( $response->get_data(), 'title' ) 749 ); 750 } 751 752 /** 753 * Searching for a post format that doesn't exist should return an empty 754 * result. 755 * 756 * @ticket 51459 757 */ 758 public function test_get_items_search_for_missing_post_format() { 759 $response = $this->do_request_with_params( 760 array( 761 'per_page' => 100, 762 'search' => 'Doesn\'t exist', 763 'type' => 'post-format', 764 ) 765 ); 766 767 $this->assertEquals( 200, $response->get_status() ); 768 $this->assertEmpty( $response->get_data() ); 769 } 770 771 /** 707 772 * Perform a REST request to our search endpoint with given parameters. 708 773 */ -
trunk/tests/qunit/fixtures/wp-api-generated.js
r49109 r49132 4511 4511 "enum": [ 4512 4512 "post", 4513 "term" 4513 "term", 4514 "post-format" 4514 4515 ], 4515 4516 "description": "Limit results to items of an object type.",
Note: See TracChangeset
for help on using the changeset viewer.