- 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-categories-controller.php
r43567 r43571 42 42 parent::setUp(); 43 43 44 register_meta( 'term', 'test_single', array( 45 'show_in_rest' => true, 46 'single' => true, 47 'type' => 'string', 48 )); 49 register_meta( 'term', 'test_multi', array( 50 'show_in_rest' => true, 51 'single' => false, 52 'type' => 'string', 53 )); 54 register_term_meta( 'category', 'test_cat_single', array( 55 'show_in_rest' => true, 56 'single' => true, 57 'type' => 'string', 58 )); 59 register_term_meta( 'category', 'test_cat_multi', array( 60 'show_in_rest' => true, 61 'single' => false, 62 'type' => 'string', 63 )); 64 register_term_meta( 'post_tag', 'test_tag_meta', array( 65 'show_in_rest' => true, 66 'single' => true, 67 'type' => 'string', 68 )); 44 register_meta( 45 'term', 46 'test_single', 47 array( 48 'show_in_rest' => true, 49 'single' => true, 50 'type' => 'string', 51 ) 52 ); 53 register_meta( 54 'term', 55 'test_multi', 56 array( 57 'show_in_rest' => true, 58 'single' => false, 59 'type' => 'string', 60 ) 61 ); 62 register_term_meta( 63 'category', 64 'test_cat_single', 65 array( 66 'show_in_rest' => true, 67 'single' => true, 68 'type' => 'string', 69 ) 70 ); 71 register_term_meta( 72 'category', 73 'test_cat_multi', 74 array( 75 'show_in_rest' => true, 76 'single' => false, 77 'type' => 'string', 78 ) 79 ); 80 register_term_meta( 81 'post_tag', 82 'test_tag_meta', 83 array( 84 'show_in_rest' => true, 85 'single' => true, 86 'type' => 'string', 87 ) 88 ); 69 89 } 70 90 … … 111 131 'search', 112 132 'slug', 113 ), $keys 133 ), 134 $keys 114 135 ); 115 136 } … … 571 592 array( 572 593 'page' => 2, 573 ), rest_url( 'wp/v2/categories' ) 594 ), 595 rest_url( 'wp/v2/categories' ) 574 596 ); 575 597 $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) ); … … 591 613 array( 592 614 'page' => 2, 593 ), rest_url( 'wp/v2/categories' ) 615 ), 616 rest_url( 'wp/v2/categories' ) 594 617 ); 595 618 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); … … 597 620 array( 598 621 'page' => 4, 599 ), rest_url( 'wp/v2/categories' ) 622 ), 623 rest_url( 'wp/v2/categories' ) 600 624 ); 601 625 $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] ); … … 611 635 array( 612 636 'page' => 5, 613 ), rest_url( 'wp/v2/categories' ) 637 ), 638 rest_url( 'wp/v2/categories' ) 614 639 ); 615 640 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); … … 626 651 array( 627 652 'page' => 6, 628 ), rest_url( 'wp/v2/categories' ) 653 ), 654 rest_url( 'wp/v2/categories' ) 629 655 ); 630 656 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); … … 685 711 $request = new WP_REST_Request( 'GET', '/wp/v2/categories/1' ); 686 712 $response = rest_get_server()->dispatch( $request ); 687 $data = $response->get_data();713 $data = $response->get_data(); 688 714 $this->assertArrayHasKey( 'meta', $data ); 689 715 $this->assertArrayHasKey( 'meta', $data ); … … 841 867 $request->set_param( 'description', 'New Description' ); 842 868 $request->set_param( 'slug', 'new-slug' ); 843 $request->set_param( 'meta', array( 844 'test_single' => 'just meta', 845 'test_cat_single' => 'category-specific meta', 846 'test_tag_meta' => 'tag-specific meta', 847 ) ); 869 $request->set_param( 870 'meta', 871 array( 872 'test_single' => 'just meta', 873 'test_cat_single' => 'category-specific meta', 874 'test_tag_meta' => 'tag-specific meta', 875 ) 876 ); 848 877 $response = rest_get_server()->dispatch( $request ); 849 878 $this->assertEquals( 200, $response->get_status() ); … … 969 998 $term = get_term( 1, 'category' ); 970 999 $response = $endpoint->prepare_item_for_response( $term, $request ); 971 $this->assertEquals( array( 972 'id', 973 'name', 974 ), array_keys( $response->get_data() ) ); 1000 $this->assertEquals( 1001 array( 1002 'id', 1003 'name', 1004 ), 1005 array_keys( $response->get_data() ) 1006 ); 975 1007 } 976 1008 … … 1023 1055 1024 1056 register_rest_field( 1025 'category', 'my_custom_int', array( 1057 'category', 1058 'my_custom_int', 1059 array( 1026 1060 'schema' => $schema, 1027 1061 'get_callback' => array( $this, 'additional_field_get_callback' ),
Note: See TracChangeset
for help on using the changeset viewer.