- Timestamp:
- 10/12/2020 07:52:57 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 */
Note: See TracChangeset
for help on using the changeset viewer.