- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r43567 r43571 59 59 parent::setUp(); 60 60 61 register_meta( 'term', 'test_single', array( 62 'show_in_rest' => true, 63 'single' => true, 64 'type' => 'string', 65 )); 66 register_meta( 'term', 'test_multi', array( 67 'show_in_rest' => true, 68 'single' => false, 69 'type' => 'string', 70 )); 71 register_term_meta( 'post_tag', 'test_tag_single', array( 72 'show_in_rest' => true, 73 'single' => true, 74 'type' => 'string', 75 )); 76 register_term_meta( 'post_tag', 'test_tag_multi', array( 77 'show_in_rest' => true, 78 'single' => false, 79 'type' => 'string', 80 )); 81 register_term_meta( 'category', 'test_cat_meta', array( 82 'show_in_rest' => true, 83 'single' => true, 84 'type' => 'string', 85 )); 61 register_meta( 62 'term', 63 'test_single', 64 array( 65 'show_in_rest' => true, 66 'single' => true, 67 'type' => 'string', 68 ) 69 ); 70 register_meta( 71 'term', 72 'test_multi', 73 array( 74 'show_in_rest' => true, 75 'single' => false, 76 'type' => 'string', 77 ) 78 ); 79 register_term_meta( 80 'post_tag', 81 'test_tag_single', 82 array( 83 'show_in_rest' => true, 84 'single' => true, 85 'type' => 'string', 86 ) 87 ); 88 register_term_meta( 89 'post_tag', 90 'test_tag_multi', 91 array( 92 'show_in_rest' => true, 93 'single' => false, 94 'type' => 'string', 95 ) 96 ); 97 register_term_meta( 98 'category', 99 'test_cat_meta', 100 array( 101 'show_in_rest' => true, 102 'single' => true, 103 'type' => 'string', 104 ) 105 ); 86 106 } 87 107 … … 128 148 'search', 129 149 'slug', 130 ), $keys 150 ), 151 $keys 131 152 ); 132 153 } … … 465 486 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 466 487 $request->set_param( 467 'slug', array( 488 'slug', 489 array( 468 490 'taco', 469 491 'burrito', … … 531 553 array( 532 554 'page' => 2, 533 ), rest_url( 'wp/v2/tags' ) 555 ), 556 rest_url( 'wp/v2/tags' ) 534 557 ); 535 558 $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) ); … … 550 573 array( 551 574 'page' => 2, 552 ), rest_url( 'wp/v2/tags' ) 575 ), 576 rest_url( 'wp/v2/tags' ) 553 577 ); 554 578 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); … … 556 580 array( 557 581 'page' => 4, 558 ), rest_url( 'wp/v2/tags' ) 582 ), 583 rest_url( 'wp/v2/tags' ) 559 584 ); 560 585 $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] ); … … 569 594 array( 570 595 'page' => 5, 571 ), rest_url( 'wp/v2/tags' ) 596 ), 597 rest_url( 'wp/v2/tags' ) 572 598 ); 573 599 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); … … 583 609 array( 584 610 'page' => 6, 585 ), rest_url( 'wp/v2/tags' ) 611 ), 612 rest_url( 'wp/v2/tags' ) 586 613 ); 587 614 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); … … 607 634 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); 608 635 $response = rest_get_server()->dispatch( $request ); 609 $data = $response->get_data();636 $data = $response->get_data(); 610 637 $this->assertArrayHasKey( 'meta', $data ); 611 638 … … 625 652 $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id ); 626 653 $response = rest_get_server()->dispatch( $request ); 627 $data = $response->get_data();654 $data = $response->get_data(); 628 655 $this->assertArrayHasKey( 'meta', $data ); 629 656 … … 743 770 $request->set_param( 'description', 'New Description' ); 744 771 $request->set_param( 'slug', 'new-slug' ); 745 $request->set_param( 'meta', array( 746 'test_single' => 'just meta', 747 'test_tag_single' => 'tag-specific meta', 748 'test_cat_meta' => 'category-specific meta', 749 ) ); 772 $request->set_param( 773 'meta', 774 array( 775 'test_single' => 'just meta', 776 'test_tag_single' => 'tag-specific meta', 777 'test_cat_meta' => 'category-specific meta', 778 ) 779 ); 750 780 $response = rest_get_server()->dispatch( $request ); 751 781 $this->assertEquals( 200, $response->get_status() ); … … 898 928 'name' => '\o/ ¯\_(ツ)_/¯', 899 929 'description' => '\o/ ¯\_(ツ)_/¯', 900 ), array( 930 ), 931 array( 901 932 'name' => '\o/ ¯\_(ツ)_/¯', 902 933 'description' => '\o/ ¯\_(ツ)_/¯', … … 913 944 'name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 914 945 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 915 ), array( 946 ), 947 array( 916 948 'name' => 'div strong', 917 949 'description' => 'div <strong>strong</strong> oh noes', … … 924 956 'name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 925 957 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 926 ), array( 958 ), 959 array( 927 960 'name' => 'div strong', 928 961 'description' => 'div <strong>strong</strong> oh noes', … … 939 972 'name' => '\\\&\\\ & &invalid; < < &lt;', 940 973 'description' => '\\\&\\\ & &invalid; < < &lt;', 941 ), array( 974 ), 975 array( 942 976 'name' => '\\\&\\\ & &invalid; < < &lt;', 943 977 'description' => '\\\&\\\ & &invalid; < < &lt;', … … 953 987 'name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 954 988 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 955 ), array( 989 ), 990 array( 956 991 'name' => 'div strong', 957 992 'description' => 'div <strong>strong</strong> oh noes', … … 1064 1099 $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' ); 1065 1100 $response = $endpoint->prepare_item_for_response( $term, $request ); 1066 $this->assertEquals( array( 1067 'id', 1068 'name', 1069 ), array_keys( $response->get_data() ) ); 1101 $this->assertEquals( 1102 array( 1103 'id', 1104 'name', 1105 ), 1106 array_keys( $response->get_data() ) 1107 ); 1070 1108 } 1071 1109 … … 1106 1144 1107 1145 register_rest_field( 1108 'tag', 'my_custom_int', array( 1146 'tag', 1147 'my_custom_int', 1148 array( 1109 1149 'schema' => $schema, 1110 1150 'get_callback' => array( $this, 'additional_field_get_callback' ), … … 1138 1178 1139 1179 register_rest_field( 1140 'tag', 'my_custom_int', array( 1180 'tag', 1181 'my_custom_int', 1182 array( 1141 1183 'schema' => $schema, 1142 1184 'get_callback' => array( $this, 'additional_field_get_callback' ),
Note: See TracChangeset
for help on using the changeset viewer.